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);
}
}
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()]);
}
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;
}
Aggregations