|
| 1 | +package mod.linguardium.tradesmen.entities; |
| 2 | + |
| 3 | +import com.google.common.collect.ImmutableList; |
| 4 | +import net.minecraft.client.model.ModelPart; |
| 5 | +import net.minecraft.client.render.entity.model.CompositeEntityModel; |
| 6 | +import net.minecraft.client.render.entity.model.ModelWithHat; |
| 7 | +import net.minecraft.client.render.entity.model.ModelWithHead; |
| 8 | +import net.minecraft.entity.Entity; |
| 9 | +import net.minecraft.entity.passive.AbstractTraderEntity; |
| 10 | +import net.minecraft.util.math.MathHelper; |
| 11 | + |
| 12 | +public class SecretTradesmenEntityModel<T extends Entity> extends CompositeEntityModel<T> implements ModelWithHead, ModelWithHat { |
| 13 | + protected ModelPart head=null; |
| 14 | + protected ModelPart man_torso=null; |
| 15 | + protected ModelPart arms=null; |
| 16 | + protected ModelPart torso=null; |
| 17 | + private ModelPart rightBackLeg=null; |
| 18 | + private ModelPart leftBackLeg=null; |
| 19 | + private ModelPart rightFrontLeg=null; |
| 20 | + private ModelPart leftFrontLeg=null; |
| 21 | + protected ModelPart nose=null; |
| 22 | + private ModelPart rightChest=null; |
| 23 | + private ModelPart leftChest=null; |
| 24 | + |
| 25 | + public SecretTradesmenEntityModel(float scale) { |
| 26 | + this(scale, 128, 64); |
| 27 | + } |
| 28 | + |
| 29 | + public SecretTradesmenEntityModel(float scale, int textureWidth, int textureHeight) { |
| 30 | + float f = 0.7F; |
| 31 | + this.head = (new ModelPart(this)).setTextureSize(textureWidth, textureHeight); |
| 32 | + this.head.setPivot(0.0F, -10.0F, -5.0F); |
| 33 | + this.head.setTextureOffset(0, 0).addCuboid(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, scale); |
| 34 | + this.nose = (new ModelPart(this)).setTextureSize(textureWidth, textureHeight); |
| 35 | + this.nose.setPivot(0.0F, -2.0F, 0.0F); |
| 36 | + this.nose.setTextureOffset(24, 0).addCuboid(-1.0F, -1.0F, -5.0F, 2.0F, 2.0F, 2.0F, scale); |
| 37 | + this.head.addChild(this.nose); |
| 38 | + this.man_torso = (new ModelPart(this)).setTextureSize(textureWidth, textureHeight); |
| 39 | + this.man_torso.setPivot(0.0F, -7.1F, 15.0F); |
| 40 | + // Y = front/back |
| 41 | + // Z = Height |
| 42 | + // X = Left/right |
| 43 | + this.man_torso.setTextureOffset(16, 20).addCuboid(-4.0F, 0.0F, -3.0F, 8.0F, 12.0F, 6.0F, scale); |
| 44 | + this.man_torso.pitch=-1.5707964F; |
| 45 | +/* this.robe = (new ModelPart(this)).setTextureSize(textureWidth, textureHeight); |
| 46 | + this.robe.setPivot(0.0F, 0.0F, 0.0F); |
| 47 | + this.robe.setTextureOffset(0, 38).addCuboid(-4.0F, 0.0F, -3.0F, 8.0F, 18.0F, 6.0F, scale + 0.5F); |
| 48 | + this.man_torso.addChild(this.robe);*/ |
| 49 | + this.arms = (new ModelPart(this)).setTextureSize(textureWidth, textureHeight); |
| 50 | + this.arms.setTextureOffset(0, 40).addCuboid(-8.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F, scale); |
| 51 | + this.arms.setTextureOffset(0, 40).addCuboid(4.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F, scale, true); |
| 52 | + this.arms.setTextureOffset(18, 40).addCuboid(-4.0F, 2.0F, -2.0F, 8.0F, 4.0F, 4.0F, scale); |
| 53 | + this.arms.setPivot(0.0F, -7.0F, -6.0F); |
| 54 | + this.torso = new ModelPart(this, 79, 0).setTextureSize(textureWidth,textureHeight); |
| 55 | + this.torso.addCuboid(-6.0F, -10.0F, -7.0F, 12.0F, 18.0F, 10.0F, f); |
| 56 | + this.torso.setPivot(0.0F, 5.0F, 2.0F); |
| 57 | + this.torso.pitch=1.5707964F; |
| 58 | + this.torso.addChild(man_torso); |
| 59 | + this.rightChest = new ModelPart(this, 45, 28).setTextureSize(textureWidth,textureHeight); |
| 60 | + this.rightChest.addCuboid(-3.0F, 0.0F, 0.0F, 8.0F, 8.0F, 3.0F, f); |
| 61 | + this.rightChest.setPivot(-8.5F, 3.0F, 3.0F); |
| 62 | + this.rightChest.yaw = 1.5707964F; |
| 63 | + this.leftChest = new ModelPart(this, 45, 41).setTextureSize(textureWidth,textureHeight); |
| 64 | + this.leftChest.addCuboid(-3.0F, 0.0F, 0.0F, 8.0F, 8.0F, 3.0F, f); |
| 65 | + this.leftChest.setPivot(5.5F, 3.0F, 3.0F); |
| 66 | + this.leftChest.yaw = 1.5707964F; |
| 67 | + this.rightBackLeg = new ModelPart(this, 79, 29).setTextureSize(textureWidth,textureHeight); |
| 68 | + this.rightBackLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 14.0F, 4.0F, f); |
| 69 | + this.rightBackLeg.setPivot(-2.5F, 10.0F, 6.0F); |
| 70 | + this.leftBackLeg = new ModelPart(this, 79, 29).setTextureSize(textureWidth,textureHeight); |
| 71 | + this.leftBackLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 14.0F, 4.0F, f); |
| 72 | + this.leftBackLeg.setPivot(2.5F, 10.0F, 6.0F); |
| 73 | + this.rightFrontLeg = new ModelPart(this, 79, 29).setTextureSize(textureWidth,textureHeight); |
| 74 | + this.rightFrontLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 14.0F, 4.0F, f); |
| 75 | + this.rightFrontLeg.setPivot(-2.5F, 10.0F, -4.0F); |
| 76 | + this.leftFrontLeg = new ModelPart(this, 79, 29).setTextureSize(textureWidth,textureHeight); |
| 77 | + this.leftFrontLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 14.0F, 4.0F, f); |
| 78 | + this.leftFrontLeg.setPivot(2.5F, 10.0F, -4.0F); |
| 79 | + --this.rightBackLeg.pivotX; |
| 80 | + ++this.leftBackLeg.pivotX; |
| 81 | + --this.rightFrontLeg.pivotX; |
| 82 | + ++this.leftFrontLeg.pivotX; |
| 83 | + --this.rightFrontLeg.pivotZ; |
| 84 | + --this.leftFrontLeg.pivotZ; |
| 85 | + } |
| 86 | + |
| 87 | + public Iterable<ModelPart> getParts() { |
| 88 | + return ImmutableList.of(this.head, this.torso, this.arms, this.rightBackLeg, this.leftBackLeg, this.rightFrontLeg, this.leftFrontLeg, this.rightChest, this.leftChest); |
| 89 | + } |
| 90 | + |
| 91 | + public void setAngles(T entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { |
| 92 | + boolean stillRollin = false; |
| 93 | + if (entity instanceof AbstractTraderEntity) { |
| 94 | + stillRollin = ((AbstractTraderEntity)entity).getHeadRollingTimeLeft() > 0; |
| 95 | + } |
| 96 | + |
| 97 | + this.head.yaw = headYaw * 0.017453292F; |
| 98 | + this.head.pitch = headPitch * 0.017453292F; |
| 99 | + if (stillRollin) { |
| 100 | + this.head.roll = 0.3F * MathHelper.sin(0.45F * customAngle); |
| 101 | + this.head.pitch = 0.4F; |
| 102 | + } else { |
| 103 | + this.head.roll = 0.0F; |
| 104 | + } |
| 105 | + this.arms.pitch = -0.75F; |
| 106 | + this.rightBackLeg.pitch = MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance; |
| 107 | + this.leftBackLeg.pitch = MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance; |
| 108 | + this.rightFrontLeg.pitch = MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance; |
| 109 | + this.leftFrontLeg.pitch = MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance; |
| 110 | + this.rightChest.visible = true; |
| 111 | + this.leftChest.visible = true; |
| 112 | + } |
| 113 | + |
| 114 | + public ModelPart getHead() { |
| 115 | + return this.head; |
| 116 | + } |
| 117 | + |
| 118 | + public void setHatVisible(boolean visible) { |
| 119 | + this.head.visible = visible; |
| 120 | + } |
| 121 | +} |
0 commit comments