Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/roles/ScriptJobPuppet.java
T

371 lines
8.3 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobPuppet;
import noppes.npcs.scripted.constants.JobType;
2022-11-15 15:25:53 -05:00
import noppes.npcs.api.jobs.IJobPuppet;
2018-09-13 12:03:28 -04:00
2022-06-12 01:26:23 -05:00
public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet {
2018-09-13 12:03:28 -04:00
private JobPuppet job;
public ScriptJobPuppet(EntityNPCInterface npc){
super(npc);
this.job = (JobPuppet) npc.jobInterface;
}
public void setAnimated(boolean animated) {
this.job.animate = animated;
}
2023-01-07 13:13:44 -06:00
public boolean isAnimated() {
return this.job.animate;
}
public void setInterpolated(boolean interpolate) {
this.job.interpolate = interpolate;
}
public boolean isInterpolated() {
return this.job.interpolate;
}
public void setFullAngles(boolean limit) {
job.fullAngles = limit;
}
2023-01-07 13:13:44 -06:00
public boolean fullAngles() {
return job.fullAngles;
}
public void setAnimRate(float animRate) {
2023-01-07 13:13:44 -06:00
if (animRate < 0)
animRate = 0;
this.job.animRate = animRate;
}
public float getAnimRate() {
return this.job.animRate;
}
public void doWhileStanding(boolean whileStanding) {
this.job.whileStanding = whileStanding;
}
public boolean doWhileStanding() {
return this.job.whileStanding;
}
public void doWhileAttacking(boolean whileAttacking) {
this.job.whileAttacking = whileAttacking;
}
public boolean doWhileAttacking() {
return this.job.whileAttacking;
}
public void doWhileMoving(boolean whileMoving) {
this.job.whileMoving = whileMoving;
}
public boolean doWhileMoving() {
return this.job.whileMoving;
}
2023-01-06 14:41:16 -06:00
public void setRotation(int part, float rotationX, float rotationY, float rotationZ) {
this.setRotationX(part,rotationX);
2022-12-22 10:15:08 -06:00
this.setRotationY(part,rotationY);
this.setRotationZ(part,rotationZ);
}
2018-09-13 12:03:28 -04:00
/**
* @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
*/
2023-01-06 14:41:16 -06:00
public void setRotationX(int part, float rotation){
2018-09-13 12:03:28 -04:00
float f = rotation / 360f - 0.5f;
if(getRotationX(part) != f)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.rotationX = f;
if(part == 1)
job.body.rotationX = f;
if(part == 2)
job.larm.rotationX = f;
if(part == 3)
job.rarm.rotationX = f;
if(part == 4)
job.lleg.rotationX = f;
if(part == 5)
job.rleg.rotationX = f;
}
/**
* @since 1.7.10c
2022-06-12 01:26:23 -05:00
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
2018-09-13 12:03:28 -04:00
* @param rotation Rotation the of the body part
*/
2023-01-06 14:41:16 -06:00
public void setRotationY(int part, float rotation){
2018-09-13 12:03:28 -04:00
float f = rotation / 360f - 0.5f;
if(getRotationY(part) != f)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.rotationY = f;
if(part == 1)
job.body.rotationY = f;
if(part == 2)
job.larm.rotationY = f;
if(part == 3)
job.rarm.rotationY = f;
if(part == 4)
job.lleg.rotationY = f;
if(part == 5)
job.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
*/
2023-01-06 14:41:16 -06:00
public void setRotationZ(int part, float rotation){
2018-09-13 12:03:28 -04:00
float f = rotation / 360f - 0.5f;
if(getRotationZ(part) != f)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.rotationZ = f;
if(part == 1)
job.body.rotationZ = f;
if(part == 2)
job.larm.rotationZ = f;
if(part == 3)
job.rarm.rotationZ = f;
if(part == 4)
job.lleg.rotationZ = f;
if(part == 5)
job.rleg.rotationZ = f;
}
2023-01-06 14:41:16 -06:00
/**
* @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)
2023-01-06 14:41:16 -06:00
return job.head.rotationX;
if(part == 1)
2023-01-06 14:41:16 -06:00
return job.body.rotationX;
if(part == 2)
2023-01-06 14:41:16 -06:00
return job.larm.rotationX;
if(part == 3)
2023-01-06 14:41:16 -06:00
return job.rarm.rotationX;
if(part == 4)
2023-01-06 14:41:16 -06:00
return job.lleg.rotationX;
if(part == 5)
2023-01-06 14:41:16 -06:00
return job.rleg.rotationX;
return 0;
}
2023-01-06 14:41:16 -06:00
/**
* @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)
2023-01-06 14:41:16 -06:00
return job.head.rotationY;
if(part == 1)
2023-01-06 14:41:16 -06:00
return job.body.rotationY;
if(part == 2)
2023-01-06 14:41:16 -06:00
return job.larm.rotationY;
if(part == 3)
2023-01-06 14:41:16 -06:00
return job.rarm.rotationY;
if(part == 4)
2023-01-06 14:41:16 -06:00
return job.lleg.rotationY;
if(part == 5)
2023-01-06 14:41:16 -06:00
return job.rleg.rotationY;
return 0;
}
2023-01-06 14:41:16 -06:00
/**
* @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)
2023-01-06 14:41:16 -06:00
return job.head.rotationZ;
if(part == 1)
2023-01-06 14:41:16 -06:00
return job.body.rotationZ;
if(part == 2)
2023-01-06 14:41:16 -06:00
return job.larm.rotationZ;
if(part == 3)
2023-01-06 14:41:16 -06:00
return job.rarm.rotationZ;
if(part == 4)
2023-01-06 14:41:16 -06:00
return job.lleg.rotationZ;
if(part == 5)
2023-01-06 14:41:16 -06:00
return job.rleg.rotationZ;
return 0;
}
2023-01-06 14:41:16 -06:00
public void setOffset(int part, float offsetX, float offsetY, float offsetZ) {
this.setOffsetX(part,offsetX);
this.setOffsetY(part,offsetY);
this.setOffsetZ(part,offsetZ);
}
2023-01-06 14:41:16 -06:00
public void setOffsetX(int part, float offset) {
if(getOffsetX(part) != offset)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.pivotX = offset;
if(part == 1)
job.body.pivotX = offset;
if(part == 2)
job.larm.pivotX = offset;
if(part == 3)
job.rarm.pivotX = offset;
if(part == 4)
job.lleg.pivotX = offset;
if(part == 5)
job.rleg.pivotX = offset;
}
2023-01-06 14:41:16 -06:00
public void setOffsetY(int part, float offset) {
if(getOffsetY(part) != offset)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.pivotY = offset;
if(part == 1)
job.body.pivotY = offset;
if(part == 2)
job.larm.pivotY = offset;
if(part == 3)
job.rarm.pivotY = offset;
if(part == 4)
job.lleg.pivotY = offset;
if(part == 5)
job.rleg.pivotY = offset;
}
2023-01-06 14:41:16 -06:00
public void setOffsetZ(int part, float offset) {
if(getOffsetZ(part) != offset)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.pivotZ = offset;
if(part == 1)
job.body.pivotZ = offset;
if(part == 2)
job.larm.pivotZ = offset;
if(part == 3)
job.rarm.pivotZ = offset;
if(part == 4)
job.lleg.pivotZ = offset;
if(part == 5)
job.rleg.pivotZ = offset;
}
2023-01-06 14:41:16 -06:00
public float getOffsetX(int part) {
if(part == 0)
return job.head.pivotX;
if(part == 1)
return job.body.pivotX;
if(part == 2)
return job.larm.pivotX;
if(part == 3)
return job.rarm.pivotX;
if(part == 4)
return job.lleg.pivotX;
if(part == 5)
return job.rleg.pivotX;
return 0;
}
public float getOffsetY(int part) {
if(part == 0)
return job.head.pivotY;
if(part == 1)
return job.body.pivotY;
if(part == 2)
return job.larm.pivotY;
if(part == 3)
return job.rarm.pivotY;
if(part == 4)
return job.lleg.pivotY;
if(part == 5)
return job.rleg.pivotY;
return 0;
}
public float getOffsetZ(int part) {
if(part == 0)
return job.head.pivotZ;
if(part == 1)
return job.body.pivotZ;
if(part == 2)
return job.larm.pivotZ;
if(part == 3)
return job.rarm.pivotZ;
if(part == 4)
return job.lleg.pivotZ;
if(part == 5)
return job.rleg.pivotZ;
return 0;
}
2018-09-13 12:03:28 -04:00
/**
* @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 !job.head.disabled;
if(part == 1)
return !job.body.disabled;
if(part == 2)
return !job.larm.disabled;
if(part == 3)
return !job.rarm.disabled;
if(part == 4)
return !job.lleg.disabled;
if(part == 5)
return !job.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(isEnabled(part) != bo)
npc.script.clientNeedsUpdate = true;
if(part == 0)
job.head.disabled = !bo;
if(part == 1)
job.body.disabled = !bo;
if(part == 2)
job.larm.disabled = !bo;
if(part == 3)
job.rarm.disabled = !bo;
if(part == 4)
job.lleg.disabled = !bo;
if(part == 5)
job.rleg.disabled = !bo;
}
@Override
public int getType(){
return JobType.PUPPET;
}
}