Advertisement
Guest User

Untitled

a guest
Mar 31st, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.12 KB | None | 0 0
  1. package com.example.examplemod.client.model;
  2.  
  3. import com.example.examplemod.entity.WarpedPiglinBruteEntity;
  4. import com.example.examplemod.entity.WarpedPiglinEntity;
  5. import com.google.common.collect.ImmutableList;
  6. import com.google.common.collect.Iterables;
  7. import com.mojang.blaze3d.matrix.MatrixStack;
  8. import com.mojang.blaze3d.vertex.IVertexBuilder;
  9. import net.minecraft.client.renderer.entity.model.BipedModel;
  10. import net.minecraft.client.renderer.entity.model.EntityModel;
  11. import net.minecraft.client.renderer.entity.model.PlayerModel;
  12. import net.minecraft.client.renderer.model.ModelHelper;
  13. import net.minecraft.client.renderer.model.ModelRenderer;
  14. import net.minecraft.entity.Entity;
  15. import net.minecraft.entity.EntityType;
  16. import net.minecraft.entity.monster.piglin.AbstractPiglinEntity;
  17. import net.minecraft.entity.monster.piglin.PiglinAction;
  18. import net.minecraft.entity.monster.piglin.PiglinEntity;
  19. import net.minecraft.util.math.MathHelper;
  20.  
  21. // Made with Blockbench 4.1.2
  22. // Exported for Minecraft version 1.15 - 1.16 with Mojang mappings
  23. // Paste this class into your mod and generate all required imports
  24.  
  25.  
  26. public class WarpedPiglinModel extends PlayerModel<WarpedPiglinEntity> {
  27. private final ModelRenderer earLeft;
  28. private final ModelRenderer leftArmDefault;
  29. private final ModelRenderer rightArmDefault;
  30. private final ModelRenderer body_r1;
  31. private final ModelRenderer body_r2;
  32. private final ModelRenderer rightItem;
  33. private final ModelRenderer earRight;
  34. private final ModelRenderer headDefault;
  35. private final ModelRenderer body_r3;
  36. private final ModelRenderer body_r4;
  37. private final ModelRenderer bodyDefault;
  38. private final ModelRenderer body_r5;
  39. private final ModelRenderer body_r6;
  40.  
  41. public WarpedPiglinModel() {
  42. super(0.0F, false);
  43. texWidth = 128;
  44. texHeight = 128;
  45.  
  46. leftLeg = new ModelRenderer(this);
  47. leftLeg.setPos(1.9F, 12.0F, 0.0F);
  48. leftLeg.texOffs(44, 42).addBox(-1.9F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.0F, false);
  49. leftLeg.texOffs(36, 10).addBox(-1.9F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.25F, false);
  50.  
  51. rightLeg = new ModelRenderer(this);
  52. rightLeg.setPos(-1.9F, 12.0F, 0.0F);
  53. rightLeg.texOffs(16, 46).addBox(-2.1F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.0F, false);
  54. rightLeg.texOffs(0, 46).addBox(-2.1F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.25F, false);
  55.  
  56. leftArmDefault = new ModelRenderer(this);
  57. leftArmDefault.setPos(5.0F, 2.0F, 0.0F);
  58. leftArmDefault.texOffs(52, 0).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.0F, false);
  59. leftArmDefault.texOffs(48, 22).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.25F, false);
  60.  
  61. rightArmDefault = new ModelRenderer(this);
  62. rightArmDefault.setPos(-5.0F, 2.0F, 0.0F);
  63. rightArmDefault.texOffs(56, 54).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.0F, false);
  64. rightArmDefault.texOffs(32, 54).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, 0.25F, false);
  65.  
  66. body_r1 = new ModelRenderer(this);
  67. body_r1.setPos(1.0F, 6.5F, 2.5F);
  68. rightArmDefault.addChild(body_r1);
  69. setRotationAngle(body_r1, 1.4292F, -0.1666F, -0.8608F);
  70. body_r1.texOffs(0, 0).addBox(0.0F, -2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 0.0F, false);
  71.  
  72. body_r2 = new ModelRenderer(this);
  73. body_r2.setPos(1.0F, 6.5F, 2.5F);
  74. rightArmDefault.addChild(body_r2);
  75. setRotationAngle(body_r2, -0.8727F, -1.3526F, 1.5708F);
  76. body_r2.texOffs(0, 0).addBox(0.0F, -2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 0.0F, false);
  77.  
  78. headDefault = new ModelRenderer(this);
  79. headDefault.setPos(0.0F, 0.0F, 0.0F);
  80. headDefault.texOffs(0, 14).addBox(-5.0F, -8.0F, -4.0F, 10.0F, 8.0F, 8.0F, -0.02F, false);
  81. headDefault.texOffs(36, 26).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 2.0F, 0.0F, -0.02F, false);
  82. headDefault.texOffs(0, 0).addBox(-2.0F, -4.0F, -5.0F, 4.0F, 4.0F, 1.0F, 0.0F, false);
  83. headDefault.texOffs(4, 14).addBox(2.0F, -2.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
  84. headDefault.texOffs(0, 14).addBox(-3.0F, -2.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
  85.  
  86. body_r3 = new ModelRenderer(this);
  87. body_r3.setPos(0.0F, -9.5F, 0.5F);
  88. headDefault.addChild(body_r3);
  89. setRotationAngle(body_r3, 0.0F, -1.0036F, 1.8762F);
  90. body_r3.texOffs(0, 0).addBox(0.0F, -2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 0.0F, false);
  91.  
  92. body_r4 = new ModelRenderer(this);
  93. body_r4.setPos(0.0F, -9.5F, 0.5F);
  94. headDefault.addChild(body_r4);
  95. setRotationAngle(body_r4, 1.0036F, 0.0F, 0.3054F);
  96. body_r4.texOffs(0, 0).addBox(0.0F, -2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 0.0F, false);
  97.  
  98. earRight = new ModelRenderer(this);
  99. earRight.setPos(-5.0F, -6.0F, 0.0F);
  100. headDefault.addChild(earRight);
  101. setRotationAngle(earRight, 0.0F, 0.0F, 0.5236F);
  102. earRight.texOffs(30, 0).addBox(0.0F, 0.0F, -2.0F, 1.0F, 5.0F, 4.0F, 0.0F, false);
  103.  
  104. earLeft = new ModelRenderer(this);
  105. earLeft.setPos(5.0F, -6.0F, 0.0F);
  106. headDefault.addChild(earLeft);
  107. setRotationAngle(earLeft, 0.0F, 0.0F, -0.5236F);
  108. earLeft.texOffs(40, 0).addBox(-1.0F, 0.0F, -2.0F, 1.0F, 5.0F, 4.0F, 0.0F, false);
  109.  
  110. hat = new ModelRenderer(this);
  111. hat.setPos(0.0F, 0.0F, 0.0F);
  112. head.addChild(hat);
  113.  
  114. rightItem = new ModelRenderer(this);
  115. rightItem.setPos(-1.0F, 7.0F, 1.0F);
  116. rightArmDefault.addChild(rightItem);
  117.  
  118. bodyDefault = new ModelRenderer(this);
  119. bodyDefault.setPos(0.0F, 0.0F, 0.0F);
  120. bodyDefault.texOffs(24, 30).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, 0.0F, false);
  121. bodyDefault.texOffs(0, 30).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, 0.25F, false);
  122.  
  123. body_r5 = new ModelRenderer(this);
  124. body_r5.setPos(1.0F, 6.5F, 2.5F);
  125. bodyDefault.addChild(body_r5);
  126. setRotationAngle(body_r5, 0.0F, -0.9163F, 1.8762F);
  127. body_r5.texOffs(0, 0).addBox(0.0F, -2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 0.0F, false);
  128.  
  129. body_r6 = new ModelRenderer(this);
  130. body_r6.setPos(1.0F, 6.5F, 2.5F);
  131. bodyDefault.addChild(body_r6);
  132. setRotationAngle(body_r6, 0.9163F, 0.0F, 0.3054F);
  133. body_r6.texOffs(0, 0).addBox(0.0F, -2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 0.0F, false);
  134. }
  135.  
  136. public void setupAnim(WarpedPiglinEntity pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
  137. super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
  138. this.body.copyFrom(this.bodyDefault);
  139. this.head.copyFrom(this.headDefault);
  140. this.leftArm.copyFrom(this.leftArmDefault);
  141. this.rightArm.copyFrom(this.rightArmDefault);
  142. float f = ((float)Math.PI / 6F);
  143. float f1 = pAgeInTicks * 0.1F + pLimbSwing * 0.5F;
  144. float f2 = 0.08F + pLimbSwingAmount * 0.4F;
  145. this.earRight.zRot = (-(float)Math.PI / 6F) - MathHelper.cos(f1 * 1.2F) * f2;
  146. this.earLeft.zRot = ((float)Math.PI / 6F) + MathHelper.cos(f1) * f2;
  147. PiglinAction piglinaction = ((AbstractPiglinEntity)pEntity).getArmPose();
  148. if (piglinaction == PiglinAction.DANCING) {
  149. float f3 = pAgeInTicks / 60.0F;
  150. this.earLeft.zRot = ((float)Math.PI / 6F) + ((float)Math.PI / 180F) * MathHelper.sin(f3 * 30.0F) * 10.0F;
  151. this.earRight.zRot = (-(float)Math.PI / 6F) - ((float)Math.PI / 180F) * MathHelper.cos(f3 * 30.0F) * 10.0F;
  152. this.head.x = MathHelper.sin(f3 * 10.0F);
  153. this.head.y = MathHelper.sin(f3 * 40.0F) + 0.4F;
  154. this.rightArm.zRot = ((float)Math.PI / 180F) * (70.0F + MathHelper.cos(f3 * 40.0F) * 10.0F);
  155. this.leftArm.zRot = this.rightArm.zRot * -1.0F;
  156. this.rightArm.y = MathHelper.sin(f3 * 40.0F) * 0.5F + 1.5F;
  157. this.leftArm.y = MathHelper.sin(f3 * 40.0F) * 0.5F + 1.5F;
  158. this.body.y = MathHelper.sin(f3 * 40.0F) * 0.35F;
  159. } else if (piglinaction == PiglinAction.ATTACKING_WITH_MELEE_WEAPON && this.attackTime == 0.0F) {
  160. this.holdWeaponHigh(pEntity);
  161. } else if (piglinaction == PiglinAction.CROSSBOW_HOLD) {
  162. ModelHelper.animateCrossbowHold(this.rightArm, this.leftArm, this.head, !pEntity.isLeftHanded());
  163. } else if (piglinaction == PiglinAction.CROSSBOW_CHARGE) {
  164. ModelHelper.animateCrossbowCharge(this.rightArm, this.leftArm, pEntity, !pEntity.isLeftHanded());
  165. } else if (piglinaction == PiglinAction.ADMIRING_ITEM) {
  166. this.head.xRot = 0.5F;
  167. this.head.yRot = 0.0F;
  168. if (pEntity.isLeftHanded()) {
  169. this.rightArm.yRot = -0.5F;
  170. this.rightArm.xRot = -0.9F;
  171. } else {
  172. this.leftArm.yRot = 0.5F;
  173. this.leftArm.xRot = -0.9F;
  174. }
  175. }
  176. }
  177.  
  178. protected void setupAttackAnimation(WarpedPiglinEntity p_230486_1_, float p_230486_2_) {
  179. if (this.attackTime > 0.0F && p_230486_1_ instanceof PiglinEntity && ((PiglinEntity)p_230486_1_).getArmPose() == PiglinAction.ATTACKING_WITH_MELEE_WEAPON) {
  180. ModelHelper.swingWeaponDown(this.rightArm, this.leftArm, p_230486_1_, this.attackTime, p_230486_2_);
  181. } else {
  182. super.setupAttackAnimation(p_230486_1_, p_230486_2_);
  183. }
  184. }
  185.  
  186. private void holdWeaponHigh(WarpedPiglinEntity p_239117_1_) {
  187. if (p_239117_1_.isLeftHanded()) {
  188. this.leftArm.xRot = -1.8F;
  189. } else {
  190. this.rightArm.xRot = -1.8F;
  191. }
  192.  
  193. }
  194.  
  195. public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
  196. modelRenderer.xRot = x;
  197. modelRenderer.yRot = y;
  198. modelRenderer.zRot = z;
  199. }
  200.  
  201. @Override
  202. protected Iterable<ModelRenderer> bodyParts() {
  203. return ImmutableList.of(leftArmDefault, rightArmDefault, bodyDefault, leftLeg, rightLeg, body_r1, body_r2, body_r5, body_r6);
  204. }
  205.  
  206. @Override
  207. protected Iterable<ModelRenderer> headParts() {
  208. return ImmutableList.of(headDefault, earLeft, earRight, body_r4, body_r5);
  209. }
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement