mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 02:37:27 +00:00
Added puppet animations and more functions for the IJobPuppet interface.
This commit is contained in:
1 parent
5d520837b1
commit
1d6499ea48
5 files changed
+156
-70
No files matched your search
@@ -3,20 +3,14 @@ package noppes.npcs.client.gui.roles;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.ModelData;
|
||||
import noppes.npcs.ModelPartConfig;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.GuiModelInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcSlider;
|
||||
import noppes.npcs.client.gui.util.ISliderListener;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.roles.JobPuppet;
|
||||
import noppes.npcs.roles.JobPuppet.PartConfig;
|
||||
|
||||
public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{
|
||||
public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener, ITextfieldListener {
|
||||
|
||||
private GuiScreen parent;
|
||||
private int type = 6;
|
||||
@@ -48,6 +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.animate ? 0 : 1));
|
||||
addLabel(new GuiNpcLabel(33, "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;
|
||||
}
|
||||
|
||||
y += 24;
|
||||
}
|
||||
else{
|
||||
@@ -161,6 +165,10 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{
|
||||
if(btn.id == 32){
|
||||
job.whileAttacking = button.getValue() == 0;
|
||||
}
|
||||
if(btn.id == 33){
|
||||
job.animate = button.getValue() == 0;
|
||||
initGui();
|
||||
}
|
||||
if(btn.id == 170 || btn.id == 171 || btn.id == 172){
|
||||
if(btn.id == 170){
|
||||
part.rotationX = 0.0f;
|
||||
@@ -184,6 +192,13 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if(textfield.id == 34) {
|
||||
job.animRate = textfield.getFloat();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(){
|
||||
this.mc.displayGuiScreen(parent);
|
||||
|
||||
@@ -426,59 +426,7 @@ public class ModelMPM extends ModelNPCMale{
|
||||
|
||||
setPlayerData(npc);
|
||||
currentlyPlayerTexture = true;
|
||||
setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
|
||||
if(npc.advanced.job == EnumJobType.Puppet){
|
||||
JobPuppet job = (JobPuppet) npc.jobInterface;
|
||||
if(job.isActive()){
|
||||
float pi = (float) Math.PI;
|
||||
|
||||
if(!job.head.disabled){
|
||||
bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = job.head.rotationX * pi;
|
||||
bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = job.head.rotationY * pi;
|
||||
bipedHeadwear.rotateAngleZ = bipedHead.rotateAngleZ = job.head.rotationZ * pi;
|
||||
}
|
||||
|
||||
if(!job.body.disabled){
|
||||
bipedBody.rotateAngleX = job.body.rotationX * pi;
|
||||
bipedBody.rotateAngleY = job.body.rotationY * pi;
|
||||
bipedBody.rotateAngleZ = job.body.rotationZ * pi;
|
||||
}
|
||||
|
||||
if(!job.larm.disabled){
|
||||
bipedLeftArm.rotateAngleX = job.larm.rotationX * pi;
|
||||
bipedLeftArm.rotateAngleY = job.larm.rotationY * pi;
|
||||
bipedLeftArm.rotateAngleZ = job.larm.rotationZ * pi;
|
||||
|
||||
if(!npc.display.disableLivingAnimation){
|
||||
this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F;
|
||||
}
|
||||
}
|
||||
|
||||
if(!job.rarm.disabled){
|
||||
bipedRightArm.rotateAngleX = job.rarm.rotationX * pi;
|
||||
bipedRightArm.rotateAngleY = job.rarm.rotationY * pi;
|
||||
bipedRightArm.rotateAngleZ = job.rarm.rotationZ * pi;
|
||||
|
||||
if(!npc.display.disableLivingAnimation){
|
||||
this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F;
|
||||
this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F;
|
||||
}
|
||||
}
|
||||
|
||||
if(!job.rleg.disabled){
|
||||
bipedRightLeg.rotateAngleX = job.rleg.rotationX * pi;
|
||||
bipedRightLeg.rotateAngleY = job.rleg.rotationY * pi;
|
||||
bipedRightLeg.rotateAngleZ = job.rleg.rotationZ * pi;
|
||||
}
|
||||
|
||||
if(!job.lleg.disabled){
|
||||
bipedLeftLeg.rotateAngleX = job.lleg.rotationX * pi;
|
||||
bipedLeftLeg.rotateAngleY = job.lleg.rotationY * pi;
|
||||
bipedLeftLeg.rotateAngleZ = job.lleg.rotationZ * pi;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
|
||||
renderHead(npc, par7);
|
||||
renderArms(npc, par7,false);
|
||||
renderBody(npc, par7);
|
||||
@@ -566,8 +514,82 @@ public class ModelMPM extends ModelNPCMale{
|
||||
this.bipedBody.rotateAngleX = 0.5F / npc.modelData.body.scaleY;
|
||||
}
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Puppet){
|
||||
JobPuppet job = (JobPuppet) npc.jobInterface;
|
||||
|
||||
if(job.isActive()){
|
||||
if(!job.head.disabled){
|
||||
bipedHead.rotateAngleX = job.bipedRotsHead[0];
|
||||
bipedHead.rotateAngleY = job.bipedRotsHead[1];
|
||||
bipedHead.rotateAngleZ = job.bipedRotsHead[2];
|
||||
this.setInterpolatedAngles(job,bipedHead,job.head);
|
||||
this.setInterpolatedAngles(job,bipedHeadwear,job.head);
|
||||
}
|
||||
|
||||
if(!job.body.disabled){
|
||||
bipedBody.rotateAngleX = job.bipedRotsBody[0];
|
||||
bipedBody.rotateAngleY = job.bipedRotsBody[1];
|
||||
bipedBody.rotateAngleZ = job.bipedRotsBody[2];
|
||||
this.setInterpolatedAngles(job,bipedBody,job.body);
|
||||
this.setInterpolatedAngles(job,bipedBodywear,job.body);
|
||||
}
|
||||
|
||||
if(!job.larm.disabled){
|
||||
bipedLeftArm.rotateAngleX = job.bipedRotsLeftArm[0];
|
||||
bipedLeftArm.rotateAngleY = job.bipedRotsLeftArm[1];
|
||||
bipedLeftArm.rotateAngleZ = job.bipedRotsLeftArm[2];
|
||||
this.setInterpolatedAngles(job,bipedLeftArm,job.larm);
|
||||
this.setInterpolatedAngles(job,bipedLeftArmwear,job.larm);
|
||||
}
|
||||
|
||||
if(!job.rarm.disabled){
|
||||
bipedRightArm.rotateAngleX = job.bipedRotsRightArm[0];
|
||||
bipedRightArm.rotateAngleY = job.bipedRotsRightArm[1];
|
||||
bipedRightArm.rotateAngleZ = job.bipedRotsRightArm[2];
|
||||
this.setInterpolatedAngles(job,bipedRightArm,job.rarm);
|
||||
this.setInterpolatedAngles(job,bipedRightArmWear,job.rarm);
|
||||
}
|
||||
|
||||
if(!job.lleg.disabled){
|
||||
bipedLeftLeg.rotateAngleX = job.bipedRotsLeftLeg[0];
|
||||
bipedLeftLeg.rotateAngleY = job.bipedRotsLeftLeg[1];
|
||||
bipedLeftLeg.rotateAngleZ = job.bipedRotsLeftLeg[2];
|
||||
this.setInterpolatedAngles(job,bipedLeftLeg,job.lleg);
|
||||
this.setInterpolatedAngles(job,bipedLeftLegWear,job.lleg);
|
||||
}
|
||||
|
||||
if(!job.rleg.disabled){
|
||||
bipedRightLeg.rotateAngleX = job.bipedRotsRightLeg[0];
|
||||
bipedRightLeg.rotateAngleY = job.bipedRotsRightLeg[1];
|
||||
bipedRightLeg.rotateAngleZ = job.bipedRotsRightLeg[2];
|
||||
this.setInterpolatedAngles(job,bipedRightLeg,job.rleg);
|
||||
this.setInterpolatedAngles(job,bipedRightLegWear,job.rleg);
|
||||
}
|
||||
|
||||
job.bipedRotsHead = new float[]{bipedHead.rotateAngleX,bipedHead.rotateAngleY,bipedHead.rotateAngleZ};
|
||||
job.bipedRotsBody = new float[]{bipedBody.rotateAngleX,bipedBody.rotateAngleY,bipedBody.rotateAngleZ};
|
||||
job.bipedRotsLeftArm = new float[]{bipedLeftArm.rotateAngleX,bipedLeftArm.rotateAngleY,bipedLeftArm.rotateAngleZ};
|
||||
job.bipedRotsRightArm = new float[]{bipedRightArm.rotateAngleX,bipedRightArm.rotateAngleY,bipedRightArm.rotateAngleZ};
|
||||
job.bipedRotsLeftLeg = new float[]{bipedLeftLeg.rotateAngleX,bipedLeftLeg.rotateAngleY,bipedLeftLeg.rotateAngleZ};
|
||||
job.bipedRotsRightLeg = new float[]{bipedRightLeg.rotateAngleX, bipedRightLeg.rotateAngleY, bipedRightLeg.rotateAngleZ};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setInterpolatedAngles(JobPuppet job, ModelRenderer modelPart, JobPuppet.PartConfig puppetPart) {
|
||||
float pi = (float) Math.PI;
|
||||
if (!job.animate) {
|
||||
modelPart.rotateAngleX = puppetPart.rotationX * pi;
|
||||
modelPart.rotateAngleY = puppetPart.rotationY * pi;
|
||||
modelPart.rotateAngleZ = puppetPart.rotationZ * pi;
|
||||
} else {
|
||||
modelPart.rotateAngleX = (puppetPart.rotationX * pi - modelPart.rotateAngleX) * job.animRate /10f + modelPart.rotateAngleX;
|
||||
modelPart.rotateAngleY = (puppetPart.rotationY * pi - modelPart.rotateAngleY) * job.animRate /10f + modelPart.rotateAngleY;
|
||||
modelPart.rotateAngleZ = (puppetPart.rotationZ * pi - modelPart.rotateAngleZ) * job.animRate /10f + modelPart.rotateAngleZ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
|
||||
{
|
||||
if(entityModel != null){
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
package noppes.npcs.roles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import noppes.npcs.controllers.ChunkController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
@@ -25,6 +16,16 @@ public class JobPuppet extends JobInterface{
|
||||
public boolean whileAttacking = false;
|
||||
public boolean whileMoving = false;
|
||||
|
||||
public boolean animate = false;
|
||||
public float animRate = 1.0F;
|
||||
|
||||
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};
|
||||
|
||||
public JobPuppet(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
@@ -41,6 +42,9 @@ public class JobPuppet extends JobInterface{
|
||||
compound.setBoolean("PuppetStanding", whileStanding);
|
||||
compound.setBoolean("PuppetAttacking", whileAttacking);
|
||||
compound.setBoolean("PuppetMoving", whileMoving);
|
||||
|
||||
compound.setBoolean("PuppetAnimate", animate);
|
||||
compound.setFloat("PuppetAnimSpeed", animRate);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -56,6 +60,9 @@ public class JobPuppet extends JobInterface{
|
||||
whileStanding = compound.getBoolean("PuppetStanding");
|
||||
whileAttacking = compound.getBoolean("PuppetAttacking");
|
||||
whileMoving = compound.getBoolean("PuppetMoving");
|
||||
|
||||
animate = compound.getBoolean("PuppetAnimate");
|
||||
animRate = compound.getFloat("PuppetAnimSpeed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,46 @@ public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet {
|
||||
this.job = (JobPuppet) npc.jobInterface;
|
||||
}
|
||||
|
||||
public void setAnimated(boolean animated) {
|
||||
this.job.animate = animated;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return this.job.animate;
|
||||
}
|
||||
|
||||
public void setAnimRate(float animRate) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
|
||||
@@ -1011,6 +1011,8 @@ model.save=Model Save
|
||||
puppet.standing=While standing
|
||||
puppet.walking=While walking
|
||||
puppet.attacking=While attacking
|
||||
puppet.animate=Animate
|
||||
puppet.animSpeed=Animation Speed
|
||||
|
||||
guard.creepers=Attack Creepers
|
||||
guard.animals=Attack Animals
|
||||
|
||||
Reference in new issue
Block a user