Advertisement
Guest User

RenderFlames

a guest
Jul 1st, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. package swords.entity;
  2.  
  3. import net.minecraft.client.renderer.RenderHelper;
  4. import net.minecraft.client.renderer.Tessellator;
  5. import net.minecraft.client.renderer.entity.Render;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.projectile.EntityFireball;
  8. import net.minecraft.util.MathHelper;
  9. import net.minecraft.util.ResourceLocation;
  10.  
  11. import org.lwjgl.opengl.GL11;
  12.  
  13. import cpw.mods.fml.relauncher.Side;
  14. import cpw.mods.fml.relauncher.SideOnly;
  15.  
  16. @SideOnly(Side.CLIENT)
  17. public class RenderFlames extends Render
  18. {
  19. private static final ResourceLocation flames = new ResourceLocation("swordsmod:textures/entity/fire_beam.png");
  20. private float field_77002_a;
  21.  
  22. public RenderFlames(float par1)
  23. {
  24. this.field_77002_a = par1;
  25. }
  26.  
  27. public void doRenderFlames(EntityFlames entityflames, double relX, double relY, double relZ, double centerX, double centerY, double centerZ, double targetX, double targetY, double targetZ, float tickStuff)
  28. {
  29. float f2 = 50000;
  30. float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F;
  31. f3 = (f3 * f3 + f3) * 0.2F;
  32. float wayX = (float) (targetX - centerX);
  33. float wayY = (float) (targetY - centerY);
  34. float wayZ = (float) (targetZ - centerZ);
  35. float distFlat = MathHelper.sqrt_float(wayX * wayX + wayZ * wayZ);
  36. float dist = MathHelper.sqrt_float(wayX * wayX + wayY * wayY + wayZ * wayZ);
  37. GL11.glPushMatrix();
  38. GL11.glTranslatef((float) relX, (float) relY, (float) relZ);
  39. GL11.glRotatef((float) (-Math.atan2(wayZ, wayX)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
  40. GL11.glRotatef((float) (-Math.atan2(distFlat, wayY)) * 180.0F / (float) Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
  41. Tessellator tessellator = Tessellator.instance;
  42. RenderHelper.disableStandardItemLighting();
  43. GL11.glDisable(GL11.GL_CULL_FACE);
  44. this.bindEntityTexture(entityflames);
  45. this.bindTexture(flames);
  46. GL11.glColor3d(1.0F, 0.0F, 0.0F);
  47. GL11.glShadeModel(GL11.GL_SMOOTH);
  48. float f9 = -(tickStuff * 0.005F);
  49. float f10 = MathHelper.sqrt_float(wayX * wayX + wayY * wayY + wayZ * wayZ) / 32.0F + f9;
  50. tessellator.startDrawing(5);
  51. //Add all 2*8 vertex/corners
  52. byte b0 = 8;
  53. for (int i = 0; i <= b0; ++i)
  54. {
  55. float f11 = 0.2F * (MathHelper.sin(i % b0 * (float) Math.PI * 2.0F / b0) * 0.75F);
  56. float f12 = 0.2F * (MathHelper.cos(i % b0 * (float) Math.PI * 2.0F / b0) * 0.75F);
  57. float f13 = i % b0 * 1.0F / b0;
  58. tessellator.setColorOpaque(255, 0, 0);
  59. tessellator.addVertexWithUV((f11), (f12), 0.0D, f13, f10);
  60. tessellator.setColorOpaque_I(16777215);
  61. tessellator.addVertexWithUV(f11, f12, dist, f13, f9);
  62. }
  63.  
  64. tessellator.draw();
  65. GL11.glEnable(GL11.GL_CULL_FACE);
  66. GL11.glShadeModel(GL11.GL_FLAT);
  67. RenderHelper.enableStandardItemLighting();
  68. GL11.glPopMatrix();
  69. }
  70.  
  71. protected ResourceLocation getEntityTexture(Entity par1Entity)
  72. {
  73. return flames;
  74. }
  75.  
  76. public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
  77. {
  78. this.doRenderFlames((EntityFlames)par1Entity, par2, par4, par6, par8, par9, par6, par6, par6, par6, par9);
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement