diff --git a/serializer-minecraft/src/main/java/team/unnamed/creative/serialize/minecraft/model/ModelSerializer.java b/serializer-minecraft/src/main/java/team/unnamed/creative/serialize/minecraft/model/ModelSerializer.java index 44a347ea..be83c38f 100644 --- a/serializer-minecraft/src/main/java/team/unnamed/creative/serialize/minecraft/model/ModelSerializer.java +++ b/serializer-minecraft/src/main/java/team/unnamed/creative/serialize/minecraft/model/ModelSerializer.java @@ -114,7 +114,6 @@ public void serializeToJson(Model model, JsonWriter writer) throws IOException { writer.name("ambientocclusion").value(ambientOcclusion); } - writer.name("textures"); writeTextures(writer, model.textures()); Model.GuiLight guiLight = model.guiLight(); @@ -449,18 +448,26 @@ private static ItemTransform readItemTransform(JsonElement node) { } private static void writeTextures(JsonWriter writer, ModelTextures texture) throws IOException { + final ModelTexture particle = texture.particle(); + final List layers = texture.layers(); + final Map variables = texture.variables(); + + if (particle == null && layers.isEmpty() && variables.isEmpty()) { + // do not write if completely empty + return; + } + + writer.name("textures"); writer.beginObject(); - ModelTexture particle = texture.particle(); if (particle != null) { writer.name("particle"); writeModelTexture(writer, particle); } - List layers = texture.layers(); for (int i = 0; i < layers.size(); i++) { writer.name("layer" + i); writeModelTexture(writer, layers.get(i)); } - for (Map.Entry variable : texture.variables().entrySet()) { + for (Map.Entry variable : variables.entrySet()) { writer.name(variable.getKey()); writeModelTexture(writer, variable.getValue()); }