IPlayerModelData:

-Restructured to implement the new IModelPart interface
This commit is contained in:
Luis C.M committed 2023-01-08 22:57:52 -06:00
1 parent f98a1af2b2
commit c146a973f0
5 files changed
+92 -461

No files matched your search

@@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.Server;
import noppes.npcs.api.handler.IPlayerModelData;
import noppes.npcs.api.handler.data.IModelPart;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.roles.JobPuppet;
@@ -19,16 +20,12 @@ public class PlayerModelData implements IPlayerModelData {
public JobPuppet.PartConfig rleg = new JobPuppet.PartConfig();
public boolean enabled = false;
public boolean whileStanding = true;
public boolean whileAttacking = false;
public boolean whileMoving = false;
public boolean fullAngles = false;
public float rotationX, rotationY, rotationZ;
public boolean rotationEnabledX, rotationEnabledY, rotationEnabledZ;
public boolean animate = false;
public float animRate = 1.0F;
public boolean fullAngles;
public boolean interpolate;
//Client-sided use
@@ -48,6 +45,24 @@ public class PlayerModelData implements IPlayerModelData {
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());
compound.setTag("PuppetLArm", larm.writeNBT());
@@ -57,10 +72,6 @@ public class PlayerModelData implements IPlayerModelData {
compound.setTag("PuppetRLeg", rleg.writeNBT());
compound.setBoolean("PuppetEnabled", enabled);
compound.setBoolean("PuppetStanding", whileStanding);
compound.setBoolean("PuppetAttacking", whileAttacking);
compound.setBoolean("PuppetMoving", whileMoving);
compound.setBoolean("PuppetFullAngles", fullAngles);
compound.setFloat("PuppetRotationX",rotationX);
compound.setFloat("PuppetRotationY",rotationY);
@@ -69,6 +80,7 @@ public class PlayerModelData implements IPlayerModelData {
compound.setBoolean("PuppetRotationEnabledY",rotationEnabledY);
compound.setBoolean("PuppetRotationEnabledZ",rotationEnabledZ);
compound.setBoolean("PuppetFullAngles", fullAngles);
compound.setBoolean("PuppetInterpolate", interpolate);
compound.setBoolean("PuppetAnimate", animate);
compound.setFloat("PuppetAnimSpeed", animRate);
@@ -84,10 +96,6 @@ public class PlayerModelData implements IPlayerModelData {
rleg.readNBT(compound.getCompoundTag("PuppetRLeg"));
enabled = compound.getBoolean("PuppetEnabled");
whileStanding = compound.getBoolean("PuppetStanding");
whileAttacking = compound.getBoolean("PuppetAttacking");
whileMoving = compound.getBoolean("PuppetMoving");
fullAngles = compound.getBoolean("PuppetFullAngles");
rotationX = compound.getFloat("PuppetRotationX");
rotationY = compound.getFloat("PuppetRotationY");
@@ -96,6 +104,7 @@ public class PlayerModelData implements IPlayerModelData {
rotationEnabledY = compound.getBoolean("PuppetRotationEnabledY");
rotationEnabledZ = compound.getBoolean("PuppetRotationEnabledZ");
fullAngles = compound.getBoolean("PuppetFullAngles");
if (!compound.hasKey("PuppetInterpolate")) {
interpolate = true;
} else {
@@ -105,405 +114,29 @@ public class PlayerModelData implements IPlayerModelData {
animRate = compound.getFloat("PuppetAnimSpeed");
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean enabled() {
return this.enabled;
}
public void setAnimated(boolean animated) {
this.animate = animated;
}
public boolean isAnimated() {
return this.animate;
for (int i = 0; i < 6; i++) {
this.getPart(i).setAnimated(animated);
}
}
public void setInterpolated(boolean interpolate) {
this.interpolate = interpolate;
for (int i = 0; i < 6; i++) {
this.getPart(i).setAnimated(interpolate);
}
}
public boolean isInterpolated() {
return this.interpolate;
}
public void setFullAngles(boolean limit) {
fullAngles = limit;
}
public boolean fullAngles() {
return fullAngles;
public void setFullAngles(boolean fullAngles) {
for (int i = 0; i < 6; i++) {
this.getPart(i).setFullAngles(fullAngles);
}
}
public void setAnimRate(float animRate) {
if (animRate < 0)
animRate = 0;
this.animRate = animRate;
}
public float getAnimRate() {
return this.animRate;
}
public void doWhileStanding(boolean whileStanding) {
this.whileStanding = whileStanding;
}
public boolean doWhileStanding() {
return this.whileStanding;
}
public void doWhileAttacking(boolean whileAttacking) {
this.whileAttacking = whileAttacking;
}
public boolean doWhileAttacking() {
return this.whileAttacking;
}
public void doWhileMoving(boolean whileMoving) {
this.whileMoving = whileMoving;
}
public boolean doWhileMoving() {
return this.whileMoving;
}
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 setRotation(int part, float rotationX, float rotationY, float rotationZ) {
this.setRotationX(part,rotationX);
this.setRotationY(part,rotationY);
this.setRotationZ(part,rotationZ);
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @param rotation Rotation the of the body part
*/
public void setRotationX(int part, float rotation){
float f = rotation / 360f - 0.5f;
if(part == 0)
head.rotationX = f;
if(part == 1)
body.rotationX = f;
if(part == 2)
larm.rotationX = f;
if(part == 3)
rarm.rotationX = f;
if(part == 4)
lleg.rotationX = f;
if(part == 5)
rleg.rotationX = f;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @param rotation Rotation the of the body part
*/
public void setRotationY(int part, float rotation){
float f = rotation / 360f - 0.5f;
if(part == 0)
head.rotationY = f;
if(part == 1)
body.rotationY = f;
if(part == 2)
larm.rotationY = f;
if(part == 3)
rarm.rotationY = f;
if(part == 4)
lleg.rotationY = f;
if(part == 5)
rleg.rotationY = f;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @param rotation Rotation the of the body part
*/
public void setRotationZ(int part, float rotation){
float f = rotation / 360f - 0.5f;
if(part == 0)
head.rotationZ = f;
if(part == 1)
body.rotationZ = f;
if(part == 2)
larm.rotationZ = f;
if(part == 3)
rarm.rotationZ = f;
if(part == 4)
lleg.rotationZ = f;
if(part == 5)
rleg.rotationZ = f;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @return Returns X rotation in degrees (0-360)
*/
public float getRotationX(int part){
if(part == 0)
return head.rotationX;
if(part == 1)
return body.rotationX;
if(part == 2)
return larm.rotationX;
if(part == 3)
return rarm.rotationX;
if(part == 4)
return lleg.rotationX;
if(part == 5)
return rleg.rotationX;
return 0;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @return Returns Y rotation in degrees (0-360)
*/
public float getRotationY(int part){
if(part == 0)
return head.rotationY;
if(part == 1)
return body.rotationY;
if(part == 2)
return larm.rotationY;
if(part == 3)
return rarm.rotationY;
if(part == 4)
return lleg.rotationY;
if(part == 5)
return rleg.rotationY;
return 0;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @return Returns Z rotation in degrees (0-360)
*/
public float getRotationZ(int part){
if(part == 0)
return head.rotationZ;
if(part == 1)
return body.rotationZ;
if(part == 2)
return larm.rotationZ;
if(part == 3)
return rarm.rotationZ;
if(part == 4)
return lleg.rotationZ;
if(part == 5)
return rleg.rotationZ;
return 0;
}
public void setOffset(int part, float offsetX, float offsetY, float offsetZ) {
this.setOffsetX(part,offsetX);
this.setOffsetY(part,offsetY);
this.setOffsetZ(part,offsetZ);
}
public void setOffsetX(int part, float offset) {
if(part == 0)
head.pivotX = offset;
if(part == 1)
body.pivotX = offset;
if(part == 2)
larm.pivotX = offset;
if(part == 3)
rarm.pivotX = offset;
if(part == 4)
lleg.pivotX = offset;
if(part == 5)
rleg.pivotX = offset;
}
public void setOffsetY(int part, float offset) {
if(part == 0)
head.pivotY = offset;
if(part == 1)
body.pivotY = offset;
if(part == 2)
larm.pivotY = offset;
if(part == 3)
rarm.pivotY = offset;
if(part == 4)
lleg.pivotY = offset;
if(part == 5)
rleg.pivotY = offset;
}
public void setOffsetZ(int part, float offset) {
if(part == 0)
head.pivotZ = offset;
if(part == 1)
body.pivotZ = offset;
if(part == 2)
larm.pivotZ = offset;
if(part == 3)
rarm.pivotZ = offset;
if(part == 4)
lleg.pivotZ = offset;
if(part == 5)
rleg.pivotZ = offset;
}
public float getOffsetX(int part) {
if(part == 0)
return head.pivotX;
if(part == 1)
return body.pivotX;
if(part == 2)
return larm.pivotX;
if(part == 3)
return rarm.pivotX;
if(part == 4)
return lleg.pivotX;
if(part == 5)
return rleg.pivotX;
return 0;
}
public float getOffsetY(int part) {
if(part == 0)
return head.pivotY;
if(part == 1)
return body.pivotY;
if(part == 2)
return larm.pivotY;
if(part == 3)
return rarm.pivotY;
if(part == 4)
return lleg.pivotY;
if(part == 5)
return rleg.pivotY;
return 0;
}
public float getOffsetZ(int part) {
if(part == 0)
return head.pivotZ;
if(part == 1)
return body.pivotZ;
if(part == 2)
return larm.pivotZ;
if(part == 3)
return rarm.pivotZ;
if(part == 4)
return lleg.pivotZ;
if(part == 5)
return rleg.pivotZ;
return 0;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @return Returns whether or not the body part is enabled
*/
public boolean isEnabled(int part){
if(part == 0)
return !head.disabled;
if(part == 1)
return !body.disabled;
if(part == 2)
return !larm.disabled;
if(part == 3)
return !rarm.disabled;
if(part == 4)
return !lleg.disabled;
if(part == 5)
return !rleg.disabled;
return false;
}
/**
* @since 1.7.10c
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @param bo Whether or not the body part is enabled
*/
public void setEnabled(int part, boolean bo){
if(part == 0)
head.disabled = !bo;
if(part == 1)
body.disabled = !bo;
if(part == 2)
larm.disabled = !bo;
if(part == 3)
rarm.disabled = !bo;
if(part == 4)
lleg.disabled = !bo;
if(part == 5)
rleg.disabled = !bo;
for (int i = 0; i < 6; i++) {
this.getPart(i).setAnimRate(animRate);
}
}
}