001 package net.minecraft.src;
002
003 import cpw.mods.fml.common.Side;
004 import cpw.mods.fml.common.asm.SideOnly;
005
006 @SideOnly(Side.CLIENT)
007 public class EntityDropParticleFX extends EntityFX
008 {
009 /** the material type for dropped items/blocks */
010 private Material materialType;
011
012 /** The height of the current bob */
013 private int bobTimer;
014
015 public EntityDropParticleFX(World par1World, double par2, double par4, double par6, Material par8Material)
016 {
017 super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
018 this.motionX = this.motionY = this.motionZ = 0.0D;
019
020 if (par8Material == Material.water)
021 {
022 this.particleRed = 0.0F;
023 this.particleGreen = 0.0F;
024 this.particleBlue = 1.0F;
025 }
026 else
027 {
028 this.particleRed = 1.0F;
029 this.particleGreen = 0.0F;
030 this.particleBlue = 0.0F;
031 }
032
033 this.setParticleTextureIndex(113);
034 this.setSize(0.01F, 0.01F);
035 this.particleGravity = 0.06F;
036 this.materialType = par8Material;
037 this.bobTimer = 40;
038 this.particleMaxAge = (int)(64.0D / (Math.random() * 0.8D + 0.2D));
039 this.motionX = this.motionY = this.motionZ = 0.0D;
040 }
041
042 public int getBrightnessForRender(float par1)
043 {
044 return this.materialType == Material.water ? super.getBrightnessForRender(par1) : 257;
045 }
046
047 /**
048 * Gets how bright this entity is.
049 */
050 public float getBrightness(float par1)
051 {
052 return this.materialType == Material.water ? super.getBrightness(par1) : 1.0F;
053 }
054
055 /**
056 * Called to update the entity's position/logic.
057 */
058 public void onUpdate()
059 {
060 this.prevPosX = this.posX;
061 this.prevPosY = this.posY;
062 this.prevPosZ = this.posZ;
063
064 if (this.materialType == Material.water)
065 {
066 this.particleRed = 0.2F;
067 this.particleGreen = 0.3F;
068 this.particleBlue = 1.0F;
069 }
070 else
071 {
072 this.particleRed = 1.0F;
073 this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16);
074 this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8);
075 }
076
077 this.motionY -= (double)this.particleGravity;
078
079 if (this.bobTimer-- > 0)
080 {
081 this.motionX *= 0.02D;
082 this.motionY *= 0.02D;
083 this.motionZ *= 0.02D;
084 this.setParticleTextureIndex(113);
085 }
086 else
087 {
088 this.setParticleTextureIndex(112);
089 }
090
091 this.moveEntity(this.motionX, this.motionY, this.motionZ);
092 this.motionX *= 0.9800000190734863D;
093 this.motionY *= 0.9800000190734863D;
094 this.motionZ *= 0.9800000190734863D;
095
096 if (this.particleMaxAge-- <= 0)
097 {
098 this.setDead();
099 }
100
101 if (this.onGround)
102 {
103 if (this.materialType == Material.water)
104 {
105 this.setDead();
106 this.worldObj.spawnParticle("splash", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
107 }
108 else
109 {
110 this.setParticleTextureIndex(114);
111 }
112
113 this.motionX *= 0.699999988079071D;
114 this.motionZ *= 0.699999988079071D;
115 }
116
117 Material var1 = this.worldObj.getBlockMaterial(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ));
118
119 if (var1.isLiquid() || var1.isSolid())
120 {
121 double var2 = (double)((float)(MathHelper.floor_double(this.posY) + 1) - BlockFluid.getFluidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))));
122
123 if (this.posY < var2)
124 {
125 this.setDead();
126 }
127 }
128 }
129 }