From a564bcdb0ec067a9e5ecf384caacad5575404ba7 Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:56:14 -0500 Subject: [PATCH] Added tick duration read/write nbt --- src/main/java/noppes/npcs/controllers/data/Animation.java | 7 +++++++ src/main/java/noppes/npcs/controllers/data/Frame.java | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/controllers/data/Animation.java b/src/main/java/noppes/npcs/controllers/data/Animation.java index 6754a3825..4e2ce3c8e 100644 --- a/src/main/java/noppes/npcs/controllers/data/Animation.java +++ b/src/main/java/noppes/npcs/controllers/data/Animation.java @@ -183,6 +183,12 @@ public class Animation implements IAnimation { smooth = compound.getByte("Smooth"); loop = compound.getInteger("Loop"); + if (compound.hasKey("TickDuration")) { + this.tickDuration = compound.getInteger("TickDuration"); + } else if(compound.hasKey("RenderTicks")){ + this.tickDuration = compound.getBoolean("RenderTicks") ? 20 : 50; + } + ArrayList frames = new ArrayList(); NBTTagList list = compound.getTagList("Frames", 10); for (int i = 0; i < list.tagCount(); i++) { @@ -206,6 +212,7 @@ public class Animation implements IAnimation { compound.setFloat("Speed", speed); compound.setByte("Smooth", smooth); compound.setInteger("Loop",loop); + compound.setInteger("TickDuration", tickDuration); NBTTagList list = new NBTTagList(); for(Frame frame : frames){ diff --git a/src/main/java/noppes/npcs/controllers/data/Frame.java b/src/main/java/noppes/npcs/controllers/data/Frame.java index df810234b..c59fd0ec8 100644 --- a/src/main/java/noppes/npcs/controllers/data/Frame.java +++ b/src/main/java/noppes/npcs/controllers/data/Frame.java @@ -135,9 +135,13 @@ public class Frame implements IFrame { customized = true; smooth = compound.getByte("Smooth"); } - if(compound.hasKey("RenderTicks")){ + + if (compound.hasKey("TickDuration")) { + customized = true; + this.tickDuration = compound.getInteger("TickDuration"); + } else if(compound.hasKey("RenderTicks")){ customized = true; - this.tickDuration = 20; + this.tickDuration = compound.getBoolean("RenderTicks") ? 20 : 50; } if (!customized) {