From 54eabdc65abbacbed8a9fbef6f99fce27210357c Mon Sep 17 00:00:00 2001 From: zimzaza4 <3625282098@qq.com> Date: Sun, 8 Sep 2024 21:59:30 +0800 Subject: [PATCH] new things --- .../generator/Animation.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/re/imc/geysermodelenginepackgenerator/generator/Animation.java b/src/main/java/re/imc/geysermodelenginepackgenerator/generator/Animation.java index e703e66..32e188c 100644 --- a/src/main/java/re/imc/geysermodelenginepackgenerator/generator/Animation.java +++ b/src/main/java/re/imc/geysermodelenginepackgenerator/generator/Animation.java @@ -45,6 +45,32 @@ public class Animation { JsonObject newAnimations = new JsonObject(); for (Map.Entry element : json.get("animations").getAsJsonObject().entrySet()) { animationIds.add(element.getKey()); + JsonObject animation = element.getValue().getAsJsonObject(); + if (animation.has("loop")) { + if (animation.get("loop").getAsJsonPrimitive().isString()) { + if (animation.get("loop").getAsString().equals("hold_on_last_frame")) { + for (Map.Entry bone : animation.get("bones").getAsJsonObject().entrySet()) { + + for (Map.Entry anim : bone.getValue().getAsJsonObject().entrySet()) { + float max = -1; + JsonObject end = null; + for (Map.Entry timeline : anim.getValue().getAsJsonObject().entrySet()) { + float time = Float.parseFloat(timeline.getKey()); + if (time > max) { + max = time; + if (timeline.getValue().isJsonObject()) { + end = timeline.getValue().getAsJsonObject(); + } + } + } + if (end != null && end.get("lerp_mode").getAsString().equals("catmullrom")) { + end.addProperty("lerp_mode", "linear"); + } + } + } + } + } + } newAnimations.add("animation." + modelId + "." + element.getKey(), element.getValue()); } json.add("animations", newAnimations);