Search in sources :

Example 1 with IWoodStateMapper

use of forestry.api.arboriculture.IWoodStateMapper 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)

Aggregations

IWoodItemMeshDefinition (forestry.api.arboriculture.IWoodItemMeshDefinition)1 IWoodStateMapper (forestry.api.arboriculture.IWoodStateMapper)1 IWoodType (forestry.api.arboriculture.IWoodType)1 WoodBlockKind (forestry.api.arboriculture.WoodBlockKind)1 IBlockState (net.minecraft.block.state.IBlockState)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1