Advertisement
Cmonster910

TNT render

Jun 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. package com.Cmonster.OreMod.client;
  2.  
  3. import com.Cmonster.OreMod.entities.EntityJohn_tnt;
  4.  
  5. import init.ModBlocks;
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.client.renderer.BlockRendererDispatcher;
  8. import net.minecraft.client.renderer.GlStateManager;
  9. import net.minecraft.client.renderer.entity.Render;
  10. import net.minecraft.client.renderer.entity.RenderManager;
  11. import net.minecraft.client.renderer.texture.TextureMap;
  12. import net.minecraft.init.Blocks;
  13. import net.minecraft.util.ResourceLocation;
  14. import net.minecraft.util.math.MathHelper;
  15. import net.minecraftforge.fml.relauncher.Side;
  16. import net.minecraftforge.fml.relauncher.SideOnly;
  17.  
  18. @SideOnly(Side.CLIENT)
  19. public class RenderJohnny_tnt extends Render<EntityJohn_tnt>
  20. {
  21. public RenderJohnny_tnt(RenderManager renderManagerIn)
  22. {
  23. super(renderManagerIn);
  24. this.shadowSize = 0.5F;
  25. }
  26.  
  27. /**
  28. * Renders the desired {@code T} type Entity.
  29. */
  30. public void doRender(EntityJohn_tnt entity, double x, double y, double z, float entityYaw, float partialTicks)
  31. {
  32. BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
  33. GlStateManager.pushMatrix();
  34. GlStateManager.translate((float)x, (float)y + 0.5F, (float)z);
  35.  
  36. if ((float)entity.getFuse() - partialTicks + 1.0F < 10.0F)
  37. {
  38. float f = 1.0F - ((float)entity.getFuse() - partialTicks + 1.0F) / 10.0F;
  39. f = MathHelper.clamp(f, 0.0F, 1.0F);
  40. f = f * f;
  41. f = f * f;
  42. float f1 = 1.0F + f * 0.3F;
  43. GlStateManager.scale(f1, f1, f1);
  44. }
  45.  
  46. float f2 = (1.0F - ((float)entity.getFuse() - partialTicks + 1.0F) / 100.0F) * 0.8F;
  47. this.bindEntityTexture(entity);
  48. GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
  49. GlStateManager.translate(-0.5F, -0.5F, 0.5F);
  50. blockrendererdispatcher.renderBlockBrightness(ModBlocks.johnny_tnt.getDefaultState(), entity.getBrightness(partialTicks));
  51. GlStateManager.translate(0.0F, 0.0F, 1.0F);
  52.  
  53. if (this.renderOutlines)
  54. {
  55. GlStateManager.enableColorMaterial();
  56. GlStateManager.enableOutlineMode(this.getTeamColor(entity));
  57. blockrendererdispatcher.renderBlockBrightness(ModBlocks.johnny_tnt.getDefaultState(), 1.0F);
  58. GlStateManager.disableOutlineMode();
  59. GlStateManager.disableColorMaterial();
  60. }
  61. else if (entity.getFuse() / 5 % 2 == 0)
  62. {
  63. GlStateManager.disableTexture2D();
  64. GlStateManager.disableLighting();
  65. GlStateManager.enableBlend();
  66. GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.DST_ALPHA);
  67. GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
  68. GlStateManager.doPolygonOffset(-3.0F, -3.0F);
  69. GlStateManager.enablePolygonOffset();
  70. blockrendererdispatcher.renderBlockBrightness(ModBlocks.johnny_tnt.getDefaultState(), 1.0F);
  71. GlStateManager.doPolygonOffset(0.0F, 0.0F);
  72. GlStateManager.disablePolygonOffset();
  73. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  74. GlStateManager.disableBlend();
  75. GlStateManager.enableLighting();
  76. GlStateManager.enableTexture2D();
  77. }
  78.  
  79. GlStateManager.popMatrix();
  80. super.doRender(entity, x, y, z, entityYaw, partialTicks);
  81. }
  82.  
  83. /**
  84. * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
  85. */
  86. @Override
  87. protected ResourceLocation getEntityTexture(EntityJohn_tnt entity)
  88. {
  89. return TextureMap.LOCATION_BLOCKS_TEXTURE;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement