Fix invalid rendering of single-frame B3D models (Fix #3815)

This commit is contained in:
Bartek Bok 2017-12-17 03:23:55 +01:00 committed by LexManos
parent 867698eb54
commit 9fdb79ae7a
2 changed files with 9 additions and 4 deletions

View file

@ -670,7 +670,7 @@ public final class ModelLoader extends ModelBakery
textures.addAll(model.getTextures()); // Kick this, just in case. textures.addAll(model.getTextures()); // Kick this, just in case.
models.add(model); models.add(model);
builder.add(Pair.of(model, v.getState())); builder.add(Pair.of(model, new ModelStateComposition(v.getState(), model.getDefaultState())));
} }
if (models.size() == 0) //If all variants are missing, add one with the missing model and default rotation. if (models.size() == 0) //If all variants are missing, add one with the missing model and default rotation.

View file

@ -496,6 +496,9 @@ public enum B3DLoader implements ICustomModelLoader
@Override @Override
public ModelWrapper process(ImmutableMap<String, String> data) public ModelWrapper process(ImmutableMap<String, String> data)
{ {
ImmutableSet<String> newMeshes = this.meshes;
int newDefaultKey = this.defaultKey;
boolean hasChanged = false;
if(data.containsKey("mesh")) if(data.containsKey("mesh"))
{ {
JsonElement e = new JsonParser().parse(data.get("mesh")); JsonElement e = new JsonParser().parse(data.get("mesh"));
@ -518,7 +521,8 @@ public enum B3DLoader implements ICustomModelLoader
return this; return this;
} }
} }
return new ModelWrapper(modelLocation, model, builder.build(), smooth, gui3d, defaultKey, textures); newMeshes = builder.build();
hasChanged = true;
} }
else else
{ {
@ -531,7 +535,8 @@ public enum B3DLoader implements ICustomModelLoader
JsonElement e = new JsonParser().parse(data.get("key")); JsonElement e = new JsonParser().parse(data.get("key"));
if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber())
{ {
return new ModelWrapper(modelLocation, model, meshes, smooth, gui3d, e.getAsNumber().intValue(), textures); newDefaultKey = e.getAsNumber().intValue();
hasChanged = true;
} }
else else
{ {
@ -539,7 +544,7 @@ public enum B3DLoader implements ICustomModelLoader
return this; return this;
} }
} }
return this; return hasChanged ? new ModelWrapper(modelLocation, model, newMeshes, smooth, gui3d, newDefaultKey, textures) : this;
} }
@Override @Override