Redefine removal value in IRetextureableModel from null to empty string {""} due to ImmutibleMap not allowing null Values. Closes #1927

This commit is contained in:
Lex Manos 2015-06-09 12:36:36 -07:00
parent f62ee5c4f5
commit fef959d1e9
3 changed files with 11 additions and 10 deletions

View file

@ -416,7 +416,7 @@ public class ForgeBlockStateV1 extends Marker
for (Entry<String, JsonElement> e : json.get("textures").getAsJsonObject().entrySet()) for (Entry<String, JsonElement> e : json.get("textures").getAsJsonObject().entrySet())
{ {
if (e.getValue().isJsonNull()) 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 else
ret.textures.put(e.getKey(), e.getValue().getAsString()); ret.textures.put(e.getKey(), e.getValue().getAsString());
} }

View file

@ -10,9 +10,10 @@ public interface IRetexturableModel extends IModel
* as a model should be able to be retextured multiple times producing * as a model should be able to be retextured multiple times producing
* a separate model each time. * a separate model each time.
* *
* The input map MAY map to NULL which should be used to indicate the * The input map MAY map to an empty string "" which should be used
* texture was removed. Handling of that is up to the model itself. * to indicate the texture was removed. Handling of that is up to
* Such as using default, missing texture, or removing vertices. * 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 * The input should be considered a DIFF of the old textures, not a
* replacement as it may not contain everything. * replacement as it may not contain everything.

View file

@ -293,7 +293,7 @@ public class ModelLoader extends ModelBakery
{ {
if (textures.isEmpty()) if (textures.isEmpty())
return this; return this;
List<BlockPart> elements = Lists.newArrayList(); //We have to duplicate this so we can edit it below. List<BlockPart> elements = Lists.newArrayList(); //We have to duplicate this so we can edit it below.
for (BlockPart part : (List<BlockPart>)this.model.getElements()) for (BlockPart part : (List<BlockPart>)this.model.getElements())
{ {
@ -307,10 +307,10 @@ public class ModelLoader extends ModelBakery
neweModel.parent = this.model.parent; neweModel.parent = this.model.parent;
Set<String> removed = Sets.newHashSet(); Set<String> removed = Sets.newHashSet();
for (Entry<String, String> e : textures.entrySet()) for (Entry<String, String> e : textures.entrySet())
{ {
if (e.getValue() == null) if ("".equals(e.getValue()))
{ {
removed.add(e.getKey()); removed.add(e.getKey());
neweModel.textures.remove(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 the model's texture references as if it was the parent of a model with the retexture map as its textures.
Map<String, String> remapped = Maps.newHashMap(); Map<String, String> remapped = Maps.newHashMap();
for (Entry<String, String> e : (Set<Entry<String, String>>)neweModel.textures.entrySet()) for (Entry<String, String> e : (Set<Entry<String, String>>)neweModel.textures.entrySet())
{ {
if (e.getValue().startsWith("#")) if (e.getValue().startsWith("#"))
@ -331,9 +331,9 @@ public class ModelLoader extends ModelBakery
remapped.put(e.getKey(), (String)neweModel.textures.get(key)); remapped.put(e.getKey(), (String)neweModel.textures.get(key));
} }
} }
neweModel.textures.putAll(remapped); neweModel.textures.putAll(remapped);
//Remove any faces that use a null texture, this is for performance reasons, also allows some cool layering stuff. //Remove any faces that use a null texture, this is for performance reasons, also allows some cool layering stuff.
for (BlockPart part : (List<BlockPart>)neweModel.getElements()) for (BlockPart part : (List<BlockPart>)neweModel.getElements())
{ {