Advertisement
JoviverdeCP

Untitled

May 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. public class ClientPhysic
  2. {
  3. public static Minecraft mc = ;
  4. public static RenderItem renderItem = mc.getRenderItem();
  5. public static long tick;
  6. public static double rotation;
  7. public static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
  8.  
  9. public static void doRender(Entity par1Entity, double x, double y, double z, float par8, float par9)
  10. {
  11. rotation = (System.nanoTime() - tick) / 3000000.0D;
  12. if (!mc.inGameHasFocus) {
  13. rotation = 0.0D;
  14. }
  15. EntityItem entityitem = (EntityItem)par1Entity;
  16. ItemStack itemstack = entityitem.getEntityItem();
  17. if (itemstack.getItem() != null)
  18. {
  19. boolean flag = false;
  20. if (TextureMap.locationBlocksTexture != null)
  21. {
  22. mc.getRenderManager().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  23. mc.getRenderManager().renderEngine.getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
  24. flag = true;
  25. }
  26. GlStateManager.enableRescaleNormal();
  27. GlStateManager.alphaFunc(516, 0.1F);
  28. GlStateManager.enableBlend();
  29. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  30. GlStateManager.pushMatrix();
  31. IBakedModel ibakedmodel = renderItem.getItemModelMesher().getItemModel(itemstack);
  32. int i = func_177077_a(entityitem, x, y, z, par9, ibakedmodel);
  33. BlockPos blockpos = new BlockPos(entityitem);
  34. if (entityitem.rotationPitch > 360.0F) {
  35. entityitem.rotationPitch = 0.0F;
  36. }
  37. if ((entityitem != null) && (!Double.isNaN(entityitem.posX)) && (!Double.isNaN(entityitem.posY)) && (!Double.isNaN(entityitem.posZ)) && (entityitem.worldObj != null)) {
  38. if (entityitem.onGround)
  39. {
  40. if ((entityitem.rotationPitch != 0.0F) && (entityitem.rotationPitch != 90.0F) && (entityitem.rotationPitch != 180.0F) && (entityitem.rotationPitch != 270.0F))
  41. {
  42. double d0 = formPositiv(entityitem.rotationPitch);
  43. double d1 = formPositiv(entityitem.rotationPitch - 90.0F);
  44. double d2 = formPositiv(entityitem.rotationPitch - 180.0F);
  45. double d3 = formPositiv(entityitem.rotationPitch - 270.0F);
  46. if ((d0 <= d1) && (d0 <= d2) && (d0 <= d3)) {
  47. if (entityitem.rotationPitch < 0.0F) {
  48. entityitem.rotationPitch = ((float)(entityitem.rotationPitch + rotation));
  49. } else {
  50. entityitem.rotationPitch = ((float)(entityitem.rotationPitch - rotation));
  51. }
  52. }
  53. if ((d1 < d0) && (d1 <= d2) && (d1 <= d3)) {
  54. if (entityitem.rotationPitch - 90.0F < 0.0F) {
  55. entityitem.rotationPitch = ((float)(entityitem.rotationPitch + rotation));
  56. } else {
  57. entityitem.rotationPitch = ((float)(entityitem.rotationPitch - rotation));
  58. }
  59. }
  60. if ((d2 < d1) && (d2 < d0) && (d2 <= d3)) {
  61. if (entityitem.rotationPitch - 180.0F < 0.0F) {
  62. entityitem.rotationPitch = ((float)(entityitem.rotationPitch + rotation));
  63. } else {
  64. entityitem.rotationPitch = ((float)(entityitem.rotationPitch - rotation));
  65. }
  66. }
  67. if ((d3 < d1) && (d3 < d2) && (d3 < d0)) {
  68. if (entityitem.rotationPitch - 270.0F < 0.0F) {
  69. entityitem.rotationPitch = ((float)(entityitem.rotationPitch + rotation));
  70. } else {
  71. entityitem.rotationPitch = ((float)(entityitem.rotationPitch - rotation));
  72. }
  73. }
  74. }
  75. }
  76. else
  77. {
  78. BlockPos blockpos1 = new BlockPos(entityitem);
  79. blockpos1.add(0, 1, 0);
  80. Material material = entityitem.worldObj.getBlockState(blockpos1).getBlock().getMaterial();
  81. Material material1 = entityitem.worldObj.getBlockState(blockpos).getBlock().getMaterial();
  82. boolean flag1 = entityitem.isInsideOfMaterial(Material.water);
  83. boolean flag2 = entityitem.isInWater();
  84. if ((flag1 | material == Material.water | material1 == Material.water | flag2)) {
  85. entityitem.rotationPitch = ((float)(entityitem.rotationPitch + rotation / 4.0D));
  86. } else {
  87. entityitem.rotationPitch = ((float)(entityitem.rotationPitch + rotation * 2.0D));
  88. }
  89. }
  90. }
  91. GL11.glRotatef(entityitem.rotationYaw, 0.0F, 1.0F, 0.0F);
  92. GL11.glRotatef(entityitem.rotationPitch + 90.0F, 1.0F, 0.0F, 0.0F);
  93. for (int j = 0; j < i; j++) {
  94. if (ibakedmodel.isAmbientOcclusion())
  95. {
  96. GlStateManager.pushMatrix();
  97. GlStateManager.scale(0.5F, 0.5F, 0.5F);
  98. renderItem.renderItem(itemstack, ibakedmodel);
  99. GlStateManager.popMatrix();
  100. }
  101. else
  102. {
  103. GlStateManager.pushMatrix();
  104. if ((j > 0) && (shouldSpreadItems())) {
  105. GlStateManager.translate(0.0F, 0.0F, 0.046875F * j);
  106. }
  107. renderItem.renderItem(itemstack, ibakedmodel);
  108. if (!shouldSpreadItems()) {
  109. GlStateManager.translate(0.0F, 0.0F, 0.046875F);
  110. }
  111. GlStateManager.popMatrix();
  112. }
  113. }
  114. GlStateManager.popMatrix();
  115. GlStateManager.disableRescaleNormal();
  116. GlStateManager.disableBlend();
  117. mc.getRenderManager().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  118. if (flag) {
  119. mc.getRenderManager().renderEngine.getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
  120. }
  121. }
  122. }
  123.  
  124. public static int func_177077_a(EntityItem items, double x, double y, double z, float p_177077_8_, IBakedModel p_177077_9_)
  125. {
  126. ItemStack itemstack = items.getEntityItem();
  127. Item item = itemstack.getItem();
  128. if (item == null) {
  129. return 0;
  130. }
  131. boolean flag = p_177077_9_.isAmbientOcclusion();
  132. int i = func_177078_a(itemstack);
  133. float f = 0.25F;
  134. float f1 = 0.0F;
  135. GlStateManager.translate((float)x, (float)y + f1 + 0.25F, (float)z);
  136. float f2 = 0.0F;
  137. if ((flag) || ((mc.getRenderManager().options != null) && (mc.getRenderManager().options.fancyGraphics))) {
  138. GlStateManager.rotate(f2, 0.0F, 1.0F, 0.0F);
  139. }
  140. if (!flag)
  141. {
  142. f2 = -0.0F * (i - 1) * 0.5F;
  143. float f3 = -0.0F * (i - 1) * 0.5F;
  144. float f4 = -0.046875F * (i - 1) * 0.5F;
  145. GlStateManager.translate(f2, f3, f4);
  146. }
  147. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  148. return i;
  149. }
  150.  
  151. public static boolean shouldSpreadItems()
  152. {
  153. return true;
  154. }
  155.  
  156. public static double formPositiv(float rotationPitch)
  157. {
  158. return rotationPitch > 0.0F ? rotationPitch : -rotationPitch;
  159. }
  160.  
  161. public static int func_177078_a(ItemStack stack)
  162. {
  163. byte b0 = 1;
  164. if (stack.stackSize > 48) {
  165. b0 = 5;
  166. } else if (stack.stackSize > 32) {
  167. b0 = 4;
  168. } else if (stack.stackSize > 16) {
  169. b0 = 3;
  170. } else if (stack.stackSize > 1) {
  171. b0 = 2;
  172. }
  173. return b0;
  174. }
  175.  
  176. public static byte getMiniBlockCount(ItemStack stack, byte original)
  177. {
  178. return original;
  179. }
  180.  
  181. public static byte getMiniItemCount(ItemStack stack, byte original)
  182. {
  183. return original;
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement