2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.roles;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
|
|
|
import noppes.npcs.util.ValueUtil;
|
|
|
|
|
|
|
|
|
|
public class JobPuppet extends JobInterface{
|
|
|
|
|
public PartConfig head = new PartConfig();
|
|
|
|
|
public PartConfig larm = new PartConfig();
|
|
|
|
|
public PartConfig rarm = new PartConfig();
|
|
|
|
|
public PartConfig body = new PartConfig();
|
|
|
|
|
public PartConfig lleg = new PartConfig();
|
|
|
|
|
public PartConfig rleg = new PartConfig();
|
|
|
|
|
|
|
|
|
|
public boolean whileStanding = true;
|
|
|
|
|
public boolean whileAttacking = false;
|
|
|
|
|
public boolean whileMoving = false;
|
|
|
|
|
|
2022-12-22 01:36:50 -06:00
|
|
|
public boolean animate = false;
|
|
|
|
|
public float animRate = 1.0F;
|
|
|
|
|
|
2022-12-22 15:24:39 -06:00
|
|
|
//Client-sided use
|
2022-12-22 01:36:50 -06:00
|
|
|
public float[] bipedRotsHead = {0,0,0};
|
|
|
|
|
public float[] bipedRotsBody = {0,0,0};
|
|
|
|
|
public float[] bipedRotsLeftArm = {0,0,0};
|
|
|
|
|
public float[] bipedRotsRightArm = {0,0,0};
|
|
|
|
|
public float[] bipedRotsLeftLeg = {0,0,0};
|
|
|
|
|
public float[] bipedRotsRightLeg = {0,0,0};
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public JobPuppet(EntityNPCInterface npc) {
|
|
|
|
|
super(npc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
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("PuppetStanding", whileStanding);
|
|
|
|
|
compound.setBoolean("PuppetAttacking", whileAttacking);
|
|
|
|
|
compound.setBoolean("PuppetMoving", whileMoving);
|
2022-12-22 01:36:50 -06:00
|
|
|
|
|
|
|
|
compound.setBoolean("PuppetAnimate", animate);
|
|
|
|
|
compound.setFloat("PuppetAnimSpeed", animRate);
|
2018-09-13 12:03:28 -04:00
|
|
|
return compound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
|
whileStanding = compound.getBoolean("PuppetStanding");
|
|
|
|
|
whileAttacking = compound.getBoolean("PuppetAttacking");
|
|
|
|
|
whileMoving = compound.getBoolean("PuppetMoving");
|
2022-12-22 01:36:50 -06:00
|
|
|
|
|
|
|
|
animate = compound.getBoolean("PuppetAnimate");
|
|
|
|
|
animRate = compound.getFloat("PuppetAnimSpeed");
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean aiShouldExecute() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void reset() {
|
|
|
|
|
}
|
|
|
|
|
public void delete() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isActive() {
|
|
|
|
|
if(!npc.isEntityAlive())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(whileAttacking && npc.isAttacking() || whileMoving && npc.isWalking() || whileStanding && !npc.isWalking())
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-22 15:24:39 -06:00
|
|
|
public static class PartConfig {
|
2018-09-13 12:03:28 -04:00
|
|
|
public float rotationX = 0f;
|
|
|
|
|
public float rotationY = 0f;
|
|
|
|
|
public float rotationZ = 0f;
|
2022-12-22 15:24:39 -06:00
|
|
|
public float pivotX = 0f;
|
|
|
|
|
public float pivotY = 0f;
|
|
|
|
|
public float pivotZ = 0f;
|
|
|
|
|
|
|
|
|
|
//Client-sided use
|
|
|
|
|
public float prevPivotX = 0f;
|
|
|
|
|
public float prevPivotY = 0f;
|
|
|
|
|
public float prevPivotZ = 0f;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public boolean disabled = false;
|
|
|
|
|
|
|
|
|
|
public NBTTagCompound writeNBT(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
compound.setFloat("RotationX", rotationX);
|
|
|
|
|
compound.setFloat("RotationY", rotationY);
|
2022-12-22 15:24:39 -06:00
|
|
|
compound.setFloat("RotationZ", rotationZ);
|
|
|
|
|
compound.setFloat("PivotX", pivotX);
|
|
|
|
|
compound.setFloat("PivotY", pivotY);
|
|
|
|
|
compound.setFloat("PivotZ", pivotZ);
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
compound.setBoolean("Disabled", disabled);
|
|
|
|
|
return compound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void readNBT(NBTTagCompound compound){
|
|
|
|
|
rotationX = ValueUtil.correctFloat(compound.getFloat("RotationX"), -0.5f, 0.5f);
|
|
|
|
|
rotationY = ValueUtil.correctFloat(compound.getFloat("RotationY"), -0.5f, 0.5f);
|
|
|
|
|
rotationZ = ValueUtil.correctFloat(compound.getFloat("RotationZ"), -0.5f, 0.5f);
|
2022-12-22 15:24:39 -06:00
|
|
|
pivotX = compound.getFloat("PivotX");
|
|
|
|
|
pivotY = compound.getFloat("PivotY");
|
|
|
|
|
pivotZ = compound.getFloat("PivotZ");
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
disabled = compound.getBoolean("Disabled");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|