Minor cleanup

This commit is contained in:
mezz committed 2017-07-03 17:22:39 -07:00
1 parent 32933ce90b
commit a2eac214b4
3 files changed
+19 -23

No files matched your search

@@ -57,6 +57,6 @@ public enum WoodBlockKind {
break;
}
textures.putAll(customTextures);
return model.retexture(new ImmutableMap.Builder<String, String>().putAll(textures).build());
return model.retexture(ImmutableMap.copyOf(textures));
}
}
@@ -36,6 +36,7 @@ import forestry.api.arboriculture.IWoodType;
import forestry.api.arboriculture.WoodBlockKind;
import forestry.arboriculture.models.WoodTexture.SimpleTexture;
import forestry.arboriculture.models.WoodTexture.TextureMap;
import forestry.core.utils.Log;
@SideOnly(Side.CLIENT)
public class WoodTextureManager {
@@ -44,14 +45,11 @@ public class WoodTextureManager {
public static final String LOCATION = "/assets/forestry/textures/wood_textures.json";
public static void parseFile() {
try {
InputStream stream = WoodTextureManager.class.getResourceAsStream(LOCATION);
JsonReader reader = null;
try {
if(stream == null){
return;
}
reader = new JsonReader(new BufferedReader(new InputStreamReader(stream)));
try (InputStream stream = WoodTextureManager.class.getResourceAsStream(LOCATION)) {
if (stream == null){
return;
}
try (JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(stream)))){
JsonElement json = Streams.parse(reader);
if (json.isJsonObject()) {
JsonObject jsonObject = json.getAsJsonObject();
@@ -64,14 +62,10 @@ public class WoodTextureManager {
}
}
}
} finally {
if (reader != null) {
reader.close();
}
}
} catch (IOException e) {
if (!(e instanceof FileNotFoundException)) {
e.printStackTrace();
Log.error("Error finding wood textures.", e);
}
}
}
@@ -124,11 +118,13 @@ public class WoodTextureManager {
return new SimpleTexture(locations.build());
}
@Nullable
private static WoodTexture getKindTexture(WoodBlockKind blockKind){
String kindName = blockKind.getName();
return WOOD_TEXTURES.get(kindName);
}
@Nullable
private static WoodTexture getTexture(IWoodType woodType){
String woodName = woodType.getName();
woodName = woodName.toLowerCase(Locale.ENGLISH);
@@ -24,6 +24,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.model.multipart.Multipart;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.world.ColorizerFoliage;
@@ -148,28 +149,27 @@ public class ProxyArboricultureClient extends ProxyArboriculture {
ImmutableMap<String, String> textures, IWoodType woodType, WoodBlockKind woodKind, ItemStack itemStack,
IWoodItemMeshDefinition woodDefinition) {
if (woodKind != WoodBlockKind.DOOR) {
IModel basicItemModel = ModelLoaderRegistry
.getModelOrMissing(woodDefinition.getDefaultModelLocation(itemStack));
ResourceLocation defaultModelLocation = woodDefinition.getDefaultModelLocation(itemStack);
IModel basicItemModel = ModelLoaderRegistry.getModelOrMissing(defaultModelLocation);
ModelResourceLocation basicItemLocation = woodDefinition.getModelLocation(itemStack);
registry.putObject(basicItemLocation,
new SimpleRetexturedModel(woodKind.retextureModel(basicItemModel, woodType, textures)));
IModel retextureModel = woodKind.retextureModel(basicItemModel, woodType, textures);
registry.putObject(basicItemLocation, new SimpleRetexturedModel(retextureModel));
}
}
private void retexturBlockModel(IRegistry<ModelResourceLocation, IBakedModel> registry,
ImmutableMap<String, String> textures, IWoodType woodType, WoodBlockKind woodKind, IBlockState blockState,
IWoodStateMapper woodMapper) {
IModel basicModel = ModelLoaderRegistry
.getModelOrMissing(woodMapper.getDefaultModelResourceLocation(blockState));
ModelResourceLocation defaultModelResourceLocation = woodMapper.getDefaultModelResourceLocation(blockState);
IModel basicModel = ModelLoaderRegistry.getModelOrMissing(defaultModelResourceLocation);
if (basicModel instanceof MultipartModel) {
MultipartModel multipartModel = (MultipartModel) basicModel;
Multipart multipart = multipartModel.getMultipart();
multipart.setStateContainer(blockState.getBlock().getBlockState());
}
ModelResourceLocation basicLocation = woodMapper.getModelLocation(blockState);
registry.putObject(basicLocation,
new SimpleRetexturedModel(woodKind.retextureModel(basicModel, woodType, textures)));
IModel retextureModel = woodKind.retextureModel(basicModel, woodType, textures);
registry.putObject(basicLocation, new SimpleRetexturedModel(retextureModel));
}