Search in sources :

Example 6 with EnumVanillaWoodType

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

the class WoodAccess method registerWithVariants.

private <T extends Block & IWoodTyped, V extends Enum<V> & IWoodType> void registerWithVariants(T woodTyped, WoodBlockKind woodBlockKind, PropertyWoodType<V> property) {
    boolean fireproof = woodTyped.isFireproof();
    for (V value : property.getAllowedValues()) {
        IBlockState blockState = woodTyped.getDefaultState().withProperty(property, value);
        int meta = woodTyped.getMetaFromState(blockState);
        IWoodType woodType = woodTyped.getWoodType(meta);
        ItemStack itemStack = new ItemStack(woodTyped, 1, meta);
        if (!(woodType instanceof EnumVanillaWoodType)) {
            ModuleArboriculture.proxy.registerWoodModel(woodTyped, true);
        }
        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)

Example 7 with EnumVanillaWoodType

use of forestry.api.arboriculture.EnumVanillaWoodType 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 8 with EnumVanillaWoodType

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

Aggregations

EnumVanillaWoodType (forestry.api.arboriculture.EnumVanillaWoodType)8 IWoodType (forestry.api.arboriculture.IWoodType)6 IBlockState (net.minecraft.block.state.IBlockState)4 ItemStack (net.minecraft.item.ItemStack)4 WoodBlockKind (forestry.api.arboriculture.WoodBlockKind)2 BarrelSkin (com.latmod.yabba.api.BarrelSkin)1 EnumForestryWoodType (forestry.api.arboriculture.EnumForestryWoodType)1 ArrayList (java.util.ArrayList)1 Block (net.minecraft.block.Block)1 BlockPlanks (net.minecraft.block.BlockPlanks)1 IProperty (net.minecraft.block.properties.IProperty)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1