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.world.World;
007
008 @SideOnly(Side.CLIENT)
009 public class EntityLavaFX extends EntityFX
010 {
011 private float lavaParticleScale;
012
013 public EntityLavaFX(World par1World, double par2, double par4, double par6)
014 {
015 super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
016 this.motionX *= 0.800000011920929D;
017 this.motionY *= 0.800000011920929D;
018 this.motionZ *= 0.800000011920929D;
019 this.motionY = (double)(this.rand.nextFloat() * 0.4F + 0.05F);
020 this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
021 this.particleScale *= this.rand.nextFloat() * 2.0F + 0.2F;
022 this.lavaParticleScale = this.particleScale;
023 this.particleMaxAge = (int)(16.0D / (Math.random() * 0.8D + 0.2D));
024 this.noClip = false;
025 this.setParticleTextureIndex(49);
026 }
027
028 public int getBrightnessForRender(float par1)
029 {
030 float var2 = ((float)this.particleAge + par1) / (float)this.particleMaxAge;
031
032 if (var2 < 0.0F)
033 {
034 var2 = 0.0F;
035 }
036
037 if (var2 > 1.0F)
038 {
039 var2 = 1.0F;
040 }
041
042 int var3 = super.getBrightnessForRender(par1);
043 short var4 = 240;
044 int var5 = var3 >> 16 & 255;
045 return var4 | var5 << 16;
046 }
047
048 /**
049 * Gets how bright this entity is.
050 */
051 public float getBrightness(float par1)
052 {
053 return 1.0F;
054 }
055
056 public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
057 {
058 float var8 = ((float)this.particleAge + par2) / (float)this.particleMaxAge;
059 this.particleScale = this.lavaParticleScale * (1.0F - var8 * var8);
060 super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
061 }
062
063 /**
064 * Called to update the entity's position/logic.
065 */
066 public void onUpdate()
067 {
068 this.prevPosX = this.posX;
069 this.prevPosY = this.posY;
070 this.prevPosZ = this.posZ;
071
072 if (this.particleAge++ >= this.particleMaxAge)
073 {
074 this.setDead();
075 }
076
077 float var1 = (float)this.particleAge / (float)this.particleMaxAge;
078
079 if (this.rand.nextFloat() > var1)
080 {
081 this.worldObj.spawnParticle("smoke", this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ);
082 }
083
084 this.motionY -= 0.03D;
085 this.moveEntity(this.motionX, this.motionY, this.motionZ);
086 this.motionX *= 0.9990000128746033D;
087 this.motionY *= 0.9990000128746033D;
088 this.motionZ *= 0.9990000128746033D;
089
090 if (this.onGround)
091 {
092 this.motionX *= 0.699999988079071D;
093 this.motionZ *= 0.699999988079071D;
094 }
095 }
096 }