001 package net.minecraft.client.particle; 002 003 import cpw.mods.fml.relauncher.Side; 004 import cpw.mods.fml.relauncher.SideOnly; 005 import net.minecraft.client.renderer.Tessellator; 006 import net.minecraft.util.AxisAlignedBB; 007 import net.minecraft.world.World; 008 009 @SideOnly(Side.CLIENT) 010 public class EntityFireworkSparkFX extends EntityFX 011 { 012 private int field_92049_a = 160; 013 private boolean field_92054_ax; 014 private boolean field_92048_ay; 015 private final EffectRenderer field_92047_az; 016 private float field_92050_aA; 017 private float field_92051_aB; 018 private float field_92052_aC; 019 private boolean field_92053_aD; 020 021 public EntityFireworkSparkFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer) 022 { 023 super(par1World, par2, par4, par6); 024 this.motionX = par8; 025 this.motionY = par10; 026 this.motionZ = par12; 027 this.field_92047_az = par14EffectRenderer; 028 this.particleScale *= 0.75F; 029 this.particleMaxAge = 48 + this.rand.nextInt(12); 030 this.noClip = false; 031 } 032 033 public void func_92045_e(boolean par1) 034 { 035 this.field_92054_ax = par1; 036 } 037 038 public void func_92043_f(boolean par1) 039 { 040 this.field_92048_ay = par1; 041 } 042 043 public void func_92044_a(int par1) 044 { 045 float var2 = (float)((par1 & 16711680) >> 16) / 255.0F; 046 float var3 = (float)((par1 & 65280) >> 8) / 255.0F; 047 float var4 = (float)((par1 & 255) >> 0) / 255.0F; 048 float var5 = 1.0F; 049 this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5); 050 } 051 052 public void func_92046_g(int par1) 053 { 054 this.field_92050_aA = (float)((par1 & 16711680) >> 16) / 255.0F; 055 this.field_92051_aB = (float)((par1 & 65280) >> 8) / 255.0F; 056 this.field_92052_aC = (float)((par1 & 255) >> 0) / 255.0F; 057 this.field_92053_aD = true; 058 } 059 060 /** 061 * returns the bounding box for this entity 062 */ 063 public AxisAlignedBB getBoundingBox() 064 { 065 return null; 066 } 067 068 /** 069 * Returns true if this entity should push and be pushed by other entities when colliding. 070 */ 071 public boolean canBePushed() 072 { 073 return false; 074 } 075 076 public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) 077 { 078 if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) 079 { 080 super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); 081 } 082 } 083 084 /** 085 * Called to update the entity's position/logic. 086 */ 087 public void onUpdate() 088 { 089 this.prevPosX = this.posX; 090 this.prevPosY = this.posY; 091 this.prevPosZ = this.posZ; 092 093 if (this.particleAge++ >= this.particleMaxAge) 094 { 095 this.setDead(); 096 } 097 098 if (this.particleAge > this.particleMaxAge / 2) 099 { 100 this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); 101 102 if (this.field_92053_aD) 103 { 104 this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F; 105 this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F; 106 this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F; 107 } 108 } 109 110 this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge)); 111 this.motionY -= 0.004D; 112 this.moveEntity(this.motionX, this.motionY, this.motionZ); 113 this.motionX *= 0.9100000262260437D; 114 this.motionY *= 0.9100000262260437D; 115 this.motionZ *= 0.9100000262260437D; 116 117 if (this.onGround) 118 { 119 this.motionX *= 0.699999988079071D; 120 this.motionZ *= 0.699999988079071D; 121 } 122 123 if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) 124 { 125 EntityFireworkSparkFX var1 = new EntityFireworkSparkFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az); 126 var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue); 127 var1.particleAge = var1.particleMaxAge / 2; 128 129 if (this.field_92053_aD) 130 { 131 var1.field_92053_aD = true; 132 var1.field_92050_aA = this.field_92050_aA; 133 var1.field_92051_aB = this.field_92051_aB; 134 var1.field_92052_aC = this.field_92052_aC; 135 } 136 137 var1.field_92048_ay = this.field_92048_ay; 138 this.field_92047_az.addEffect(var1); 139 } 140 } 141 142 public int getBrightnessForRender(float par1) 143 { 144 return 15728880; 145 } 146 147 /** 148 * Gets how bright this entity is. 149 */ 150 public float getBrightness(float par1) 151 { 152 return 1.0F; 153 } 154 }