package micdoodle8.mods.galacticraft.planets.mars.client.fx;
import micdoodle8.mods.galacticraft.api.vector.Vector3;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EntityCryoFX extends EntityFX
{
float field_70569_a;
public EntityCryoFX(World worldIn, Vector3 position, Vector3 motion)
{
super(worldIn, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D);
float f = 2.5F;
this.motionX *= 0.0;
this.motionY *= 0.10000000149011612;
this.motionZ *= 0.0;
this.motionX += motion.x;
this.motionY += motion.y;
this.motionZ += motion.z;
this.particleRed = this.particleGreen = this.particleBlue = 1.0F - (float) (Math.random() * 0.30000001192092896D);
this.particleRed *= 0.8F;
this.particleGreen *= 0.8F;
this.particleScale *= 0.25F;
this.particleScale *= f;
this.field_70569_a = this.particleScale;
this.particleMaxAge = (int) (8.0D / (Math.random() * 0.8D + 0.3D));
this.particleMaxAge = (int) ((float) this.particleMaxAge * f);
this.noClip = true;
}
/**
* Renders the particle
*/
@Override
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{
float f = ((float) this.particleAge + partialTicks) / (float) this.particleMaxAge * 32.0F;
f = MathHelper.clamp_float(f, 0.0F, 1.0F);
this.particleScale = this.field_70569_a * f;
super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9599999785423279D;
this.motionY *= 0.9599999785423279D;
this.motionZ *= 0.9599999785423279D;
EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 2.0D);
if (entityplayer != null && this.posY > entityplayer.getEntityBoundingBox().minY)
{
this.posY += (entityplayer.getEntityBoundingBox().minY - this.posY) * 0.2D;
this.motionY += (entityplayer.motionY - this.motionY) * 0.2D;
this.setPosition(this.posX, this.posY, this.posZ);
}
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
}
}