mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 19:15:11 +00:00
Full Animation File Makeup
> Remove JobPuppet > Remove PlayerModelData > REWORK IAnimationPart and IAnimation
This commit is contained in:
1 parent
8e3440bc73
commit
adb581ea64
6 files changed
+296
-80
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -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) {
|
||||
@@ -40,6 +40,7 @@ public class DataDisplay {
|
||||
public long overlayRenderTicks = 0;
|
||||
|
||||
public JobPuppet modelData;
|
||||
public AnimationData animationData;
|
||||
|
||||
public String glowTexture = "";
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user