fix override anim

This commit is contained in:
zimzaza4
2024-09-28 12:12:29 +08:00
parent ad3009b0b7
commit 45c9de0337
3 changed files with 17 additions and 3 deletions

View File

@@ -109,7 +109,7 @@ public class GeneratorMain {
File texturesFolder = new File(output, "textures/entity");
File animationControllersFolder = new File(output, "animation_controllers");
File renderControllersFolder = new File(output, "render_controllers");
File materialsFolder = new File(output, "materials");
File manifestFile = new File(output, "manifest.json");
@@ -131,7 +131,10 @@ public class GeneratorMain {
texturesFolder.mkdirs();
animationControllersFolder.mkdirs();
renderControllersFolder.mkdirs();
materialsFolder.mkdirs();
File materialFile = new File(materialsFolder, "entity.material");
for (Map.Entry<String, Animation> entry : animationMap.entrySet()) {
Geometry geo = geometryMap.get(entry.getKey());
if (geo != null) {

View File

@@ -46,6 +46,16 @@ public class Animation {
for (Map.Entry<String, JsonElement> element : json.get("animations").getAsJsonObject().entrySet()) {
animationIds.add(element.getKey());
JsonObject animation = element.getValue().getAsJsonObject();
if (animation.has("override_previous_animation")) {
if (animation.get("override_previous_animation").getAsBoolean()) {
if (!animation.has("loop")) {
animation.addProperty("loop", "hold_on_last_frame");
// play once but override must use this to avoid strange anim
}
}
}
if (animation.has("loop")) {
if (animation.get("loop").getAsJsonPrimitive().isString()) {
if (animation.get("loop").getAsString().equals("hold_on_last_frame")) {
@@ -74,6 +84,7 @@ public class Animation {
}
}
}
newAnimations.add("animation." + modelId + "." + element.getKey(), element.getValue());
}
json.add("animations", newAnimations);

View File

@@ -23,8 +23,8 @@ public class PackManifest {
}
""";
public static String generate() {
public static String generate() {
return TEMPLATE.replace("%uuid-1%", UUID.randomUUID().toString())
.replace("%uuid-2%", UUID.randomUUID().toString());
.replace("%uuid-2%", UUID.randomUUID().toString());
}
}