Fixed partial variant detection in the forge blockstate loader.

This commit is contained in:
RainWarrior 2015-06-04 16:59:18 +03:00
parent 5064d33519
commit 897d41fa77
1 changed files with 22 additions and 17 deletions

View File

@ -55,11 +55,10 @@ public class ForgeBlockStateV1 extends Marker
Multimap<String, ForgeBlockStateV1.Variant> specified = HashMultimap.create(); // Multimap containing all the states specified with "property=value".
for (Entry<String, JsonElement> e : JsonUtils.getJsonObject(json, "variants").entrySet())
{
if (e.getKey().contains("=")) //Normal fully defined variant
{
if (e.getValue().isJsonArray())
{
// array of fully-defined variants
for (JsonElement a : e.getValue().getAsJsonArray())
{
Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey();
@ -68,12 +67,10 @@ public class ForgeBlockStateV1 extends Marker
}
else
{
Variant.Deserializer.INSTANCE.simpleSubmodelKey = e.getKey();
specified.put(e.getKey(), (ForgeBlockStateV1.Variant)context.deserialize(e.getValue(), ForgeBlockStateV1.Variant.class));
}
}
else
JsonObject obj = e.getValue().getAsJsonObject();
if(obj.entrySet().iterator().next().getValue().isJsonObject())
{
// first value is a json object, so we know it's not a fully-defined variant
Map<String, ForgeBlockStateV1.Variant> subs = Maps.newHashMap();
condensed.put(e.getKey(), subs);
for (Entry<String, JsonElement> se : e.getValue().getAsJsonObject().entrySet())
@ -82,6 +79,13 @@ public class ForgeBlockStateV1 extends Marker
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));
}
}
}
Multimap<String, ForgeBlockStateV1.Variant> permutations = getPermutations(condensed); // Get permutations of Forge-style states.
@ -178,6 +182,7 @@ public class ForgeBlockStateV1 extends Marker
{
if (depth == sorted.size())
{
if(parent != null)
ret.put(prefix, parent);
return ret;
}