From 897d41fa77a2c25a9d4421d99b1299178f2020f4 Mon Sep 17 00:00:00 2001 From: RainWarrior Date: Thu, 4 Jun 2015 16:59:18 +0300 Subject: [PATCH] Fixed partial variant detection in the forge blockstate loader. --- .../client/model/ForgeBlockStateV1.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java index c57515b92..b1cb90572 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java @@ -56,30 +56,34 @@ public class ForgeBlockStateV1 extends Marker for (Entry e : JsonUtils.getJsonObject(json, "variants").entrySet()) { - if (e.getKey().contains("=")) //Normal fully defined variant + if (e.getValue().isJsonArray()) { - if (e.getValue().isJsonArray()) - { - for (JsonElement a : e.getValue().getAsJsonArray()) - { - Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey(); - specified.put(e.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(a, ForgeBlockStateV1.Variant.class)); - } - } - else + // array of fully-defined variants + for (JsonElement a : e.getValue().getAsJsonArray()) { Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey(); - specified.put(e.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(e.getValue(), ForgeBlockStateV1.Variant.class)); + specified.put(e.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(a, ForgeBlockStateV1.Variant.class)); } } else { - Map subs = Maps.newHashMap(); - condensed.put(e.getKey(), subs); - for (Entry se : e.getValue().getAsJsonObject().entrySet()) + JsonObject obj = e.getValue().getAsJsonObject(); + if(obj.entrySet().iterator().next().getValue().isJsonObject()) { - Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey() + "=" + se.getKey(); - subs.put(se.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(se.getValue(), ForgeBlockStateV1.Variant.class)); + // first value is a json object, so we know it's not a fully-defined variant + Map subs = Maps.newHashMap(); + condensed.put(e.getKey(), subs); + for (Entry se : e.getValue().getAsJsonObject().entrySet()) + { + Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey() + "=" + se.getKey(); + subs.put(se.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(se.getValue(), ForgeBlockStateV1.Variant.class)); + } + } + else + { + // fully-defined variant + Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey(); + specified.put(e.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(e.getValue(), ForgeBlockStateV1.Variant.class)); } } } @@ -178,7 +182,8 @@ public class ForgeBlockStateV1 extends Marker { if (depth == sorted.size()) { - ret.put(prefix, parent); + if(parent != null) + ret.put(prefix, parent); return ret; }