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.block.BlockFluid; 006 import net.minecraft.block.material.Material; 007 import net.minecraft.util.MathHelper; 008 import net.minecraft.world.World; 009 010 @SideOnly(Side.CLIENT) 011 public class EntityRainFX extends EntityFX 012 { 013 public EntityRainFX(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.30000001192092896D; 017 this.motionY = (double)((float)Math.random() * 0.2F + 0.1F); 018 this.motionZ *= 0.30000001192092896D; 019 this.particleRed = 1.0F; 020 this.particleGreen = 1.0F; 021 this.particleBlue = 1.0F; 022 this.setParticleTextureIndex(19 + this.rand.nextInt(4)); 023 this.setSize(0.01F, 0.01F); 024 this.particleGravity = 0.06F; 025 this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); 026 } 027 028 /** 029 * Called to update the entity's position/logic. 030 */ 031 public void onUpdate() 032 { 033 this.prevPosX = this.posX; 034 this.prevPosY = this.posY; 035 this.prevPosZ = this.posZ; 036 this.motionY -= (double)this.particleGravity; 037 this.moveEntity(this.motionX, this.motionY, this.motionZ); 038 this.motionX *= 0.9800000190734863D; 039 this.motionY *= 0.9800000190734863D; 040 this.motionZ *= 0.9800000190734863D; 041 042 if (this.particleMaxAge-- <= 0) 043 { 044 this.setDead(); 045 } 046 047 if (this.onGround) 048 { 049 if (Math.random() < 0.5D) 050 { 051 this.setDead(); 052 } 053 054 this.motionX *= 0.699999988079071D; 055 this.motionZ *= 0.699999988079071D; 056 } 057 058 Material var1 = this.worldObj.getBlockMaterial(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); 059 060 if (var1.isLiquid() || var1.isSolid()) 061 { 062 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)))); 063 064 if (this.posY < var2) 065 { 066 this.setDead(); 067 } 068 } 069 } 070 }