Search in sources :

Example 1 with IWoodType

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

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

the class ItemBlockWood method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack itemstack) {
    IWoodTyped wood = getBlock();
    int meta = itemstack.getMetadata();
    IWoodType woodType = wood.getWoodType(meta);
    return WoodHelper.getDisplayName(wood, woodType);
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) IWoodTyped(forestry.arboriculture.IWoodTyped)

Example 3 with IWoodType

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

the class ItemBlockWoodSlab method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack itemstack) {
    BlockForestrySlab<?> wood = (BlockForestrySlab) getBlock();
    int meta = itemstack.getMetadata();
    IWoodType woodType = wood.getWoodType(meta);
    return WoodHelper.getDisplayName(wood, woodType);
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) BlockForestrySlab(forestry.arboriculture.blocks.BlockForestrySlab)

Example 4 with IWoodType

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

the class WoodTypeStateMapper method getModelResourceLocation.

@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
    final Map<IProperty<?>, Comparable<?>> properties;
    if (propertyWoodType != null) {
        properties = Maps.newLinkedHashMap(state.getProperties());
        properties.remove(propertyWoodType);
    } else {
        properties = Maps.newLinkedHashMap(state.getProperties());
    }
    for (IProperty property : propertiesToRemove) {
        properties.remove(property);
    }
    Block block = state.getBlock();
    int meta = block.getMetaFromState(state);
    IWoodType woodType = woodTyped.getWoodType(meta);
    if (woodType instanceof EnumVanillaWoodType) {
        return getVanillaModelResourceLocation(block, woodType, properties);
    } else {
        return getModelResourceLocation(woodType, properties, block.getRegistryName().getResourceDomain());
    }
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) IProperty(net.minecraft.block.properties.IProperty) EnumVanillaWoodType(forestry.api.arboriculture.EnumVanillaWoodType) Block(net.minecraft.block.Block)

Example 5 with IWoodType

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

the class WoodAccess method registerWithoutVariants.

/**
 * Register wood blocks that have no variant property
 */
private <T extends Block & IWoodTyped> void registerWithoutVariants(T woodTyped, WoodBlockKind woodBlockKind) {
    boolean fireproof = woodTyped.isFireproof();
    IBlockState blockState = woodTyped.getDefaultState();
    IWoodType woodType = woodTyped.getWoodType(0);
    ItemStack itemStack = new ItemStack(woodTyped);
    if (!(woodType instanceof EnumVanillaWoodType)) {
        ModuleArboriculture.proxy.registerWoodModel(woodTyped, false);
    }
    register(woodType, woodBlockKind, fireproof, blockState, itemStack);
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) IBlockState(net.minecraft.block.state.IBlockState) EnumVanillaWoodType(forestry.api.arboriculture.EnumVanillaWoodType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IWoodType (forestry.api.arboriculture.IWoodType)14 EnumVanillaWoodType (forestry.api.arboriculture.EnumVanillaWoodType)6 ItemStack (net.minecraft.item.ItemStack)5 IBlockState (net.minecraft.block.state.IBlockState)4 WoodBlockKind (forestry.api.arboriculture.WoodBlockKind)3 ArrayList (java.util.ArrayList)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IWoodTyped (forestry.arboriculture.IWoodTyped)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 BarrelSkin (com.latmod.yabba.api.BarrelSkin)1 EnumForestryWoodType (forestry.api.arboriculture.EnumForestryWoodType)1 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 IWoodItemMeshDefinition (forestry.api.arboriculture.IWoodItemMeshDefinition)1 IWoodStateMapper (forestry.api.arboriculture.IWoodStateMapper)1 BlockArbLog (forestry.arboriculture.blocks.BlockArbLog)1 BlockForestrySlab (forestry.arboriculture.blocks.BlockForestrySlab)1 BlockRegistryArboriculture (forestry.arboriculture.blocks.BlockRegistryArboriculture)1 ItemRegistryArboriculture (forestry.arboriculture.items.ItemRegistryArboriculture)1 ItemRegistryCore (forestry.core.items.ItemRegistryCore)1