2022-12-31 18:47:13 -06:00
|
|
|
package noppes.npcs.controllers.data;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import noppes.npcs.Server;
|
|
|
|
|
import noppes.npcs.api.handler.IPlayerModelData;
|
2023-01-08 22:57:52 -06:00
|
|
|
import noppes.npcs.api.handler.data.IModelPart;
|
2022-12-31 18:47:13 -06:00
|
|
|
import noppes.npcs.constants.EnumPacketClient;
|
|
|
|
|
import noppes.npcs.roles.JobPuppet;
|
|
|
|
|
|
|
|
|
|
public class PlayerModelData implements IPlayerModelData {
|
|
|
|
|
public PlayerData parent;
|
|
|
|
|
public final EntityPlayer player;
|
|
|
|
|
|
|
|
|
|
public JobPuppet.PartConfig head = new JobPuppet.PartConfig();
|
|
|
|
|
public JobPuppet.PartConfig larm = new JobPuppet.PartConfig();
|
|
|
|
|
public JobPuppet.PartConfig rarm = new JobPuppet.PartConfig();
|
|
|
|
|
public JobPuppet.PartConfig body = new JobPuppet.PartConfig();
|
|
|
|
|
public JobPuppet.PartConfig lleg = new JobPuppet.PartConfig();
|
|
|
|
|
public JobPuppet.PartConfig rleg = new JobPuppet.PartConfig();
|
|
|
|
|
|
|
|
|
|
public boolean enabled = false;
|
2023-01-06 14:28:15 -06:00
|
|
|
public float rotationX, rotationY, rotationZ;
|
2023-01-05 17:58:32 -06:00
|
|
|
public boolean rotationEnabledX, rotationEnabledY, rotationEnabledZ;
|
|
|
|
|
|
2022-12-31 18:47:13 -06:00
|
|
|
public boolean animate = false;
|
|
|
|
|
public float animRate = 1.0F;
|
2023-01-08 22:57:52 -06:00
|
|
|
public boolean fullAngles;
|
2023-01-07 13:38:44 -06:00
|
|
|
public boolean interpolate;
|
2022-12-31 18:47:13 -06:00
|
|
|
|
|
|
|
|
//Client-sided use
|
2023-01-06 13:43:49 -06:00
|
|
|
public float modelRotPartialTicks;
|
|
|
|
|
public float[] modelRotations = {0,0,0};
|
|
|
|
|
|
2022-12-31 18:47:13 -06:00
|
|
|
public PlayerModelData(PlayerData parent) {
|
|
|
|
|
this.parent = parent;
|
|
|
|
|
this.player = parent.player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PlayerModelData(EntityPlayer player) {
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateClient() {
|
|
|
|
|
Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_MODEL_DATA, ((PlayerData) parent).player.getCommandSenderName(), this.writeToNBT(new NBTTagCompound()));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-08 22:57:52 -06:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-31 18:47:13 -06:00
|
|
|
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", enabled);
|
|
|
|
|
|
2023-01-06 14:28:15 -06:00
|
|
|
compound.setFloat("PuppetRotationX",rotationX);
|
|
|
|
|
compound.setFloat("PuppetRotationY",rotationY);
|
|
|
|
|
compound.setFloat("PuppetRotationZ",rotationZ);
|
2023-01-05 17:58:32 -06:00
|
|
|
compound.setBoolean("PuppetRotationEnabledX",rotationEnabledX);
|
|
|
|
|
compound.setBoolean("PuppetRotationEnabledY",rotationEnabledY);
|
|
|
|
|
compound.setBoolean("PuppetRotationEnabledZ",rotationEnabledZ);
|
|
|
|
|
|
2023-01-08 22:57:52 -06:00
|
|
|
compound.setBoolean("PuppetFullAngles", fullAngles);
|
2023-01-07 13:38:44 -06:00
|
|
|
compound.setBoolean("PuppetInterpolate", interpolate);
|
2022-12-31 18:47:13 -06:00
|
|
|
compound.setBoolean("PuppetAnimate", animate);
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
|
enabled = compound.getBoolean("PuppetEnabled");
|
|
|
|
|
|
2023-01-06 14:28:15 -06:00
|
|
|
rotationX = compound.getFloat("PuppetRotationX");
|
|
|
|
|
rotationY = compound.getFloat("PuppetRotationY");
|
|
|
|
|
rotationZ = compound.getFloat("PuppetRotationZ");
|
2023-01-05 17:58:32 -06:00
|
|
|
rotationEnabledX = compound.getBoolean("PuppetRotationEnabledX");
|
|
|
|
|
rotationEnabledY = compound.getBoolean("PuppetRotationEnabledY");
|
|
|
|
|
rotationEnabledZ = compound.getBoolean("PuppetRotationEnabledZ");
|
|
|
|
|
|
2023-01-08 22:57:52 -06:00
|
|
|
fullAngles = compound.getBoolean("PuppetFullAngles");
|
2023-01-07 13:38:44 -06:00
|
|
|
if (!compound.hasKey("PuppetInterpolate")) {
|
|
|
|
|
interpolate = true;
|
|
|
|
|
} else {
|
|
|
|
|
interpolate = compound.getBoolean("PuppetInterpolate");
|
|
|
|
|
}
|
2022-12-31 18:47:13 -06:00
|
|
|
animate = compound.getBoolean("PuppetAnimate");
|
|
|
|
|
animRate = compound.getFloat("PuppetAnimSpeed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAnimated(boolean animated) {
|
2023-01-08 23:04:57 -06:00
|
|
|
this.animate = animated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setInterpolated(boolean interpolate) {
|
|
|
|
|
this.interpolate = interpolate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFullAngles(boolean fullAngles) {
|
|
|
|
|
this.fullAngles = fullAngles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAnimRate(float animRate) {
|
|
|
|
|
this.animRate = animRate;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-08 23:28:08 -06:00
|
|
|
public void allEnabled(boolean enabled) {
|
|
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
|
this.getPart(i).setEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-08 23:04:57 -06:00
|
|
|
public void allAnimated(boolean animated) {
|
2023-01-08 22:57:52 -06:00
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
|
this.getPart(i).setAnimated(animated);
|
|
|
|
|
}
|
2022-12-31 18:47:13 -06:00
|
|
|
}
|
|
|
|
|
|
2023-01-08 23:04:57 -06:00
|
|
|
public void allInterpolated(boolean interpolate) {
|
2023-01-08 22:57:52 -06:00
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
|
this.getPart(i).setAnimated(interpolate);
|
|
|
|
|
}
|
2022-12-31 18:47:13 -06:00
|
|
|
}
|
|
|
|
|
|
2023-01-08 23:04:57 -06:00
|
|
|
public void allFullAngles(boolean fullAngles) {
|
2023-01-08 22:57:52 -06:00
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
|
this.getPart(i).setFullAngles(fullAngles);
|
|
|
|
|
}
|
2022-12-31 18:47:13 -06:00
|
|
|
}
|
|
|
|
|
|
2023-01-08 23:04:57 -06:00
|
|
|
public void allAnimRate(float animRate) {
|
2023-01-07 13:38:44 -06:00
|
|
|
if (animRate < 0)
|
|
|
|
|
animRate = 0;
|
2023-01-08 22:57:52 -06:00
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
|
this.getPart(i).setAnimRate(animRate);
|
|
|
|
|
}
|
2022-12-31 18:47:13 -06:00
|
|
|
}
|
|
|
|
|
}
|