    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import org.lwjgl.opengl.GL11;
    006
    007    @SideOnly(Side.CLIENT)
    008    public class RenderMinecart extends Render
    009    {
    010        /** instance of ModelMinecart for rendering */
    011        protected ModelBase modelMinecart;
    012
    013        public RenderMinecart()
    014        {
    015            this.shadowSize = 0.5F;
    016            this.modelMinecart = new ModelMinecart();
    017        }
    018
    019        /**
    020         * Renders the Minecart.
    021         */
    022        public void renderTheMinecart(EntityMinecart par1EntityMinecart, double par2, double par4, double par6, float par8, float par9)
    023        {
    024            GL11.glPushMatrix();
    025            long var10 = (long)par1EntityMinecart.entityId * 493286711L;
    026            var10 = var10 * var10 * 4392167121L + var10 * 98761L;
    027            float var12 = (((float)(var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    028            float var13 = (((float)(var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    029            float var14 = (((float)(var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    030            GL11.glTranslatef(var12, var13, var14);
    031            double var15 = par1EntityMinecart.lastTickPosX + (par1EntityMinecart.posX - par1EntityMinecart.lastTickPosX) * (double)par9;
    032            double var17 = par1EntityMinecart.lastTickPosY + (par1EntityMinecart.posY - par1EntityMinecart.lastTickPosY) * (double)par9;
    033            double var19 = par1EntityMinecart.lastTickPosZ + (par1EntityMinecart.posZ - par1EntityMinecart.lastTickPosZ) * (double)par9;
    034            double var21 = 0.30000001192092896D;
    035            Vec3 var23 = par1EntityMinecart.func_70489_a(var15, var17, var19);
    036            float var24 = par1EntityMinecart.prevRotationPitch + (par1EntityMinecart.rotationPitch - par1EntityMinecart.prevRotationPitch) * par9;
    037
    038            if (var23 != null)
    039            {
    040                Vec3 var25 = par1EntityMinecart.func_70495_a(var15, var17, var19, var21);
    041                Vec3 var26 = par1EntityMinecart.func_70495_a(var15, var17, var19, -var21);
    042
    043                if (var25 == null)
    044                {
    045                    var25 = var23;
    046                }
    047
    048                if (var26 == null)
    049                {
    050                    var26 = var23;
    051                }
    052
    053                par2 += var23.xCoord - var15;
    054                par4 += (var25.yCoord + var26.yCoord) / 2.0D - var17;
    055                par6 += var23.zCoord - var19;
    056                Vec3 var27 = var26.addVector(-var25.xCoord, -var25.yCoord, -var25.zCoord);
    057
    058                if (var27.lengthVector() != 0.0D)
    059                {
    060                    var27 = var27.normalize();
    061                    par8 = (float)(Math.atan2(var27.zCoord, var27.xCoord) * 180.0D / Math.PI);
    062                    var24 = (float)(Math.atan(var27.yCoord) * 73.0D);
    063                }
    064            }
    065
    066            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
    067            GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
    068            GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F);
    069            float var28 = (float)par1EntityMinecart.func_70496_j() - par9;
    070            float var30 = (float)par1EntityMinecart.getDamage() - par9;
    071
    072            if (var30 < 0.0F)
    073            {
    074                var30 = 0.0F;
    075            }
    076
    077            if (var28 > 0.0F)
    078            {
    079                GL11.glRotatef(MathHelper.sin(var28) * var28 * var30 / 10.0F * (float)par1EntityMinecart.func_70493_k(), 1.0F, 0.0F, 0.0F);
    080            }
    081
    082            if (par1EntityMinecart.minecartType != 0)
    083            {
    084                this.loadTexture("/terrain.png");
    085                float var29 = 0.75F;
    086                GL11.glScalef(var29, var29, var29);
    087
    088                if (par1EntityMinecart.minecartType == 1)
    089                {
    090                    GL11.glTranslatef(0.0F, 0.5F, 0.0F);
    091                    (new RenderBlocks()).renderBlockAsItem(Block.chest, 0, par1EntityMinecart.getBrightness(par9));
    092                    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    093                    GL11.glTranslatef(0.5F, 0.0F, -0.5F);
    094                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    095                }
    096                else if (par1EntityMinecart.minecartType == 2)
    097                {
    098                    GL11.glTranslatef(0.0F, 0.3125F, 0.0F);
    099                    (new RenderBlocks()).renderBlockAsItem(Block.stoneOvenIdle, 0, par1EntityMinecart.getBrightness(par9));
    100                    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    101                    GL11.glTranslatef(0.0F, -0.3125F, 0.0F);
    102                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    103                }
    104
    105                GL11.glScalef(1.0F / var29, 1.0F / var29, 1.0F / var29);
    106            }
    107
    108            this.loadTexture("/item/cart.png");
    109            GL11.glScalef(-1.0F, -1.0F, 1.0F);
    110            this.modelMinecart.render(par1EntityMinecart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    111            GL11.glPopMatrix();
    112        }
    113
    114        /**
    115         * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    116         * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    117         * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    118         * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    119         */
    120        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    121        {
    122            this.renderTheMinecart((EntityMinecart)par1Entity, par2, par4, par6, par8, par9);
    123        }
    124    }