Incomplete Animate Move

This commit is contained in:
KAMKEEL committed 2023-01-11 23:27:24 -05:00
1 parent 29f529a711
commit 816873dcd8
3 files changed
+236 -1

No files matched your search

@@ -0,0 +1,173 @@
package noppes.npcs;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.roles.JobPuppet;
import noppes.npcs.util.ValueUtil;
public class ModelPartAnimate {
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};
public float[] prevPivots = new float[]{0, 0, 0};
public float partialRotationTick = 0f;
public float partialPivotTick = 0f;
// ^^^ Client-sided use ^^^
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("RotationX", rotationX);
compound.setFloat("RotationY", rotationY);
compound.setFloat("RotationZ", rotationZ);
compound.setFloat("PivotX", pivotX);
compound.setFloat("PivotY", pivotY);
compound.setFloat("PivotZ", pivotZ);
compound.setBoolean("PuppetFullAngles", fullAngles);
compound.setBoolean("PuppetInterpolate", interpolate);
compound.setBoolean("PuppetAnimate", animate);
compound.setFloat("PuppetAnimSpeed", animRate);
return compound;
}
public void readNBT(NBTTagCompound compound) {
rotationX = compound.getFloat("RotationX");
rotationY = compound.getFloat("RotationY");
rotationZ = compound.getFloat("RotationZ");
pivotX = compound.getFloat("PivotX");
pivotY = compound.getFloat("PivotY");
pivotZ = compound.getFloat("PivotZ");
fullAngles = compound.getBoolean("PuppetFullAngles");
if (!compound.hasKey("PuppetInterpolate")) {
interpolate = true;
} else {
interpolate = compound.getBoolean("PuppetInterpolate");
}
animate = compound.getBoolean("PuppetAnimate");
animRate = compound.getFloat("PuppetAnimSpeed");
}
public void setEnabled(boolean bo) {
this.disabled = !bo;
}
public boolean isEnabled() {
return !this.disabled;
}
public void setAnimated(boolean animated) {
this.animate = animated;
}
public boolean isAnimated() {
return this.animate;
}
public void setInterpolated(boolean interpolate) {
this.interpolate = interpolate;
}
public boolean isInterpolated() {
return this.interpolate;
}
public void setFullAngles(boolean fullAngles) {
this.fullAngles = fullAngles;
}
public boolean fullAngles() {
return this.fullAngles;
}
public void setAnimRate(float animRate) {
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 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 = f;
}
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 = f;
}
public float getRotationX() {
return this.rotationX;
}
public float getRotationY() {
return this.rotationY;
}
public float getRotationZ() {
return this.rotationZ;
}
public void setOffset(float offsetX, float offsetY, float offsetZ) {
this.setOffsetX(offsetX);
this.setOffsetY(offsetY);
this.setOffsetZ(offsetZ);
}
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;
}
public float getOffsetX() {
return this.pivotX;
}
public float getOffsetY() {
return this.pivotY;
}
public float getOffsetZ() {
return this.pivotZ;
}
}
@@ -0,0 +1,62 @@
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 boolean enableAnimate = false;
public ModelPartAnimate animate = new ModelPartAnimate();
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("ScaleX", scaleX);
compound.setFloat("ScaleY", scaleY);
compound.setFloat("ScaleZ", scaleZ);
compound.setFloat("TransX", transX);
compound.setFloat("TransY", transY);
compound.setFloat("TransZ", transZ);
// SAVE ANIMATE
if(enableAnimate){
// LOUIS
// SAVE ANIMATE VARIABLE
// which contains the PartConfig
}
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);
transX = compound.getFloat("TransX");
transY = compound.getFloat("TransY");
transZ = compound.getFloat("TransZ");
// LOAD enableAnimate
}
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;
}
}
@@ -94,7 +94,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
private void showPlayerButtons() {
int y = guiTop ;
addButton(new GuiNpcButton(9, guiLeft + 4, y += 22, 96, 20, "model.rotate"));
addButton(new GuiNpcButton(9, guiLeft + 4, y += 22, 96, 20, "model.animate"));
addButton(new GuiNpcButton(8, guiLeft + 4, y += 22, 96, 20, "model.scale"));