From a5903c24b9d43db0f1f8fdc25db0c15211d0975d Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Mon, 9 Jan 2023 00:00:18 -0600 Subject: [PATCH] Fixed rotation and offset functions setting values that are too high. --- .../java/noppes/npcs/roles/JobPuppet.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/noppes/npcs/roles/JobPuppet.java b/src/main/java/noppes/npcs/roles/JobPuppet.java index eb283a6a0..e40662654 100644 --- a/src/main/java/noppes/npcs/roles/JobPuppet.java +++ b/src/main/java/noppes/npcs/roles/JobPuppet.java @@ -6,12 +6,12 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.ValueUtil; public class JobPuppet extends JobInterface{ - public PartConfig head = new PartConfig(); - public PartConfig larm = new PartConfig(); - public PartConfig rarm = new PartConfig(); - public PartConfig body = new PartConfig(); - public PartConfig lleg = new PartConfig(); - public PartConfig rleg = new PartConfig(); + public PartConfig head = new PartConfig(this); + public PartConfig larm = new PartConfig(this); + public PartConfig rarm = new PartConfig(this); + public PartConfig body = new PartConfig(this); + public PartConfig lleg = new PartConfig(this); + public PartConfig rleg = new PartConfig(this); public boolean whileStanding = true; public boolean whileAttacking = false; @@ -71,6 +71,8 @@ public class JobPuppet extends JobInterface{ } public static class PartConfig implements IModelPart { + public Object parent; + public float rotationX = 0f; public float rotationY = 0f; public float rotationZ = 0f; @@ -88,6 +90,10 @@ public class JobPuppet extends JobInterface{ public float[] prevPivots = new float[]{0,0,0}; public boolean disabled = false; + + public PartConfig(Object parent) { + this.parent = parent; + } public NBTTagCompound writeNBT(){ NBTTagCompound compound = new NBTTagCompound(); @@ -174,14 +180,23 @@ public class JobPuppet extends JobInterface{ } public void setRotationX(float rotation) { - this.rotationX = rotation; + float f = rotation / 360f - 0.5f; + if(this.getRotationX() != f && parent instanceof JobPuppet) + ((JobPuppet)parent).npc.script.clientNeedsUpdate = true; + this.rotationX = f; } public void setRotationY(float rotation) { + float f = rotation / 360f - 0.5f; + if(this.getRotationY() != f && parent instanceof JobPuppet) + ((JobPuppet)parent).npc.script.clientNeedsUpdate = true; this.rotationY = rotation; } public void setRotationZ(float rotation) { + float f = rotation / 360f - 0.5f; + if(this.getRotationZ() != f && parent instanceof JobPuppet) + ((JobPuppet)parent).npc.script.clientNeedsUpdate = true; this.rotationZ = rotation; } @@ -204,14 +219,20 @@ public class JobPuppet extends JobInterface{ } public void setOffsetX(float offset) { + if(this.getOffsetX() != offset && parent instanceof JobPuppet) + ((JobPuppet)parent).npc.script.clientNeedsUpdate = true; this.pivotX = offset; } public void setOffsetY(float offset) { + if(this.getOffsetY() != offset && parent instanceof JobPuppet) + ((JobPuppet)parent).npc.script.clientNeedsUpdate = true; this.pivotY = offset; } public void setOffsetZ(float offset) { + if(this.getOffsetZ() != offset && parent instanceof JobPuppet) + ((JobPuppet)parent).npc.script.clientNeedsUpdate = true; this.pivotZ = offset; }