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