Files
CustomNPC-Plus/src/main/java/noppes/npcs/client/model/ModelNPCMale.java
T

344 lines
14 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.client.model;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import noppes.npcs.CustomNpcs;
2021-04-30 02:43:35 -04:00
import noppes.npcs.client.model.util.ModelScaleRenderer;
2018-09-13 12:03:28 -04:00
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
2025-03-12 20:12:01 -04:00
public class ModelNPCMale extends ModelBiped {
2018-09-13 12:03:28 -04:00
public boolean isDancing;
public boolean isSleeping;
2021-05-07 19:49:04 -04:00
2018-09-13 12:03:28 -04:00
public float animationTick;
public float dancingTicks;
2022-06-17 13:16:54 -04:00
public float invisible;
2021-04-29 20:42:52 -04:00
2025-03-12 20:12:01 -04:00
public ModelNPCMale(float f) {
2021-05-07 19:49:04 -04:00
init(f, 0.0F);
2018-09-13 12:03:28 -04:00
}
2021-04-29 01:10:15 -04:00
2025-03-12 20:12:01 -04:00
public ModelNPCMale(float f, boolean alex) {
2021-04-29 01:10:15 -04:00
super(f, 0.0F, 64, 64);
2022-04-11 23:01:41 -04:00
init(f, 0.0F, alex);
2021-04-29 01:10:15 -04:00
}
2018-09-13 12:03:28 -04:00
@Override
2025-03-12 20:12:01 -04:00
public void setLivingAnimations(EntityLivingBase par1EntityLiving, float f6, float f5, float par9) {
2021-05-07 19:49:04 -04:00
animationTick += par9;
dancingTicks = CustomNpcs.ticks / 3.978873F;
2018-09-13 12:03:28 -04:00
}
2021-04-29 01:10:15 -04:00
// 64x64 Skin
2025-03-12 20:12:01 -04:00
public void init(float f, float f1, boolean arms) {
2021-04-29 01:10:15 -04:00
heldItemLeft = 0;
heldItemRight = 0;
isSneak = false;
aimedBow = false;
bipedCloak = new ModelRenderer(this, 0, 0);
bipedCloak.setTextureSize(64, 32);
bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, f);
// Same
bipedEars = new ModelRenderer(this, 24, 0);
bipedEars.setTextureSize(64, 32); // NEW LINE
bipedEars.addBox(-3F, -6F, -1F, 6, 6, 1, f);
bipedHead = new ModelRenderer(this, 0, 0);
bipedHead.addBox(-4F, -8F, -4F, 8, 8, 8, f);
bipedHead.setRotationPoint(0.0F, 0.0F + f1, 0.0F);
bipedHeadwear = new ModelRenderer(this, 32, 0);
bipedHeadwear.addBox(-4F, -8F, -4F, 8, 8, 8, f + 0.5F);
bipedHeadwear.setRotationPoint(0.0F, 0.0F + f1, 0.0F);
bipedBody = new ModelRenderer(this, 16, 16);
bipedBody.addBox(-4F, 0.0F, -2F, 8, 12, 4, f);
bipedBody.setRotationPoint(0.0F, 0.0F + f1, 0.0F);
2025-03-12 20:12:01 -04:00
if (arms) {
2021-05-07 19:49:04 -04:00
// Alex Version
bipedRightArm = (new ModelScaleRenderer(this, 40, 16));
bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, f);
bipedRightArm.setRotationPoint(-5.0F, 2.5F + f1, 0.0F);
bipedLeftArm = new ModelScaleRenderer(this, 32, 48);
bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, f);
bipedLeftArm.setRotationPoint(5.0F, 2.5F + f1, 0.0F);
2025-03-12 20:12:01 -04:00
} else {
2021-05-07 19:49:04 -04:00
// Steve Version
2021-04-30 02:43:35 -04:00
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedRightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f);
bipedRightArm.setRotationPoint(-5F, 2.0F + f1, 0.0F);
2021-05-07 19:49:04 -04:00
bipedLeftArm = new ModelRenderer(this, 32, 48);
bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, f);
bipedLeftArm.setRotationPoint(5.0F, 2.0F + f1, 0.0F);
}
2021-04-30 02:43:35 -04:00
2021-05-07 19:49:04 -04:00
bipedRightLeg = new ModelRenderer(this, 0, 16);
bipedRightLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f);
bipedRightLeg.setRotationPoint(-2F, 12F + f1, 0.0F);
2021-04-30 02:43:35 -04:00
2021-05-07 19:49:04 -04:00
bipedLeftLeg = new ModelRenderer(this, 16, 48);
bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, f);
bipedLeftLeg.setRotationPoint(1.9F, 12.0F + f1, 0.0F);
2021-04-29 01:10:15 -04:00
}
// 64x32
2025-03-12 20:12:01 -04:00
public void init(float f, float f1) {
2018-09-13 12:03:28 -04:00
heldItemLeft = 0;
heldItemRight = 0;
isSneak = false;
aimedBow = false;
2021-04-29 01:10:15 -04:00
2018-09-13 12:03:28 -04:00
bipedCloak = new ModelRenderer(this, 0, 0);
bipedCloak.textureHeight = 32;
bipedCloak.addBox(-5F, 0.0F, -1F, 10, 16, 1, f);
2021-05-07 19:49:04 -04:00
2018-09-13 12:03:28 -04:00
bipedEars = new ModelRenderer(this, 24, 0);
bipedEars.addBox(-3F, -6F, -1F, 6, 6, 1, f);
2021-05-07 19:49:04 -04:00
2018-09-13 12:03:28 -04:00
bipedHead = new ModelRenderer(this, 0, 0);
bipedHead.addBox(-4F, -8F, -4F, 8, 8, 8, f);
bipedHead.setRotationPoint(0.0F, 0.0F + f1, 0.0F);
2021-05-07 19:49:04 -04:00
2018-09-13 12:03:28 -04:00
bipedHeadwear = new ModelRenderer(this, 32, 0);
bipedHeadwear.addBox(-4F, -8F, -4F, 8, 8, 8, f + 0.5F);
bipedHeadwear.setRotationPoint(0.0F, 0.0F + f1, 0.0F);
bipedBody = new ModelRenderer(this, 16, 16);
bipedBody.addBox(-4F, 0.0F, -2F, 8, 12, 4, f);
bipedBody.setRotationPoint(0.0F, 0.0F + f1, 0.0F);
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedRightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f);
bipedRightArm.setRotationPoint(-5F, 2.0F + f1, 0.0F);
bipedLeftArm = new ModelRenderer(this, 40, 16);
bipedLeftArm.mirror = true;
bipedLeftArm.addBox(-1F, -2F, -2F, 4, 12, 4, f);
bipedLeftArm.setRotationPoint(5F, 2.0F + f1, 0.0F);
bipedRightLeg = new ModelRenderer(this, 0, 16);
bipedRightLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f);
bipedRightLeg.setRotationPoint(-2F, 12F + f1, 0.0F);
bipedLeftLeg = new ModelRenderer(this, 0, 16);
bipedLeftLeg.mirror = true;
bipedLeftLeg.addBox(-2F, 0.0F, -2F, 4, 12, 4, f);
bipedLeftLeg.setRotationPoint(2.0F, 12F + f1, 0.0F);
2021-05-07 19:49:04 -04:00
2018-09-13 12:03:28 -04:00
}
2021-04-29 01:10:15 -04:00
2018-09-13 12:03:28 -04:00
@Override
2025-03-12 20:12:01 -04:00
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
2018-09-13 12:03:28 -04:00
setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
2025-03-12 20:12:01 -04:00
if (!isDancing) {
2021-05-07 19:49:04 -04:00
bipedHead.render(par7);
bipedBody.render(par7);
bipedRightArm.render(par7);
bipedLeftArm.render(par7);
bipedRightLeg.render(par7);
bipedLeftLeg.render(par7);
bipedHeadwear.render(par7);
2025-03-12 20:12:01 -04:00
} else {
2021-05-07 19:49:04 -04:00
renderHead(par1Entity, par7);
renderArms(par1Entity, par7);
renderBody(par1Entity, par7);
renderLegs(par1Entity, par7);
}
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public void renderHead(Entity entityliving, float par7) {
if (isDancing) {
2021-05-07 19:49:04 -04:00
GL11.glPushMatrix();
2025-03-12 20:12:01 -04:00
GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.075F, (float) Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, (float) (-Math.abs(Math.cos(dancingTicks))) * 0.075F);
2021-05-07 19:49:04 -04:00
bipedHead.render(par7);
bipedHeadwear.render(par7);
GL11.glPopMatrix();
2025-03-12 20:12:01 -04:00
} else {
2021-05-07 19:49:04 -04:00
bipedHead.render(par7);
bipedHeadwear.render(par7);
}
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public void renderLeftArm(Entity entityliving, float par7) {
if (isDancing) {
2021-05-07 19:49:04 -04:00
GL11.glPushMatrix();
2025-03-12 20:12:01 -04:00
GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.025F, (float) Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, 0.0F);
2021-05-07 19:49:04 -04:00
bipedLeftArm.render(par7);
GL11.glPopMatrix();
2025-03-12 20:12:01 -04:00
} else {
2021-05-07 19:49:04 -04:00
bipedLeftArm.render(par7);
}
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public void renderArms(Entity entity, float par7) {
renderLeftArm(entity, par7);
renderRightArm(entity, par7);
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public void renderRightArm(Entity entityliving, float par7) {
if (isDancing) {
2021-05-07 19:49:04 -04:00
GL11.glPushMatrix();
2025-03-12 20:12:01 -04:00
GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.025F, (float) Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, 0.0F);
2021-05-07 19:49:04 -04:00
bipedRightArm.render(par7);
GL11.glPopMatrix();
2025-03-12 20:12:01 -04:00
} else {
2021-05-07 19:49:04 -04:00
bipedRightArm.render(par7);
}
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public void renderBody(Entity entityliving, float par7) {
if (isDancing) {
2021-05-07 19:49:04 -04:00
GL11.glPushMatrix();
2025-03-12 20:12:01 -04:00
GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.015F, 0.0F, 0.0F);
2021-05-07 19:49:04 -04:00
bipedBody.render(par7);
GL11.glPopMatrix();
2025-03-12 20:12:01 -04:00
} else {
2021-05-07 19:49:04 -04:00
bipedBody.render(par7);
}
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public void renderLegs(Entity entityliving, float par7) {
2018-09-13 12:03:28 -04:00
bipedRightLeg.render(par7);
bipedLeftLeg.render(par7);
}
2021-05-07 19:49:04 -04:00
2025-03-12 20:12:01 -04:00
public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
2021-05-07 19:49:04 -04:00
EntityNPCInterface npc = (EntityNPCInterface) entity;
isRiding = npc.isRiding();
2025-03-12 20:12:01 -04:00
if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING))
2021-05-07 19:49:04 -04:00
isSneak = false;
2025-03-12 20:12:01 -04:00
bipedHead.rotateAngleY = par4 / (180F / (float) Math.PI);
bipedHead.rotateAngleX = par5 / (180F / (float) Math.PI);
2018-09-13 12:03:28 -04:00
bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY;
bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX;
2025-03-12 20:12:01 -04:00
bipedRightArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 2.0F * par2 * 0.5F;
2018-09-13 12:03:28 -04:00
bipedLeftArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
bipedRightArm.rotateAngleZ = 0.0F;
bipedLeftArm.rotateAngleZ = 0.0F;
bipedRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
2025-03-12 20:12:01 -04:00
bipedLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.4F * par2;
2018-09-13 12:03:28 -04:00
bipedRightLeg.rotateAngleY = 0.0F;
bipedLeftLeg.rotateAngleY = 0.0F;
2021-05-07 19:49:04 -04:00
2025-03-12 20:12:01 -04:00
if (isRiding) {
bipedRightArm.rotateAngleX += -((float) Math.PI / 5F);
bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F);
bipedRightLeg.rotateAngleX = -((float) Math.PI * 2F / 5F);
bipedLeftLeg.rotateAngleX = -((float) Math.PI * 2F / 5F);
bipedRightLeg.rotateAngleY = ((float) Math.PI / 10F);
bipedLeftLeg.rotateAngleY = -((float) Math.PI / 10F);
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
if (heldItemLeft != 0) {
bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F) * (float) heldItemLeft;
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
if (heldItemRight != 0) {
bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F) * (float) heldItemRight;
2018-09-13 12:03:28 -04:00
}
bipedRightArm.rotateAngleY = 0.0F;
bipedLeftArm.rotateAngleY = 0.0F;
2025-03-12 20:12:01 -04:00
if (onGround > -9990F) {
2018-09-13 12:03:28 -04:00
float f = onGround;
2025-03-12 20:12:01 -04:00
bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f) * (float) Math.PI * 2.0F) * 0.2F;
2018-09-13 12:03:28 -04:00
bipedRightArm.rotationPointZ = MathHelper.sin(bipedBody.rotateAngleY) * 5F;
bipedRightArm.rotationPointX = -MathHelper.cos(bipedBody.rotateAngleY) * 5F;
bipedLeftArm.rotationPointZ = -MathHelper.sin(bipedBody.rotateAngleY) * 5F;
bipedLeftArm.rotationPointX = MathHelper.cos(bipedBody.rotateAngleY) * 5F;
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
bipedLeftArm.rotateAngleX += bipedBody.rotateAngleY;
f = 1.0F - onGround;
f *= f;
f *= f;
f = 1.0F - f;
2025-03-12 20:12:01 -04:00
float f2 = MathHelper.sin(f * (float) Math.PI);
float f4 = MathHelper.sin(onGround * (float) Math.PI) * -(bipedHead.rotateAngleX - 0.7F) * 0.75F;
bipedRightArm.rotateAngleX -= (double) f2 * 1.2D + (double) f4;
2018-09-13 12:03:28 -04:00
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY * 2.0F;
2025-03-12 20:12:01 -04:00
bipedRightArm.rotateAngleZ = MathHelper.sin(onGround * (float) Math.PI) * -0.4F;
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
if (isSneak) {
2018-09-13 12:03:28 -04:00
bipedBody.rotateAngleX = 0.5F;
bipedRightLeg.rotateAngleX -= 0.0F;
bipedLeftLeg.rotateAngleX -= 0.0F;
bipedRightArm.rotateAngleX += 0.4F;
bipedLeftArm.rotateAngleX += 0.4F;
bipedRightLeg.rotationPointZ = 4F;
bipedLeftLeg.rotationPointZ = 4F;
bipedRightLeg.rotationPointY = 9F;
bipedLeftLeg.rotationPointY = 9F;
bipedHead.rotationPointY = 1.0F;
2025-03-12 20:12:01 -04:00
} else {
2018-09-13 12:03:28 -04:00
bipedBody.rotateAngleX = 0.0F;
bipedRightLeg.rotationPointZ = 0.0F;
bipedLeftLeg.rotationPointZ = 0.0F;
bipedRightLeg.rotationPointY = 12F;
bipedLeftLeg.rotationPointY = 12F;
bipedHead.rotationPointY = 0.0F;
}
bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F;
bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F;
bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F;
bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F;
2025-03-12 20:12:01 -04:00
if (aimedBow) {
2018-09-13 12:03:28 -04:00
float f1 = 0.0F;
float f3 = 0.0F;
bipedRightArm.rotateAngleZ = 0.0F;
bipedLeftArm.rotateAngleZ = 0.0F;
bipedRightArm.rotateAngleY = -(0.1F - f1 * 0.6F) + bipedHead.rotateAngleY;
bipedLeftArm.rotateAngleY = (0.1F - f1 * 0.6F) + bipedHead.rotateAngleY + 0.4F;
2025-03-12 20:12:01 -04:00
bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX;
bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX;
2018-09-13 12:03:28 -04:00
bipedRightArm.rotateAngleX -= f1 * 1.2F - f3 * 0.4F;
bipedLeftArm.rotateAngleX -= f1 * 1.2F - f3 * 0.4F;
bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F;
bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F;
bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F;
bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F;
}
}
2025-03-12 20:12:01 -04:00
public void renderEars(float f) {
2018-09-13 12:03:28 -04:00
bipedEars.rotateAngleY = bipedHead.rotateAngleY;
bipedEars.rotateAngleX = bipedHead.rotateAngleX;
bipedEars.rotationPointX = 0.0F;
bipedEars.rotationPointY = 0.0F;
bipedEars.render(f);
}
2025-03-12 20:12:01 -04:00
public void setRotation(ModelRenderer model, float x, float y, float z) {
2021-05-07 19:49:04 -04:00
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
2018-09-13 12:03:28 -04:00
}
2021-05-07 19:49:04 -04:00
2025-03-12 20:12:01 -04:00
public void renderCloak(float f) {
2018-09-13 12:03:28 -04:00
bipedCloak.render(f);
}
2021-05-07 19:49:04 -04:00
public boolean isSleeping(Entity entity) {
2025-03-12 20:12:01 -04:00
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).isPlayerSleeping())
2021-05-07 19:49:04 -04:00
return true;
2025-03-12 20:12:01 -04:00
return ((EntityNPCInterface) entity).currentAnimation == EnumAnimation.LYING;
2021-05-07 19:49:04 -04:00
}
2018-09-13 12:03:28 -04:00
}