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