diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java index 4dcb6d7f8..7e180404e 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcPuppet.java @@ -42,14 +42,16 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener, addLabel(new GuiNpcLabel(31, "puppet.walking", guiLeft + 30, y + 5, 0xFFFFFF)); addButton(new GuiNpcButton(32, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, job.whileAttacking?0:1)); addLabel(new GuiNpcLabel(32, "puppet.attacking", guiLeft + 30, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(33, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, job.limitAngles?0:1)); + addLabel(new GuiNpcLabel(33, "puppet.limitAngles", guiLeft + 30, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(33, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, job.animate ? 0 : 1)); - addLabel(new GuiNpcLabel(33, "puppet.animate", guiLeft + 30, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(35, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, job.animate ? 0 : 1)); + addLabel(new GuiNpcLabel(35, "puppet.animate", guiLeft + 30, y + 5, 0xFFFFFF)); if (job.animate) { - addTextField(new GuiNpcTextField(34, this, guiLeft + 120, y += 22, 40, 20, "" + job.animRate)); - addLabel(new GuiNpcLabel(34, "puppet.animSpeed", guiLeft + 30, y + 5, 0xFFFFFF)); - getTextField(34).floatsOnly = true; + addTextField(new GuiNpcTextField(36, this, guiLeft + 120, y += 22, 40, 20, "" + job.animRate)); + addLabel(new GuiNpcLabel(36, "puppet.animSpeed", guiLeft + 30, y + 5, 0xFFFFFF)); + getTextField(36).floatsOnly = true; } y += 24; @@ -177,6 +179,9 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener, job.whileAttacking = button.getValue() == 0; } if(btn.id == 33){ + job.limitAngles = button.getValue() == 0; + } + if(btn.id == 35){ job.animate = button.getValue() == 0; initGui(); } @@ -205,7 +210,7 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener, @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 34) { + if(textfield.id == 36) { job.animRate = textfield.getFloat(); } diff --git a/src/main/java/noppes/npcs/client/model/ModelMPM.java b/src/main/java/noppes/npcs/client/model/ModelMPM.java index 13518c624..a0701c7f4 100644 --- a/src/main/java/noppes/npcs/client/model/ModelMPM.java +++ b/src/main/java/noppes/npcs/client/model/ModelMPM.java @@ -628,7 +628,7 @@ public class ModelMPM extends ModelNPCMale{ } public void setInterpolatedAngles(JobPuppet job, ModelRenderer modelPart, JobPuppet.PartConfig puppetPart) { - float pi = (float) Math.PI; + float pi = (float) Math.PI * (job.limitAngles ? 1 : 2); if (!job.animate) { modelPart.rotateAngleX = puppetPart.rotationX * pi; modelPart.rotateAngleY = puppetPart.rotationY * pi; diff --git a/src/main/java/noppes/npcs/roles/JobPuppet.java b/src/main/java/noppes/npcs/roles/JobPuppet.java index 8eebc1307..c11b356f8 100644 --- a/src/main/java/noppes/npcs/roles/JobPuppet.java +++ b/src/main/java/noppes/npcs/roles/JobPuppet.java @@ -15,6 +15,7 @@ public class JobPuppet extends JobInterface{ public boolean whileStanding = true; public boolean whileAttacking = false; public boolean whileMoving = false; + public boolean limitAngles = true; public boolean animate = false; public float animRate = 1.0F; @@ -43,6 +44,7 @@ public class JobPuppet extends JobInterface{ compound.setBoolean("PuppetStanding", whileStanding); compound.setBoolean("PuppetAttacking", whileAttacking); compound.setBoolean("PuppetMoving", whileMoving); + compound.setBoolean("PuppetLimitAngles", limitAngles); compound.setBoolean("PuppetAnimate", animate); compound.setFloat("PuppetAnimSpeed", animRate); @@ -61,6 +63,7 @@ public class JobPuppet extends JobInterface{ whileStanding = compound.getBoolean("PuppetStanding"); whileAttacking = compound.getBoolean("PuppetAttacking"); whileMoving = compound.getBoolean("PuppetMoving"); + limitAngles = compound.getBoolean("PuppetLimitAngles"); animate = compound.getBoolean("PuppetAnimate"); animRate = compound.getFloat("PuppetAnimSpeed"); diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobPuppet.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobPuppet.java index 3b5922501..3c420ace5 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobPuppet.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobPuppet.java @@ -16,6 +16,14 @@ public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet { this.job.animate = animated; } + public boolean anglesLimited() { + return job.limitAngles; + } + + public void setAnglesLimited(boolean limit) { + job.limitAngles = limit; + } + public boolean isAnimated() { return this.job.animate; } @@ -192,7 +200,115 @@ public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet { if(part == 5) job.rleg.rotationZ = f; } - + + public int getOffsetX(int part) { + if(part == 0) + return floatToInt(job.head.pivotX); + if(part == 1) + return floatToInt(job.body.pivotX); + if(part == 2) + return floatToInt(job.larm.pivotX); + if(part == 3) + return floatToInt(job.rarm.pivotX); + if(part == 4) + return floatToInt(job.lleg.pivotX); + if(part == 5) + return floatToInt(job.rleg.pivotX); + return 0; + } + + public int getOffsetY(int part) { + if(part == 0) + return floatToInt(job.head.pivotY); + if(part == 1) + return floatToInt(job.body.pivotY); + if(part == 2) + return floatToInt(job.larm.pivotY); + if(part == 3) + return floatToInt(job.rarm.pivotY); + if(part == 4) + return floatToInt(job.lleg.pivotY); + if(part == 5) + return floatToInt(job.rleg.pivotY); + return 0; + } + + public int getOffsetZ(int part) { + if(part == 0) + return floatToInt(job.head.pivotZ); + if(part == 1) + return floatToInt(job.body.pivotZ); + if(part == 2) + return floatToInt(job.larm.pivotZ); + if(part == 3) + return floatToInt(job.rarm.pivotZ); + if(part == 4) + return floatToInt(job.lleg.pivotZ); + if(part == 5) + return floatToInt(job.rleg.pivotZ); + return 0; + } + + public void setOffset(int part, int offsetX, int offsetY, int offsetZ) { + this.setOffsetX(part,offsetX); + this.setOffsetY(part,offsetY); + this.setOffsetZ(part,offsetZ); + } + + public void setOffsetX(int part, int offset) { + if(getRotationZ(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; + } + + public void setOffsetY(int part, int offset) { + if(getRotationZ(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; + } + + public void setOffsetZ(int part, int offset) { + if(getRotationZ(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; + } + /** * @since 1.7.10c * @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg) diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 83c366ed6..c583bf2d8 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1016,6 +1016,7 @@ puppet.animSpeed=Animation Speed puppet.pivotX=Pivot X puppet.pivotY=Pivot Y puppet.pivotZ=Pivot Z +puppet.limitAngles=Limit Angles guard.creepers=Attack Creepers guard.animals=Attack Animals