303

Untitled

303
Mar 21st, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.34 KB | None | 0 0
  1. package net.minecraft.src;
  2. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  3. // Jad home page: http://www.kpdus.com/jad.html
  4. // Decompiler options: packimports(3) braces deadcode
  5.  
  6. import java.util.Random;
  7.  
  8. public class _FireworksFX extends EntityFX {
  9.     int type;
  10.     double color;
  11.     double something;
  12.  
  13.     public _FireworksFX(World world, double d, double d1, double d2,
  14.             double type1, double color1, double something1) {
  15.         super(world, d, d1, d2, 0, 0, 0);
  16.         motionX *= 0.80000001192092896D;
  17.         motionY *= 0.80000001192092896D;
  18.         motionZ *= 0.80000001192092896D;
  19.         motionY = rand.nextFloat() * 0.4F + 0.05F;
  20.         d += (rand.nextFloat() - rand.nextFloat()) * 0.05F;
  21.         d1 += (rand.nextFloat() - rand.nextFloat()) * 0.05F;
  22.         d2 += (rand.nextFloat() - rand.nextFloat()) * 0.05F;
  23.         field_672_a = particleScale;
  24.         renderDistanceWeight = 100D;
  25.         type = (int) type1;
  26.         color = color1;
  27.         something = something1;
  28.         //@Override
  29.         //super isInRangeToRenderDist(100000000);
  30.         double red, green, blue;
  31.  
  32.         if(color == 0) { // white
  33.             red = 1;
  34.             green = 1;
  35.             blue = 1;
  36.         } else if(color == 1) { // random
  37.             red = Math.random();
  38.             green = Math.random();
  39.             blue = Math.random();
  40.         }
  41.  
  42.         double change = 1+ (something/300); //something/20 + Math.random()/20;
  43.         //System.out.println(something);
  44.         particleRed = (float) (red*change);
  45.         particleGreen = (float) (green*change);
  46.         particleBlue = (float) (blue*change);
  47.         particleTextureIndex = (int)(Math.random() * 8D);
  48.  
  49.         if(type == 0) {
  50.             setupSkyrocket(world, d, d1, d2, something);
  51.         } else if(type == 1) {
  52.             setupSubrocket(world, d, d1, d2, something);
  53.         } else if(type == 2) {
  54.             setupSpark(world, d, d1, d2, something);
  55.         }
  56.     }
  57.  
  58.  
  59.     {
  60.         /*
  61.            double d1 = boundingBox.getAverageEdgeLength() * 4D;
  62.            d1 *= 64D;
  63.            return d < d1 * d1;
  64.            */
  65.         return true;
  66.     }
  67.  
  68.  
  69.  
  70.  
  71.     // The type determines what kind of thing it is.
  72.     // They have their own 'constructors'
  73.     // 0 is the skyrocket flying up
  74.     // 1 is one of the clusterthings (Subrocket) shooting in all directions
  75.     // 2 is sparks, left behind by skyrockets and clusterthings
  76.  
  77.     private void setupSkyrocket(World world, double d, double d1, double d2, double something) {
  78.         motionY = 0.5F;
  79.         particleMaxAge = (int) 10;//(Math.random()*30D);
  80.         noClip = false;
  81.         //motionX = motionX + (Math.random()-05)/10;
  82.         //motionZ = motionZ + (Math.random()-05)/10;
  83.     }
  84.  
  85.     private void setupSubrocket(World world, double d, double d1, double d2, double something) {
  86.         particleMaxAge = (int) (Math.random()*2+6);
  87.         noClip = false;
  88.         motionX = (Math.random()-0.5)*2;
  89.         motionY = (Math.random()-0.5)*2;
  90.         motionZ = (Math.random()-0.5)*2;
  91.         field_672_a = 0.9F;
  92.     }
  93.  
  94.     private void setupSpark(World world, double d, double d1, double d2, double something) {
  95.         particleMaxAge = (int)(something/3); //(10D + (Math.random() * 30) +
  96.         noClip = true;
  97.         //int dirX = (Math.random()-0.5)
  98.         motionX = Math.random()/100;
  99.         motionY = Math.random()/100;
  100.         motionZ = Math.random()/100;
  101.         field_672_a = 0.6F + (float) ((Math.random()-0.5)/100);
  102.         super.particleGravity = -1F;
  103.     }
  104.  
  105.  
  106.     public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
  107.         float f6 = ((float)particleAge + f) / (float)particleMaxAge;
  108.         particleScale = field_672_a * (1.0F - f6 * f6 * 0.5F);
  109.  
  110.         if(type == 0) { // the skyrocket doesn't shrink.
  111.             particleScale = 2;
  112.         }
  113.  
  114.         super.renderParticle(tessellator, f, f1, f2, f3, f4, f5);
  115.     }
  116.  
  117.     public float getEntityBrightness(float f) {
  118.         return 1.0F;
  119.     }
  120.  
  121.     public void onUpdate() {
  122.         something++;
  123.         prevPosX = posX;
  124.         prevPosY = posY;
  125.         prevPosZ = posZ;
  126.         moveEntity(motionX, motionY, motionZ);
  127.         particleRed *= 1.02;
  128.         particleGreen *= 0.999;
  129.         particleBlue *= 1.01;
  130.  
  131.         if(particleAge++ >= particleMaxAge || posY >= 123 ) {
  132.             if(type == 0) {
  133.                 for(int a = 0; a < 100; a++) {
  134.                     worldObj.spawnParticle("fireworks", posX, posY, posZ, 1, color, 5);
  135.                 }
  136.  
  137.                 System.out.println("KABOEM!");
  138.                 worldObj.createExplosion(null, posX, posY, posZ, 0F);
  139.             }
  140.  
  141.             setEntityDead();
  142.         }
  143.  
  144.         if(type == 1) {
  145.             worldObj.spawnParticle("fireworks", posX, posY, posZ, 2, color, something);
  146.             double subPosX = prevPosX;
  147.             double subPosY = prevPosY;
  148.             double subPosZ = prevPosZ;
  149.  
  150.             for(int teller = 1; teller < 11; teller++) {
  151.                 //System.out.println(posX-prevPosX);
  152.                 subPosX += ((posX-prevPosX)/10);
  153.                 subPosY += ((posY-prevPosY)/10);
  154.                 subPosZ += ((posZ-prevPosZ)/10);
  155.                 worldObj.spawnParticle("fireworks", subPosX, subPosY, subPosZ, 2, color, something);
  156.                 something++;
  157.             }
  158.         } else if(type == 0) {
  159.             worldObj.spawnParticle("fireworks", posX, (posY-0.2), posZ, 2, color, 50);
  160.             worldObj.spawnParticle("fireworks", posX, (posY-0.4), posZ, 2, color, 50);
  161.             worldObj.spawnParticle("fireworks", posX, (posY-0.7), posZ, 2, color, 50);
  162.         }
  163.  
  164.         float f = (float)particleAge / (float)particleMaxAge;
  165.  
  166.         if(rand.nextFloat() > f) {
  167.             //worldObj.spawnParticle("smoke", posX, posY, posZ, motionX, motionY, motionZ);
  168.         }
  169.  
  170.         if(!(type == 2)) {
  171.             motionY -= 0.005D;
  172.         }
  173.  
  174.         if(type == 0) {
  175.             motionY *= 1.15D;
  176.         }
  177.  
  178.         if(type == 1) {
  179.             motionY -= 0.1;
  180.         }
  181.  
  182.         motionX *= 0.99900001287460327D;
  183.         motionY *= 0.99900001287460327D;
  184.         motionZ *= 0.99900001287460327D;
  185.  
  186.         if(onGround) {
  187.             motionY *= -0.7D;
  188.             motionX *= 0.5D;
  189.             motionZ *= 0.5D;
  190.         }
  191.     }
  192.  
  193.     private float field_672_a;
  194. }
Advertisement
Add Comment
Please, Sign In to add comment