    001package net.minecraft.client.particle;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.renderer.OpenGlHelper;
    006import net.minecraft.client.renderer.Tessellator;
    007import net.minecraft.client.renderer.entity.RenderManager;
    008import net.minecraft.entity.Entity;
    009import net.minecraft.util.MathHelper;
    010import net.minecraft.world.World;
    011import org.lwjgl.opengl.GL11;
    012
    013@SideOnly(Side.CLIENT)
    014public class EntityPickupFX extends EntityFX
    015{
    016    private Entity entityToPickUp;
    017    private Entity entityPickingUp;
    018    private int age = 0;
    019    private int maxAge = 0;
    020
    021    /** renamed from yOffset to fix shadowing Entity.yOffset */
    022    private float yOffs;
    023
    024    public EntityPickupFX(World par1World, Entity par2Entity, Entity par3Entity, float par4)
    025    {
    026        super(par1World, par2Entity.posX, par2Entity.posY, par2Entity.posZ, par2Entity.motionX, par2Entity.motionY, par2Entity.motionZ);
    027        this.entityToPickUp = par2Entity;
    028        this.entityPickingUp = par3Entity;
    029        this.maxAge = 3;
    030        this.yOffs = par4;
    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.age + par2) / (float)this.maxAge;
    036        var8 *= var8;
    037        double var9 = this.entityToPickUp.posX;
    038        double var11 = this.entityToPickUp.posY;
    039        double var13 = this.entityToPickUp.posZ;
    040        double var15 = this.entityPickingUp.lastTickPosX + (this.entityPickingUp.posX - this.entityPickingUp.lastTickPosX) * (double)par2;
    041        double var17 = this.entityPickingUp.lastTickPosY + (this.entityPickingUp.posY - this.entityPickingUp.lastTickPosY) * (double)par2 + (double)this.yOffs;
    042        double var19 = this.entityPickingUp.lastTickPosZ + (this.entityPickingUp.posZ - this.entityPickingUp.lastTickPosZ) * (double)par2;
    043        double var21 = var9 + (var15 - var9) * (double)var8;
    044        double var23 = var11 + (var17 - var11) * (double)var8;
    045        double var25 = var13 + (var19 - var13) * (double)var8;
    046        int var27 = MathHelper.floor_double(var21);
    047        int var28 = MathHelper.floor_double(var23 + (double)(this.yOffset / 2.0F));
    048        int var29 = MathHelper.floor_double(var25);
    049        int var30 = this.getBrightnessForRender(par2);
    050        int var31 = var30 % 65536;
    051        int var32 = var30 / 65536;
    052        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var31 / 1.0F, (float)var32 / 1.0F);
    053        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    054        var21 -= interpPosX;
    055        var23 -= interpPosY;
    056        var25 -= interpPosZ;
    057        RenderManager.instance.renderEntityWithPosYaw(this.entityToPickUp, (double)((float)var21), (double)((float)var23), (double)((float)var25), this.entityToPickUp.rotationYaw, par2);
    058    }
    059
    060    /**
    061     * Called to update the entity's position/logic.
    062     */
    063    public void onUpdate()
    064    {
    065        ++this.age;
    066
    067        if (this.age == this.maxAge)
    068        {
    069            this.setDead();
    070        }
    071    }
    072
    073    public int getFXLayer()
    074    {
    075        return 3;
    076    }
    077}