Guest User

ParticleFX

a guest
Feb 12th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.92 KB | None | 0 0
  1. package com.anim8.gscraft.particles;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.client.particle.EntityFX;
  6. import net.minecraft.client.renderer.Tessellator;
  7. import net.minecraft.world.World;
  8.  
  9. @SideOnly(Side.CLIENT)
  10. public class EntityWhirlwindDustFX extends EntityFX
  11. {
  12.     float particleScaleOverTime;
  13.    
  14.     private double entityCentreX, entityCentreY, entityCentreZ, distToCentre, secondsPerRevolution;
  15.     private float tickCount;
  16.    
  17.     public EntityWhirlwindDustFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, double centreX, double centreY, double centreZ, double secs4Rev)
  18.     {
  19.         this(par1World, par2, par4, par6, par8, par10, par12, 1.0F, centreX, centreY, centreZ, secs4Rev);
  20.     }
  21.  
  22.     public EntityWhirlwindDustFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14, double centreX, double centreY, double centreZ, double secs4Rev)
  23.     {
  24.         super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
  25.        
  26.         this.secondsPerRevolution = secs4Rev;
  27.        
  28.         this.entityCentreX = centreX;
  29.         this.entityCentreY = centreY;
  30.         this.entityCentreZ = centreZ;
  31.        
  32.         this.distToCentre = Math.sqrt((posX - entityCentreX) * (posX - entityCentreX) + (posZ - entityCentreZ) * (posZ - entityCentreZ));
  33.        
  34.        
  35.         this.particleRed = this.particleGreen = this.particleBlue = (float)(Math.random() * 0.30000001192092896D);
  36.  
  37.         this.particleScale *= 0.75F *2 ;
  38.      
  39.         this.particleScaleOverTime = this.particleScale;
  40.         this.particleMaxAge = 32;
  41.        
  42.        
  43.  
  44.         this.setParticleTextureIndex(7);
  45.     }
  46.  
  47.     public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
  48.     {
  49.         float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F;
  50.  
  51.         if (f6 < 0.0F)
  52.         {
  53.             f6 = 0.0F;
  54.         }
  55.  
  56.         if (f6 > 1.0F)
  57.         {
  58.             f6 = 1.0F;
  59.         }
  60.  
  61.         this.particleScale = this.particleScaleOverTime * f6;
  62.         super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
  63.     }
  64.  
  65.    
  66.     public void onUpdate()
  67.     {
  68.         float maxAgeOverTime = this.particleAge / particleMaxAge;
  69.        
  70.         this.prevPosX = this.posX;
  71.         this.prevPosY = this.posY;
  72.         this.prevPosZ = this.posZ;
  73.  
  74.         if (this.particleAge++ >= this.particleMaxAge)
  75.         {
  76.             tickCount = 0;
  77.             this.setDead();
  78.         }
  79.        
  80.  
  81.      
  82.         tickCount++;
  83.         this.posX = this.entityCentreX + distToCentre * Math.cos(2 * 3.141 * (tickCount / 20) / secondsPerRevolution);
  84.         this.posZ = this.entityCentreZ + distToCentre * Math.sin(2 * 3.141 * (tickCount / 20) / secondsPerRevolution);
  85.        
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment