Added puppet offsets and adjusted puppet leg pivots based on body angles.

This commit is contained in:
Luis C.M committed 2022-12-22 15:24:39 -06:00
1 parent 4f553a9ee4
commit bb7b33bf95
4 files changed
+106 -21

No files matched your search

@@ -61,8 +61,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
addLabel(new GuiNpcLabel(20, "model.head", guiLeft + 55, y + 5, 0xFFFFFF));
if(type == 0){
drawSlider(y, job.head);
y += 90;
y += drawSlider(y, job.head);
}
else{
addButton(new GuiNpcButton(0, guiLeft + 110, y , 60, 20, "selectServer.edit"));
@@ -71,8 +70,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
addLabel(new GuiNpcLabel(21, "model.body", guiLeft + 55, y + 5, 0xFFFFFF));
if(type == 1){
drawSlider(y, job.body);
y += 90;
y += drawSlider(y, job.body);
}
else{
addButton(new GuiNpcButton(1, guiLeft + 110, y , 60, 20, "selectServer.edit"));
@@ -81,8 +79,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
addLabel(new GuiNpcLabel(22, "model.larm", guiLeft + 55, y + 5, 0xFFFFFF));
if(type == 2){
drawSlider(y, job.larm);
y += 90;
y += drawSlider(y, job.larm);
}
else{
addButton(new GuiNpcButton(2, guiLeft + 110, y , 60, 20, "selectServer.edit"));
@@ -91,8 +88,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
addLabel(new GuiNpcLabel(23, "model.rarm", guiLeft + 55, y + 5, 0xFFFFFF));
if(type == 3){
drawSlider(y, job.rarm);
y += 90;
y += drawSlider(y, job.rarm);
}
else{
addButton(new GuiNpcButton(3, guiLeft + 110, y , 60, 20, "selectServer.edit"));
@@ -101,8 +97,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
addLabel(new GuiNpcLabel(24, "model.lleg", guiLeft + 55, y + 5, 0xFFFFFF));
if(type == 4){
drawSlider(y, job.lleg);
y += 90;
y += drawSlider(y, job.lleg);;
}
else{
addButton(new GuiNpcButton(4, guiLeft + 110, y , 60, 20, "selectServer.edit"));
@@ -111,8 +106,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
addLabel(new GuiNpcLabel(25, "model.rleg", guiLeft + 55, y + 5, 0xFFFFFF));
if(type == 5){
drawSlider(y, job.rleg);
y += 90;
y += drawSlider(y, job.rleg);;
}
else{
addButton(new GuiNpcButton(5, guiLeft + 110, y , 60, 20, "selectServer.edit"));
@@ -121,7 +115,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
}
private void drawSlider(int y, PartConfig config){
private float drawSlider(int y, PartConfig config){
part = config;
addButton(new GuiNpcButton(29, guiLeft + 100, y , 80, 20, new String[]{"gui.enabled","gui.disabled"}, config.disabled?1:0));
y += 22;
@@ -139,6 +133,23 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
rotateZ = new GuiNpcSlider(this, 12, guiLeft + 50, y, config.rotationZ + 0.5f);
addSlider(rotateZ);
addButton(new GuiNpcButton(172, guiLeft + 8, y, 40, 20, "Reset"));
addTextField(new GuiNpcTextField(15, this, guiLeft + 60, y += 22, 40, 20, "" + config.pivotX));
addLabel(new GuiNpcLabel(15, "puppet.pivotX", guiLeft, y + 5, 0xFFFFFF));
getTextField(15).floatsOnly = true;
getTextField(15).setMinMaxDefaultFloat(-Float.MAX_VALUE,Float.MAX_VALUE,0);
addTextField(new GuiNpcTextField(16, this, guiLeft + 60, y += 22, 40, 20, "" + config.pivotY));
addLabel(new GuiNpcLabel(16, "puppet.pivotY", guiLeft, y + 5, 0xFFFFFF));
getTextField(16).floatsOnly = true;
getTextField(16).setMinMaxDefaultFloat(-Float.MAX_VALUE,Float.MAX_VALUE,0);
addTextField(new GuiNpcTextField(17, this, guiLeft + 60, y += 22, 40, 20, "" + config.pivotZ));
addLabel(new GuiNpcLabel(17, "puppet.pivotZ", guiLeft, y + 5, 0xFFFFFF));
getTextField(17).floatsOnly = true;
getTextField(17).setMinMaxDefaultFloat(-Float.MAX_VALUE,Float.MAX_VALUE,0);
return 160;
}
@@ -197,6 +208,16 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener,
if(textfield.id == 34) {
job.animRate = textfield.getFloat();
}
if(textfield.id == 15) {
part.pivotX = textfield.getFloat();
}
if(textfield.id == 16) {
part.pivotY = textfield.getFloat();
}
if(textfield.id == 17) {
part.pivotZ = textfield.getFloat();
}
}
@Override
@@ -570,10 +570,41 @@ public class ModelMPM extends ModelNPCMale{
this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
this.bipedRightLeg.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 2.0F;
this.bipedRightLeg.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 2.0F;
this.bipedLeftLeg.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 2.0F;
this.bipedLeftLeg.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 2.0F;
this.bipedRightLeg.rotationPointX =
-MathHelper.cos(this.bipedBody.rotateAngleY) * 2.0F +
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.sin(this.bipedBody.rotateAngleY) * MathHelper.cos(this.bipedBody.rotateAngleZ) * 12.0F +
-MathHelper.cos(this.bipedBody.rotateAngleX) * MathHelper.sin(this.bipedBody.rotateAngleZ) * 12.0F;
this.bipedRightLeg.rotationPointY =
MathHelper.cos(this.bipedBody.rotateAngleX) * MathHelper.cos(this.bipedBody.rotateAngleZ) * 12.0F +
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.sin(this.bipedBody.rotateAngleY) * MathHelper.sin(this.bipedBody.rotateAngleZ) * 12.0F;
this.bipedRightLeg.rotationPointZ =
MathHelper.sin(this.bipedBody.rotateAngleY) * 2.0F +
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.cos(this.bipedBody.rotateAngleY) * 12.0F;
this.bipedLeftLeg.rotationPointX =
MathHelper.cos(this.bipedBody.rotateAngleY) * 2.0F +
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.sin(this.bipedBody.rotateAngleY) * MathHelper.cos(this.bipedBody.rotateAngleZ) * 12.0F +
-MathHelper.cos(this.bipedBody.rotateAngleX) * MathHelper.sin(this.bipedBody.rotateAngleZ) * 12.0F;
this.bipedLeftLeg.rotationPointY =
MathHelper.cos(this.bipedBody.rotateAngleX) * MathHelper.cos(this.bipedBody.rotateAngleZ) * 12.0F +
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.sin(this.bipedBody.rotateAngleY) * MathHelper.sin(this.bipedBody.rotateAngleZ) * 12.0F;
this.bipedLeftLeg.rotationPointZ =
-MathHelper.sin(this.bipedBody.rotateAngleY) * 2.0F +
MathHelper.sin(this.bipedBody.rotateAngleX) * MathHelper.cos(this.bipedBody.rotateAngleY) * 12.0F;
this.addInterpolatedOffset(job,bipedHead,job.head);
this.addInterpolatedOffset(job,bipedHeadwear,job.head);
this.addInterpolatedOffset(job,bipedBody,job.body);
this.addInterpolatedOffset(job,bipedBodywear,job.body);
this.addInterpolatedOffset(job,bipedLeftArm,job.larm);
this.addInterpolatedOffset(job,bipedLeftArmwear,job.larm);
this.addInterpolatedOffset(job,bipedRightArm,job.rarm);
this.addInterpolatedOffset(job,bipedRightArmWear,job.rarm);
this.addInterpolatedOffset(job,bipedLeftLeg,job.lleg);
this.addInterpolatedOffset(job,bipedLeftLegWear,job.lleg);
this.addInterpolatedOffset(job,bipedRightLeg,job.rleg);
this.addInterpolatedOffset(job,bipedRightLegWear,job.rleg);
job.bipedRotsHead = new float[]{bipedHead.rotateAngleX,bipedHead.rotateAngleY,bipedHead.rotateAngleZ};
job.bipedRotsBody = new float[]{bipedBody.rotateAngleX,bipedBody.rotateAngleY,bipedBody.rotateAngleZ};
@@ -598,6 +629,21 @@ public class ModelMPM extends ModelNPCMale{
}
}
public void addInterpolatedOffset(JobPuppet job, ModelRenderer modelPart, JobPuppet.PartConfig puppetPart) {
if (!job.animate) {
modelPart.rotationPointX += puppetPart.pivotX;
modelPart.rotationPointY += puppetPart.pivotY;
modelPart.rotationPointZ += puppetPart.pivotZ;
} else {
modelPart.rotationPointX += puppetPart.prevPivotX;
modelPart.rotationPointY += puppetPart.prevPivotY;
modelPart.rotationPointZ += puppetPart.prevPivotZ;
puppetPart.prevPivotX = (puppetPart.pivotX - puppetPart.prevPivotX) * job.animRate /10f + puppetPart.prevPivotX;
puppetPart.prevPivotY = (puppetPart.pivotY - puppetPart.prevPivotY) * job.animRate /10f + puppetPart.prevPivotY;
puppetPart.prevPivotZ = (puppetPart.pivotZ - puppetPart.prevPivotZ) * job.animRate /10f + puppetPart.prevPivotZ;
}
}
public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
{
+19 -4
View File
@@ -19,6 +19,7 @@ public class JobPuppet extends JobInterface{
public boolean animate = false;
public float animRate = 1.0F;
//Client-sided use
public float[] bipedRotsHead = {0,0,0};
public float[] bipedRotsBody = {0,0,0};
public float[] bipedRotsLeftArm = {0,0,0};
@@ -85,10 +86,18 @@ public class JobPuppet extends JobInterface{
return false;
}
public static class PartConfig{
public static class PartConfig {
public float rotationX = 0f;
public float rotationY = 0f;
public float rotationZ = 0f;
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;
public boolean disabled = false;
@@ -96,8 +105,11 @@ public class JobPuppet extends JobInterface{
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("RotationX", rotationX);
compound.setFloat("RotationY", rotationY);
compound.setFloat("RotationZ", rotationZ);
compound.setFloat("RotationZ", rotationZ);
compound.setFloat("PivotX", pivotX);
compound.setFloat("PivotY", pivotY);
compound.setFloat("PivotZ", pivotZ);
compound.setBoolean("Disabled", disabled);
return compound;
}
@@ -106,7 +118,10 @@ public class JobPuppet extends JobInterface{
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);
pivotX = compound.getFloat("PivotX");
pivotY = compound.getFloat("PivotY");
pivotZ = compound.getFloat("PivotZ");
disabled = compound.getBoolean("Disabled");
}
}