From fef959d1e9e3b86a80c5d8edc09a1fd542d01f36 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Tue, 9 Jun 2015 12:36:36 -0700 Subject: [PATCH] Redefine removal value in IRetextureableModel from null to empty string {""} due to ImmutibleMap not allowing null Values. Closes #1927 --- .../client/model/ForgeBlockStateV1.java | 2 +- .../client/model/IRetexturableModel.java | 7 ++++--- .../net/minecraftforge/client/model/ModelLoader.java | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java index b1cb90572..8522849d9 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java @@ -416,7 +416,7 @@ public class ForgeBlockStateV1 extends Marker for (Entry e : json.get("textures").getAsJsonObject().entrySet()) { if (e.getValue().isJsonNull()) - ret.textures.put(e.getKey(), null); + ret.textures.put(e.getKey(), ""); // We have to use "" because ImmutibleMaps don't allow nulls -.- else ret.textures.put(e.getKey(), e.getValue().getAsString()); } diff --git a/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java b/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java index 0e6139dd6..eb6248706 100644 --- a/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java +++ b/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java @@ -10,9 +10,10 @@ public interface IRetexturableModel extends IModel * as a model should be able to be retextured multiple times producing * a separate model each time. * - * The input map MAY map to NULL which should be used to indicate the - * texture was removed. Handling of that is up to the model itself. - * Such as using default, missing texture, or removing vertices. + * The input map MAY map to an empty string "" which should be used + * to indicate the texture was removed. Handling of that is up to + * the model itself. Such as using default, missing texture, or + * removing vertices. * * The input should be considered a DIFF of the old textures, not a * replacement as it may not contain everything. diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoader.java b/src/main/java/net/minecraftforge/client/model/ModelLoader.java index 57d0cc314..47ab1a713 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoader.java @@ -293,7 +293,7 @@ public class ModelLoader extends ModelBakery { if (textures.isEmpty()) return this; - + List elements = Lists.newArrayList(); //We have to duplicate this so we can edit it below. for (BlockPart part : (List)this.model.getElements()) { @@ -307,10 +307,10 @@ public class ModelLoader extends ModelBakery neweModel.parent = this.model.parent; Set removed = Sets.newHashSet(); - + for (Entry e : textures.entrySet()) { - if (e.getValue() == null) + if ("".equals(e.getValue())) { removed.add(e.getKey()); neweModel.textures.remove(e.getKey()); @@ -321,7 +321,7 @@ public class ModelLoader extends ModelBakery // Map the model's texture references as if it was the parent of a model with the retexture map as its textures. Map remapped = Maps.newHashMap(); - + for (Entry e : (Set>)neweModel.textures.entrySet()) { if (e.getValue().startsWith("#")) @@ -331,9 +331,9 @@ public class ModelLoader extends ModelBakery remapped.put(e.getKey(), (String)neweModel.textures.get(key)); } } - + neweModel.textures.putAll(remapped); - + //Remove any faces that use a null texture, this is for performance reasons, also allows some cool layering stuff. for (BlockPart part : (List)neweModel.getElements()) {