Guest User

Untitled

a guest
Feb 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. //FireworksParticle
  2.  
  3. package net.minecraft.src;
  4.  
  5. public class FireworksParticle extends EntityFX {
  6. double redDiff, greenDiff, blueDiff;
  7. private float field_672_a; // I think this is the size of the particle
  8.  
  9. //constructor
  10. public FireworksParticle(World world, double x, double y, double z, double r, double g, double b, double rT, double gT, double bT, int maxAge, float particleSize)
  11. {
  12. super(world, x, y, z, 0, 0, 0);
  13. super.particleGravity = -1F;
  14. field_672_a = particleSize + (float) ((Math.random() - 0.5) / 100);
  15. setSize(1f, 1f);
  16. noClip = true;
  17.  
  18. particleMaxAge = maxAge;
  19.  
  20. motionX = Math.random() / 100; // small random movement
  21. motionY = Math.random() / 100;
  22. motionZ = Math.random() / 100;
  23.  
  24. particleRed = (float) r;
  25. particleGreen = (float) g;
  26. particleBlue = (float) b;
  27.  
  28.  
  29. // calculate diffence between current color and target color
  30. // difference per update
  31. redDiff = (rT - r)/ maxAge;
  32. greenDiff = (gT - g)/ maxAge;
  33. blueDiff = (bT - b)/ maxAge;
  34.  
  35. particleTextureIndex = (int) (4 + Math.random() * 4D);
  36. }
  37.  
  38. public void renderParticle(Tessellator tessellator, float f, float f1,
  39. float f2, float f3, float f4, float f5) {
  40. float f6 = ((float) particleAge + f) / (float) particleMaxAge;
  41. particleScale = field_672_a * (1.0F - f6 * f6 * 0.5F);
  42. super.renderParticle(tessellator, f, f1, f2, f3, f4, f5);
  43. }
  44.  
  45. public float getEntityBrightness(float f) {
  46. return 2.0F;
  47. }
  48.  
  49. public void onUpdate() {
  50.  
  51. if (particleAge >= particleMaxAge) { // nobody lives beyond its time
  52. setEntityDead();
  53. }
  54.  
  55. // remember your old coordinates
  56. prevPosX = posX;
  57. prevPosY = posY;
  58. prevPosZ = posZ;
  59.  
  60. // and move your body
  61. moveEntity(motionX, motionY, motionZ);
  62.  
  63. // become old
  64. particleAge++;
  65.  
  66. // slowly change color
  67. particleRed += redDiff;
  68. particleGreen += greenDiff;
  69. particleBlue += blueDiff;
  70.  
  71. // you can't swim
  72. if (inWater) {
  73. setEntityDead();
  74. }
  75. }
  76.  
  77. }
Add Comment
Please, Sign In to add comment