Search in sources :

Example 1 with WoodBlockKind

use of forestry.api.arboriculture.WoodBlockKind in project ForestryMC by ForestryMC.

the class ProxyArboricultureClient method onModelBake.

@SubscribeEvent
public <T extends Block & IWoodTyped> void onModelBake(ModelBakeEvent event) {
    IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
    for (WoodModelEntry<T> entry : woodModelEntrys) {
        T woodTyped = entry.woodTyped;
        WoodBlockKind woodKind = woodTyped.getBlockKind();
        IWoodStateMapper woodMapper = stateMappers.get(woodTyped);
        for (IBlockState blockState : woodTyped.getBlockState().getValidStates()) {
            IWoodType woodType;
            ItemStack itemStack;
            if (entry.withVariants) {
                int meta = woodTyped.getMetaFromState(blockState);
                woodType = woodTyped.getWoodType(meta);
                itemStack = new ItemStack(woodTyped, 1, meta);
            } else {
                woodType = woodTyped.getWoodType(0);
                itemStack = new ItemStack(woodTyped);
            }
            IWoodItemMeshDefinition definition = shapers.get(itemStack.getItem());
            ImmutableMap<String, String> textures = WoodTextureManager.getTextures(woodType, woodKind);
            if (definition != null) {
                retextureItemModel(registry, textures, woodType, woodKind, itemStack, definition);
            }
            if (woodMapper != null) {
                retexturBlockModel(registry, textures, woodType, woodKind, blockState, woodMapper);
            }
        }
    }
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IWoodStateMapper(forestry.api.arboriculture.IWoodStateMapper) IWoodItemMeshDefinition(forestry.api.arboriculture.IWoodItemMeshDefinition) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with WoodBlockKind

use of forestry.api.arboriculture.WoodBlockKind in project ForestryMC by ForestryMC.

the class WoodHelper method getResourceLocations.

public static ResourceLocation[] getResourceLocations(IWoodTyped typed) {
    List<ResourceLocation> resourceLocations = new ArrayList<>();
    WoodBlockKind blockKind = typed.getBlockKind();
    for (IWoodType woodType : typed.getWoodTypes()) {
        if (woodType instanceof EnumVanillaWoodType) {
            resourceLocations.add(new ResourceLocation("minecraft", woodType + "_" + blockKind));
        } else {
            resourceLocations.add(new ResourceLocation(Constants.MOD_ID, blockKind + "/" + woodType));
        }
    }
    return resourceLocations.toArray(new ResourceLocation[resourceLocations.size()]);
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) EnumVanillaWoodType(forestry.api.arboriculture.EnumVanillaWoodType) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList)

Example 3 with WoodBlockKind

use of forestry.api.arboriculture.WoodBlockKind in project ForestryMC by ForestryMC.

the class WoodHelper method getDisplayName.

public static String getDisplayName(IWoodTyped wood, IWoodType woodType) {
    WoodBlockKind blockKind = wood.getBlockKind();
    String displayName;
    if (woodType instanceof EnumForestryWoodType) {
        String customUnlocalizedName = "tile.for." + blockKind + "." + woodType + ".name";
        if (Translator.canTranslateToLocal(customUnlocalizedName)) {
            displayName = Translator.translateToLocal(customUnlocalizedName);
        } else {
            String woodGrammar = Translator.translateToLocal("for." + blockKind + ".grammar");
            String woodTypeName = Translator.translateToLocal("for.trees.woodType." + woodType);
            displayName = woodGrammar.replaceAll("%TYPE", woodTypeName);
        }
    } else if (woodType instanceof EnumVanillaWoodType) {
        displayName = TreeManager.woodAccess.getStack(woodType, blockKind, false).getDisplayName();
    } else {
        throw new IllegalArgumentException("Unknown wood type: " + woodType);
    }
    if (wood.isFireproof()) {
        displayName = Translator.translateToLocalFormatted("tile.for.fireproof", displayName);
    }
    return displayName;
}
Also used : WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) EnumVanillaWoodType(forestry.api.arboriculture.EnumVanillaWoodType) EnumForestryWoodType(forestry.api.arboriculture.EnumForestryWoodType)

Example 4 with WoodBlockKind

use of forestry.api.arboriculture.WoodBlockKind in project ForestryMC by ForestryMC.

the class ModuleArboriculture method registerSprites.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerSprites(TextureStitchEvent.Pre event) {
    TextureLeaves.registerAllSprites();
    WoodTextureManager.parseFile();
    for (IAlleleFruit alleleFruit : AlleleFruits.getFruitAlleles()) {
        alleleFruit.getProvider().registerSprites();
    }
    List<ResourceLocation> textures = new ArrayList<>();
    for (IWoodType type : TreeManager.woodAccess.getRegisteredWoodTypes()) {
        textures.add(new ResourceLocation(type.getHeartTexture()));
        textures.add(new ResourceLocation(type.getBarkTexture()));
        textures.add(new ResourceLocation(type.getDoorLowerTexture()));
        textures.add(new ResourceLocation(type.getDoorUpperTexture()));
        textures.add(new ResourceLocation(type.getPlankTexture()));
        for (WoodBlockKind kind : WoodBlockKind.values()) {
            for (Entry<String, String> loc : WoodTextureManager.getTextures(type, kind).entrySet()) {
                textures.add(new ResourceLocation(loc.getValue()));
            }
        }
    }
    for (ResourceLocation loc : textures) {
        TextureManagerForestry.registerSprite(loc);
    }
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with WoodBlockKind

use of forestry.api.arboriculture.WoodBlockKind in project Binnie by ForestryMC.

the class WoodManager method getDisplayName.

public static String getDisplayName(IWoodTyped wood, IWoodType woodType) {
    WoodBlockKind blockKind = wood.getBlockKind();
    String displayName;
    if (woodType instanceof EnumETLog || woodType instanceof EnumShrubLog) {
        String customUnlocalizedName = "tile.et." + blockKind + "." + woodType + ".name";
        if (Translator.canTranslateToLocal(customUnlocalizedName)) {
            displayName = Translator.translateToLocal(customUnlocalizedName);
        } else {
            String woodGrammar = Translator.translateToLocal("for." + blockKind + ".grammar");
            String woodTypeName = Translator.translateToLocal("et.trees.woodType." + woodType);
            displayName = woodGrammar.replaceAll("%TYPE", woodTypeName);
        }
    } else {
        throw new IllegalArgumentException("Unknown wood type: " + woodType);
    }
    if (wood.isFireproof()) {
        displayName = Translator.translateToLocalFormatted("tile.for.fireproof", displayName);
    }
    return displayName;
}
Also used : WoodBlockKind(forestry.api.arboriculture.WoodBlockKind)

Aggregations

WoodBlockKind (forestry.api.arboriculture.WoodBlockKind)5 IWoodType (forestry.api.arboriculture.IWoodType)3 EnumVanillaWoodType (forestry.api.arboriculture.EnumVanillaWoodType)2 ArrayList (java.util.ArrayList)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumForestryWoodType (forestry.api.arboriculture.EnumForestryWoodType)1 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 IWoodItemMeshDefinition (forestry.api.arboriculture.IWoodItemMeshDefinition)1 IWoodStateMapper (forestry.api.arboriculture.IWoodStateMapper)1 IBlockState (net.minecraft.block.state.IBlockState)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ItemStack (net.minecraft.item.ItemStack)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1