grossik

Untitled

Aug 14th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1. package com.example.examplemod;
  2.  
  3. import net.minecraft.client.model.IMultipassModel;
  4. import net.minecraft.client.model.ModelBase;
  5. import net.minecraft.client.model.ModelRenderer;
  6. import net.minecraft.client.renderer.GLAllocation;
  7. import net.minecraft.client.renderer.GlStateManager;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.util.math.MathHelper;
  10. import net.minecraftforge.fml.relauncher.Side;
  11. import net.minecraftforge.fml.relauncher.SideOnly;
  12.  
  13. @SideOnly(Side.CLIENT)
  14. public class ModelVehicle extends ModelBase implements IMultipassModel
  15. {
  16. public ModelRenderer[] boatSides = new ModelRenderer[5];
  17. public ModelRenderer[] paddles = new ModelRenderer[2];
  18. /** Part of the model rendered to make it seem like there's no water in the boat */
  19. public ModelRenderer noWater;
  20. private final int patchList = GLAllocation.generateDisplayLists(1);
  21.  
  22. public ModelVehicle()
  23. {
  24. this.boatSides[0] = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
  25. this.boatSides[1] = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64);
  26. this.boatSides[2] = (new ModelRenderer(this, 0, 27)).setTextureSize(128, 64);
  27. this.boatSides[3] = (new ModelRenderer(this, 0, 35)).setTextureSize(128, 64);
  28. this.boatSides[4] = (new ModelRenderer(this, 0, 43)).setTextureSize(128, 64);
  29. int i = 32;
  30. int j = 6;
  31. int k = 20;
  32. int l = 4;
  33. int i1 = 28;
  34. this.boatSides[0].addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F);
  35. this.boatSides[0].setRotationPoint(0.0F, 3.0F, 1.0F);
  36. this.boatSides[1].addBox(-13.0F, -7.0F, -1.0F, 18, 6, 2, 0.0F);
  37. this.boatSides[1].setRotationPoint(-15.0F, 4.0F, 4.0F);
  38. this.boatSides[2].addBox(-8.0F, -7.0F, -1.0F, 16, 6, 2, 0.0F);
  39. this.boatSides[2].setRotationPoint(15.0F, 4.0F, 0.0F);
  40. this.boatSides[3].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F);
  41. this.boatSides[3].setRotationPoint(0.0F, 4.0F, -9.0F);
  42. this.boatSides[4].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F);
  43. this.boatSides[4].setRotationPoint(0.0F, 4.0F, 9.0F);
  44. this.boatSides[0].rotateAngleX = ((float)Math.PI / 2F);
  45. this.boatSides[1].rotateAngleY = ((float)Math.PI * 3F / 2F);
  46. this.boatSides[2].rotateAngleY = ((float)Math.PI / 2F);
  47. this.boatSides[3].rotateAngleY = (float)Math.PI;
  48. this.paddles[0] = this.makePaddle(true);
  49. this.paddles[0].setRotationPoint(3.0F, -5.0F, 9.0F);
  50. this.paddles[1] = this.makePaddle(false);
  51. this.paddles[1].setRotationPoint(3.0F, -5.0F, -9.0F);
  52. this.paddles[1].rotateAngleY = (float)Math.PI;
  53. this.paddles[0].rotateAngleZ = 0.19634955F;
  54. this.paddles[1].rotateAngleZ = 0.19634955F;
  55. this.noWater = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
  56. this.noWater.addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F);
  57. this.noWater.setRotationPoint(0.0F, -3.0F, 1.0F);
  58. this.noWater.rotateAngleX = ((float)Math.PI / 2F);
  59. }
  60.  
  61. /**
  62. * Sets the models various rotation angles then renders the model.
  63. */
  64. public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
  65. {
  66. GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
  67. EntityVehicle entityboat = (EntityVehicle)entityIn;
  68. this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn);
  69.  
  70. for (int i = 0; i < 5; ++i)
  71. {
  72. this.boatSides[i].render(scale);
  73. }
  74.  
  75. this.renderPaddle(entityboat, 0, scale, limbSwing);
  76. this.renderPaddle(entityboat, 1, scale, limbSwing);
  77. }
  78.  
  79. public void renderMultipass(Entity p_187054_1_, float p_187054_2_, float p_187054_3_, float p_187054_4_, float p_187054_5_, float p_187054_6_, float scale)
  80. {
  81. GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
  82. GlStateManager.colorMask(false, false, false, false);
  83. this.noWater.render(scale);
  84. GlStateManager.colorMask(true, true, true, true);
  85. }
  86.  
  87. /**
  88. * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
  89. * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
  90. * "far" arms and legs can swing at most.
  91. */
  92. public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
  93. {
  94. }
  95.  
  96. ModelRenderer makePaddle(boolean p_187056_1_)
  97. {
  98. ModelRenderer modelrenderer = (new ModelRenderer(this, 62, p_187056_1_ ? 0 : 20)).setTextureSize(128, 64);
  99. int i = 20;
  100. int j = 7;
  101. int k = 6;
  102. float f = -5.0F;
  103. modelrenderer.addBox(-1.0F, 0.0F, -5.0F, 2, 2, 18);
  104. modelrenderer.addBox(p_187056_1_ ? -1.001F : 0.001F, -3.0F, 8.0F, 1, 6, 7);
  105. return modelrenderer;
  106. }
  107.  
  108. void renderPaddle(EntityVehicle boat, int paddle, float scale, float limbSwing)
  109. {
  110. float f = 40.0F;
  111. float f1 = boat.getRowingTime(paddle, limbSwing) * 40.0F;
  112. ModelRenderer modelrenderer = this.paddles[paddle];
  113. modelrenderer.rotateAngleX = (float)MathHelper.denormalizeClamp(-1.0471975803375244D, -0.2617993950843811D, (double)((MathHelper.sin(-f1) + 1.0F) / 2.0F));
  114. modelrenderer.rotateAngleY = (float)MathHelper.denormalizeClamp(-(Math.PI / 4D), (Math.PI / 4D), (double)((MathHelper.sin(-f1 + 1.0F) + 1.0F) / 2.0F));
  115.  
  116. if (paddle == 1)
  117. {
  118. modelrenderer.rotateAngleY = (float)Math.PI - modelrenderer.rotateAngleY;
  119. }
  120.  
  121. modelrenderer.render(scale);
  122. }
  123. }
Add Comment
Please, Sign In to add comment