From adb581ea6494a804ef31295803ee6b8a4a087023 Mon Sep 17 00:00:00 2001 From: KAMKEEL Date: Thu, 12 Jan 2023 03:13:39 -0500 Subject: [PATCH] Full Animation File Makeup > Remove JobPuppet > Remove PlayerModelData > REWORK IAnimationPart and IAnimation --- src/main/java/noppes/npcs/AnimationData.java | 39 +++ .../java/noppes/npcs/AnimationDataShared.java | 244 ++++++++++++++++++ ...tAnimate.java => AnimationPartConfig.java} | 19 +- src/main/java/noppes/npcs/DataDisplay.java | 1 + .../java/noppes/npcs/ModelPartConfigNEW.java | 49 ---- .../controllers/data/PlayerModelData.java | 24 +- 6 files changed, 296 insertions(+), 80 deletions(-) create mode 100644 src/main/java/noppes/npcs/AnimationData.java create mode 100644 src/main/java/noppes/npcs/AnimationDataShared.java rename src/main/java/noppes/npcs/{ModelPartAnimate.java => AnimationPartConfig.java} (92%) delete mode 100644 src/main/java/noppes/npcs/ModelPartConfigNEW.java diff --git a/src/main/java/noppes/npcs/AnimationData.java b/src/main/java/noppes/npcs/AnimationData.java new file mode 100644 index 000000000..57a59ae8a --- /dev/null +++ b/src/main/java/noppes/npcs/AnimationData.java @@ -0,0 +1,39 @@ +package noppes.npcs; + +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.constants.EnumPacketClient; +import noppes.npcs.controllers.data.PlayerData; +import noppes.npcs.entity.EntityNPCInterface; + +public class AnimationData extends AnimationDataShared { + public EntityNPCInterface npc; + + public boolean whileStanding = true; + public boolean whileAttacking = false; + public boolean whileMoving = false; + + public AnimationData(EntityNPCInterface npc, Object parent){ + super(null); + this.npc = npc; + } + + // CHANGE to CHECK IF PARENT IS NPC LOUIS + @Override + public void updateClient() { + Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_MODEL_DATA, ((PlayerData) parent).player.getCommandSenderName(), this.writeToNBT(new NBTTagCompound())); + } + + public boolean isActive() { + if (!this.allowAnimation) + return false; + + if(!npc.isEntityAlive()) + return false; + + if(whileAttacking && npc.isAttacking() || whileMoving && npc.isWalking() || whileStanding && !npc.isWalking()) + return true; + + return false; + } + +} diff --git a/src/main/java/noppes/npcs/AnimationDataShared.java b/src/main/java/noppes/npcs/AnimationDataShared.java new file mode 100644 index 000000000..08e793247 --- /dev/null +++ b/src/main/java/noppes/npcs/AnimationDataShared.java @@ -0,0 +1,244 @@ +package noppes.npcs; + + +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.constants.EnumPacketClient; +import noppes.npcs.controllers.data.PlayerData; + +public class AnimationDataShared { + public Object parent; + + public AnimationPartConfig head = new AnimationPartConfig(); + public AnimationPartConfig larm = new AnimationPartConfig(); + public AnimationPartConfig rarm = new AnimationPartConfig(); + public AnimationPartConfig body = new AnimationPartConfig(); + public AnimationPartConfig lleg = new AnimationPartConfig(); + public AnimationPartConfig rleg = new AnimationPartConfig(); + + public boolean allowAnimation = false; + + // Full Model Animation + public float rotationX, rotationY, rotationZ; + public boolean rotationEnabledX, rotationEnabledY, rotationEnabledZ; + + public boolean fullAnimate = false; + public float animRate = 1.0F; + public boolean fullAngles; + public boolean interpolate; + + //Client-sided use + public float modelRotPartialTicks; + public float[] modelRotations = {0,0,0}; + + public AnimationDataShared(Object parent){ + this.parent = parent; + } + + public void updateClient() { + Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_MODEL_DATA, ((PlayerData) parent).player.getCommandSenderName(), this.writeToNBT(new NBTTagCompound())); + } + + // SWITCH TO IAnimatePart + public AnimationPartConfig getPart(int part) { + switch (part) { + case 0: + return this.head; + case 1: + return this.body; + case 2: + return this.larm; + case 3: + return this.rarm; + case 4: + return this.lleg; + case 5: + return this.rleg; + } + return null; + } + + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setTag("PuppetHead", head.writeNBT()); + compound.setTag("PuppetLArm", larm.writeNBT()); + compound.setTag("PuppetRArm", rarm.writeNBT()); + compound.setTag("PuppetBody", body.writeNBT()); + compound.setTag("PuppetLLeg", lleg.writeNBT()); + compound.setTag("PuppetRLeg", rleg.writeNBT()); + + compound.setBoolean("PuppetEnabled", allowAnimation); + + compound.setFloat("PuppetRotationX",rotationX); + compound.setFloat("PuppetRotationY",rotationY); + compound.setFloat("PuppetRotationZ",rotationZ); + compound.setBoolean("PuppetRotationEnabledX",rotationEnabledX); + compound.setBoolean("PuppetRotationEnabledY",rotationEnabledY); + compound.setBoolean("PuppetRotationEnabledZ",rotationEnabledZ); + + compound.setBoolean("PuppetFullAngles", fullAngles); + compound.setBoolean("PuppetInterpolate", interpolate); + compound.setBoolean("PuppetAnimate", fullAnimate); + compound.setFloat("PuppetAnimSpeed", animRate); + return compound; + } + + public void readFromNBT(NBTTagCompound compound) { + head.readNBT(compound.getCompoundTag("PuppetHead")); + larm.readNBT(compound.getCompoundTag("PuppetLArm")); + rarm.readNBT(compound.getCompoundTag("PuppetRArm")); + body.readNBT(compound.getCompoundTag("PuppetBody")); + lleg.readNBT(compound.getCompoundTag("PuppetLLeg")); + rleg.readNBT(compound.getCompoundTag("PuppetRLeg")); + + allowAnimation = compound.getBoolean("PuppetEnabled"); + + rotationX = compound.getFloat("PuppetRotationX"); + rotationY = compound.getFloat("PuppetRotationY"); + rotationZ = compound.getFloat("PuppetRotationZ"); + rotationEnabledX = compound.getBoolean("PuppetRotationEnabledX"); + rotationEnabledY = compound.getBoolean("PuppetRotationEnabledY"); + rotationEnabledZ = compound.getBoolean("PuppetRotationEnabledZ"); + + fullAngles = compound.getBoolean("PuppetFullAngles"); + if (!compound.hasKey("PuppetInterpolate")) { + interpolate = true; + } else { + interpolate = compound.getBoolean("PuppetInterpolate"); + } + fullAnimate = compound.getBoolean("PuppetAnimate"); + animRate = compound.getFloat("PuppetAnimSpeed"); + } + + public void setEnabled(boolean enabled) { + this.allowAnimation = enabled; + } + + public boolean enabled() { + return this.allowAnimation; + } + + public void setAnimated(boolean animated) { + this.fullAnimate = animated; + } + + public boolean isAnimated() { + return this.fullAnimate; + } + + public void setInterpolated(boolean interpolate) { + this.interpolate = interpolate; + } + + public boolean isInterpolated() { + return this.interpolate; + } + + public void setFullAngles(boolean limit) { + fullAngles = limit; + } + + public boolean fullAngles() { + return fullAngles; + } + + public void setAnimRate(float animRate) { + if (animRate < 0) + animRate = 0; + this.animRate = animRate; + } + + public float getAnimRate() { + return this.animRate; + } + + public void setRotation(float rotationX, float rotationY, float rotationZ) { + this.setRotationX(rotationX); + this.setRotationY(rotationY); + this.setRotationZ(rotationZ); + } + + public void setRotationX(float rotationX) { + this.rotationX = rotationX; + } + + public void setRotationY(float rotationY) { + this.rotationY = rotationY; + } + + public void setRotationZ(float rotationZ) { + this.rotationZ = rotationZ; + } + + public float getRotationX() { + return rotationX; + } + + public float getRotationY() { + return rotationY; + } + + public float getRotationZ() { + return rotationZ; + } + + public void setRotationEnabled(boolean enabledX, boolean enabledY, boolean enabledZ) { + this.setRotationEnabledX(enabledX); + this.setRotationEnabledY(enabledY); + this.setRotationEnabledZ(enabledZ); + } + + public void setRotationEnabledX(boolean enabled) { + this.rotationEnabledX = enabled; + } + + public void setRotationEnabledY(boolean enabled) { + this.rotationEnabledY = enabled; + } + + public void setRotationEnabledZ(boolean enabled) { + this.rotationEnabledZ = enabled; + } + + public boolean rotationEnabledX() { + return rotationEnabledX; + } + + public boolean rotationEnabledY() { + return rotationEnabledY; + } + + public boolean rotationEnabledZ() { + return rotationEnabledZ; + } + + public void allEnabled(boolean enabled) { + for (int i = 0; i < 6; i++) { + this.getPart(i).setEnabled(enabled); + } + } + + public void allAnimated(boolean animated) { + for (int i = 0; i < 6; i++) { + this.getPart(i).setAnimated(animated); + } + } + + public void allInterpolated(boolean interpolate) { + for (int i = 0; i < 6; i++) { + this.getPart(i).setAnimated(interpolate); + } + } + + public void allFullAngles(boolean fullAngles) { + for (int i = 0; i < 6; i++) { + this.getPart(i).setFullAngles(fullAngles); + } + } + + public void allAnimRate(float animRate) { + if (animRate < 0) + animRate = 0; + for (int i = 0; i < 6; i++) { + this.getPart(i).setAnimRate(animRate); + } + } +} diff --git a/src/main/java/noppes/npcs/ModelPartAnimate.java b/src/main/java/noppes/npcs/AnimationPartConfig.java similarity index 92% rename from src/main/java/noppes/npcs/ModelPartAnimate.java rename to src/main/java/noppes/npcs/AnimationPartConfig.java index 522b85822..8f13e639d 100644 --- a/src/main/java/noppes/npcs/ModelPartAnimate.java +++ b/src/main/java/noppes/npcs/AnimationPartConfig.java @@ -1,17 +1,16 @@ package noppes.npcs; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.roles.JobPuppet; -import noppes.npcs.util.ValueUtil; -public class ModelPartAnimate { - public boolean enabled = false; +public class AnimationPartConfig { + public float rotationX = 0f, rotationY = 0f, rotationZ = 0f; + public float pivotX = 0f, pivotY = 0f, pivotZ = 0f; + + public boolean enablePart = false; public boolean fullAngles = false; public boolean animate = false; public float animRate = 1.0F; public boolean interpolate = true; - public float rotationX = 0f, rotationY = 0f, rotationZ = 0f; - public float pivotX = 0f, pivotY = 0f, pivotZ = 0f; // vvv Client-sided use vvv public float[] prevRotations = new float[]{0, 0, 0}; @@ -22,7 +21,7 @@ public class ModelPartAnimate { public NBTTagCompound writeNBT() { NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("Enabled", enabled); + compound.setBoolean("EnablePart", enablePart); compound.setFloat("RotationX", rotationX); compound.setFloat("RotationY", rotationY); compound.setFloat("RotationZ", rotationZ); @@ -39,7 +38,7 @@ public class ModelPartAnimate { } public void readNBT(NBTTagCompound compound) { - enabled = compound.getBoolean("Enabled"); + enablePart = compound.getBoolean("EnablePart"); rotationX = compound.getFloat("RotationX"); rotationY = compound.getFloat("RotationY"); @@ -60,11 +59,11 @@ public class ModelPartAnimate { } public void setEnabled(boolean enabled) { - this.enabled = enabled; + this.enablePart = enabled; } public boolean isEnabled() { - return this.enabled; + return this.enablePart; } public void setAnimated(boolean animated) { diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 7ba5eaec7..9245d1cbc 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -40,6 +40,7 @@ public class DataDisplay { public long overlayRenderTicks = 0; public JobPuppet modelData; + public AnimationData animationData; public String glowTexture = ""; diff --git a/src/main/java/noppes/npcs/ModelPartConfigNEW.java b/src/main/java/noppes/npcs/ModelPartConfigNEW.java deleted file mode 100644 index a73a6d06d..000000000 --- a/src/main/java/noppes/npcs/ModelPartConfigNEW.java +++ /dev/null @@ -1,49 +0,0 @@ -package noppes.npcs; - -import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.util.ValueUtil; - -public class ModelPartConfigNEW { - public float scaleX = 1, scaleY = 1, scaleZ = 1; - public float transX = 0, transY = 0, transZ = 0; - - public ModelPartAnimate animate = new ModelPartAnimate(); - - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setFloat("ScaleX", scaleX); - compound.setFloat("ScaleY", scaleY); - compound.setFloat("ScaleZ", scaleZ); - - // SAVE ANIMATE - if (animate.enabled) { - compound.setTag("Animate",animate.writeNBT()); - } - - return compound; - } - - public void readFromNBT(NBTTagCompound compound){ - scaleX = ValueUtil.correctFloat(compound.getFloat("ScaleX"), 0.5f, 1.5f); - scaleY = ValueUtil.correctFloat(compound.getFloat("ScaleY"), 0.5f, 1.5f); - scaleZ = ValueUtil.correctFloat(compound.getFloat("ScaleZ"), 0.5f, 1.5f); - - animate.readNBT(compound.getCompoundTag("Animate")); - } - - public String toString(){ - return "ScaleX: " + scaleX + " - ScaleY: " + scaleY + " - ScaleZ: " + scaleZ; - } - - public void setScale(float x, float y, float z) { - scaleX = x; - scaleY = y; - scaleZ = z; - } - - public void setScale(float x, float y) { - scaleZ = scaleX = x; - scaleY = y; - } - -} diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerModelData.java b/src/main/java/noppes/npcs/controllers/data/PlayerModelData.java index 5b676682c..5bea54634 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerModelData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerModelData.java @@ -9,6 +9,9 @@ import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.roles.PartConfig; public class PlayerModelData implements IPlayerModelData { + + // REMOVE THIS CLASS - LOUIS :D + public PlayerData parent; public final EntityPlayer player; @@ -41,27 +44,6 @@ public class PlayerModelData implements IPlayerModelData { this.player = player; } - public void updateClient() { - Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_MODEL_DATA, ((PlayerData) parent).player.getCommandSenderName(), this.writeToNBT(new NBTTagCompound())); - } - - public IModelPart getPart(int part) { - switch (part) { - case 0: - return this.head; - case 1: - return this.body; - case 2: - return this.larm; - case 3: - return this.rarm; - case 4: - return this.lleg; - case 5: - return this.rleg; - } - return null; - } public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("PuppetHead", head.writeNBT());