    001package net.minecraft.client.renderer.entity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.Random;
    006import net.minecraft.block.Block;
    007import net.minecraft.client.Minecraft;
    008import net.minecraft.client.gui.FontRenderer;
    009import net.minecraft.client.renderer.ItemRenderer;
    010import net.minecraft.client.renderer.RenderBlocks;
    011import net.minecraft.client.renderer.RenderEngine;
    012import net.minecraft.client.renderer.Tessellator;
    013import net.minecraft.entity.Entity;
    014import net.minecraft.entity.item.EntityItem;
    015import net.minecraft.item.Item;
    016import net.minecraft.item.ItemBlock;
    017import net.minecraft.item.ItemStack;
    018import net.minecraft.util.MathHelper;
    019import org.lwjgl.opengl.GL11;
    020import org.lwjgl.opengl.GL12;
    021
    022import net.minecraftforge.client.ForgeHooksClient;
    023
    024@SideOnly(Side.CLIENT)
    025public class RenderItem extends Render
    026{
    027    private RenderBlocks itemRenderBlocks = new RenderBlocks();
    028
    029    /** The RNG used in RenderItem (for bobbing itemstacks on the ground) */
    030    private Random random = new Random();
    031    public boolean field_77024_a = true;
    032
    033    /** Defines the zLevel of rendering of item on GUI. */
    034    public float zLevel = 0.0F;
    035    public static boolean field_82407_g = false;
    036
    037    public RenderItem()
    038    {
    039        this.shadowSize = 0.15F;
    040        this.shadowOpaque = 0.75F;
    041    }
    042
    043    /**
    044     * Renders the item
    045     */
    046    public void doRenderItem(EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9)
    047    {
    048        this.random.setSeed(187L);
    049        ItemStack var10 = par1EntityItem.getEntityItem();
    050
    051        if (var10.getItem() != null)
    052        {
    053            GL11.glPushMatrix();
    054            float var11 = shouldBob() ? MathHelper.sin(((float)par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F;
    055            float var12 = (((float)par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float)Math.PI);
    056            byte var13 = getMiniBlockCountForItemStack(var10);
    057
    058            GL11.glTranslatef((float)par2, (float)par4 + var11, (float)par6);
    059            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    060            int var16;
    061            float var19;
    062            float var20;
    063            float var24;
    064
    065            if (ForgeHooksClient.renderEntityItem(par1EntityItem, var10, var11, var12, random, renderManager.renderEngine, renderBlocks))
    066            {
    067                ;
    068            }
    069            else if (var10.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.blocksList[var10.itemID].getRenderType()))
    070            {
    071                GL11.glRotatef(var12, 0.0F, 1.0F, 0.0F);
    072
    073                if (field_82407_g)
    074                {
    075                    GL11.glScalef(1.25F, 1.25F, 1.25F);
    076                    GL11.glTranslatef(0.0F, 0.05F, 0.0F);
    077                    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    078                }
    079
    080                this.loadTexture(Block.blocksList[var10.itemID].getTextureFile());
    081                float var22 = 0.25F;
    082                var16 = Block.blocksList[var10.itemID].getRenderType();
    083
    084                if (var16 == 1 || var16 == 19 || var16 == 12 || var16 == 2)
    085                {
    086                    var22 = 0.5F;
    087                }
    088
    089                GL11.glScalef(var22, var22, var22);
    090
    091                for (int var23 = 0; var23 < var13; ++var23)
    092                {
    093                    GL11.glPushMatrix();
    094
    095                    if (var23 > 0)
    096                    {
    097                        var24 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var22;
    098                        var19 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var22;
    099                        var20 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var22;
    100                        GL11.glTranslatef(var24, var19, var20);
    101                    }
    102
    103                    var24 = 1.0F;
    104                    this.itemRenderBlocks.renderBlockAsItem(Block.blocksList[var10.itemID], var10.getItemDamage(), var24);
    105                    GL11.glPopMatrix();
    106                }
    107            }
    108            else
    109            {
    110                int var15;
    111                float var17;
    112
    113                if (var10.getItem().requiresMultipleRenderPasses())
    114                {
    115                    if (field_82407_g)
    116                    {
    117                        GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
    118                        GL11.glTranslatef(0.0F, -0.05F, 0.0F);
    119                    }
    120                    else
    121                    {
    122                        GL11.glScalef(0.5F, 0.5F, 0.5F);
    123                    }
    124
    125
    126                    for (var15 = 0; var15 < var10.getItem().getRenderPasses(var10.getItemDamage()); ++var15)
    127                    {
    128                        this.loadTexture(Item.itemsList[var10.itemID].getTextureFile());
    129                        this.random.setSeed(187L);
    130                        var16 = var10.getItem().getIconIndex(var10, var15);
    131                        var17 = 1.0F;
    132
    133                        if (this.field_77024_a)
    134                        {
    135                            int var18 = Item.itemsList[var10.itemID].getColorFromItemStack(var10, var15);
    136                            var19 = (float)(var18 >> 16 & 255) / 255.0F;
    137                            var20 = (float)(var18 >> 8 & 255) / 255.0F;
    138                            float var21 = (float)(var18 & 255) / 255.0F;
    139                            GL11.glColor4f(var19 * var17, var20 * var17, var21 * var17, 1.0F);
    140                            this.func_77020_a(par1EntityItem, var16, var13, par9, var19 * var17, var20 * var17, var21 * var17);
    141                        }
    142                        else
    143                        {
    144                            this.func_77020_a(par1EntityItem, var16, var13, par9, 1.0F, 1.0F, 1.0F);
    145                        }
    146                    }
    147                }
    148                else
    149                {
    150                    if (field_82407_g)
    151                    {
    152                        GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
    153                        GL11.glTranslatef(0.0F, -0.05F, 0.0F);
    154                    }
    155                    else
    156                    {
    157                        GL11.glScalef(0.5F, 0.5F, 0.5F);
    158                    }
    159
    160                    var15 = var10.getIconIndex();
    161
    162                    this.loadTexture(var10.getItem().getTextureFile());
    163
    164                    if (this.field_77024_a)
    165                    {
    166                        var16 = Item.itemsList[var10.itemID].getColorFromItemStack(var10, 0);
    167                        var17 = (float)(var16 >> 16 & 255) / 255.0F;
    168                        var24 = (float)(var16 >> 8 & 255) / 255.0F;
    169                        var19 = (float)(var16 & 255) / 255.0F;
    170                        var20 = 1.0F;
    171                        this.func_77020_a(par1EntityItem, var15, var13, par9, var17 * var20, var24 * var20, var19 * var20);
    172                    }
    173                    else
    174                    {
    175                        this.func_77020_a(par1EntityItem, var15, var13, par9, 1.0F, 1.0F, 1.0F);
    176                    }
    177                }
    178            }
    179
    180            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    181            GL11.glPopMatrix();
    182        }
    183    }
    184
    185    private void func_77020_a(EntityItem par1EntityItem, int par2, int par3, float par4, float par5, float par6, float par7)
    186    {
    187        Tessellator var8 = Tessellator.instance;
    188        float var9 = (float)(par2 % 16 * 16 + 0) / 256.0F;
    189        float var10 = (float)(par2 % 16 * 16 + 16) / 256.0F;
    190        float var11 = (float)(par2 / 16 * 16 + 0) / 256.0F;
    191        float var12 = (float)(par2 / 16 * 16 + 16) / 256.0F;
    192        float var13 = 1.0F;
    193        float var14 = 0.5F;
    194        float var15 = 0.25F;
    195        float var17;
    196
    197        if (this.renderManager.options.fancyGraphics)
    198        {
    199            GL11.glPushMatrix();
    200
    201            if (field_82407_g)
    202            {
    203                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
    204            }
    205            else
    206            {
    207                GL11.glRotatef((((float)par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
    208            }
    209
    210            float var16 = 0.0625F;
    211            var17 = 0.021875F;
    212            ItemStack var18 = par1EntityItem.getEntityItem();
    213            int var19 = var18.stackSize;
    214            byte var24 = getMiniItemCountForItemStack(var18);
    215
    216
    217            GL11.glTranslatef(-var14, -var15, -((var16 + var17) * (float)var24 / 2.0F));
    218
    219            for (int var20 = 0; var20 < var24; ++var20)
    220            {
    221                // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
    222                if (var20 > 0 && shouldSpreadItems())
    223                {
    224                    float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
    225                    float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
    226                    float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
    227                    GL11.glTranslatef(x, y, var16 + var17);
    228                }
    229                else
    230                {
    231                    GL11.glTranslatef(0f, 0f, var16 + var17);
    232                }
    233
    234                this.loadTexture(Item.itemsList[var18.itemID].getTextureFile());
    235
    236                GL11.glColor4f(par5, par6, par7, 1.0F);
    237                ItemRenderer.renderItemIn2D(var8, var10, var11, var9, var12, var16);
    238
    239                if (var18 != null && var18.hasEffect())
    240                {
    241                    GL11.glDepthFunc(GL11.GL_EQUAL);
    242                    GL11.glDisable(GL11.GL_LIGHTING);
    243                    this.renderManager.renderEngine.bindTexture(this.renderManager.renderEngine.getTexture("%blur%/misc/glint.png"));
    244                    GL11.glEnable(GL11.GL_BLEND);
    245                    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    246                    float var21 = 0.76F;
    247                    GL11.glColor4f(0.5F * var21, 0.25F * var21, 0.8F * var21, 1.0F);
    248                    GL11.glMatrixMode(GL11.GL_TEXTURE);
    249                    GL11.glPushMatrix();
    250                    float var22 = 0.125F;
    251                    GL11.glScalef(var22, var22, var22);
    252                    float var23 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
    253                    GL11.glTranslatef(var23, 0.0F, 0.0F);
    254                    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    255                    ItemRenderer.renderItemIn2D(var8, 0.0F, 0.0F, 1.0F, 1.0F, var16);
    256                    GL11.glPopMatrix();
    257                    GL11.glPushMatrix();
    258                    GL11.glScalef(var22, var22, var22);
    259                    var23 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
    260                    GL11.glTranslatef(-var23, 0.0F, 0.0F);
    261                    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
    262                    ItemRenderer.renderItemIn2D(var8, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
    263                    GL11.glPopMatrix();
    264                    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    265                    GL11.glDisable(GL11.GL_BLEND);
    266                    GL11.glEnable(GL11.GL_LIGHTING);
    267                    GL11.glDepthFunc(GL11.GL_LEQUAL);
    268                }
    269            }
    270
    271            GL11.glPopMatrix();
    272        }
    273        else
    274        {
    275            for (int var25 = 0; var25 < par3; ++var25)
    276            {
    277                GL11.glPushMatrix();
    278
    279                if (var25 > 0)
    280                {
    281                    var17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
    282                    float var27 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
    283                    float var26 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
    284                    GL11.glTranslatef(var17, var27, var26);
    285                }
    286
    287                if (!field_82407_g)
    288                {
    289                    GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    290                }
    291
    292                GL11.glColor4f(par5, par6, par7, 1.0F);
    293                var8.startDrawingQuads();
    294                var8.setNormal(0.0F, 1.0F, 0.0F);
    295                var8.addVertexWithUV((double)(0.0F - var14), (double)(0.0F - var15), 0.0D, (double)var9, (double)var12);
    296                var8.addVertexWithUV((double)(var13 - var14), (double)(0.0F - var15), 0.0D, (double)var10, (double)var12);
    297                var8.addVertexWithUV((double)(var13 - var14), (double)(1.0F - var15), 0.0D, (double)var10, (double)var11);
    298                var8.addVertexWithUV((double)(0.0F - var14), (double)(1.0F - var15), 0.0D, (double)var9, (double)var11);
    299                var8.draw();
    300                GL11.glPopMatrix();
    301            }
    302        }
    303    }
    304
    305    /**
    306     * Renders the item's icon or block into the UI at the specified position.
    307     */
    308    public void renderItemIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5)
    309    {
    310        int var6 = par3ItemStack.itemID;
    311        int var7 = par3ItemStack.getItemDamage();
    312        int var8 = par3ItemStack.getIconIndex();
    313        int var10;
    314        float var12;
    315        float var13;
    316        float var16;
    317
    318        if (par3ItemStack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.blocksList[par3ItemStack.itemID].getRenderType()))
    319        {
    320            Block var15 = Block.blocksList[var6];
    321            par2RenderEngine.bindTexture(par2RenderEngine.getTexture(var15.getTextureFile()));
    322            GL11.glPushMatrix();
    323            GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel);
    324            GL11.glScalef(10.0F, 10.0F, 10.0F);
    325            GL11.glTranslatef(1.0F, 0.5F, 1.0F);
    326            GL11.glScalef(1.0F, 1.0F, -1.0F);
    327            GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
    328            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    329            var10 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, 0);
    330            var16 = (float)(var10 >> 16 & 255) / 255.0F;
    331            var12 = (float)(var10 >> 8 & 255) / 255.0F;
    332            var13 = (float)(var10 & 255) / 255.0F;
    333
    334            if (this.field_77024_a)
    335            {
    336                GL11.glColor4f(var16, var12, var13, 1.0F);
    337            }
    338
    339            GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    340            this.itemRenderBlocks.useInventoryTint = this.field_77024_a;
    341            this.itemRenderBlocks.renderBlockAsItem(var15, var7, 1.0F);
    342            this.itemRenderBlocks.useInventoryTint = true;
    343            GL11.glPopMatrix();
    344        }
    345        else
    346        {
    347            int var9;
    348
    349            if (Item.itemsList[var6].requiresMultipleRenderPasses())
    350            {
    351                GL11.glDisable(GL11.GL_LIGHTING);
    352                par2RenderEngine.bindTexture(par2RenderEngine.getTexture(Item.itemsList[var6].getTextureFile()));
    353
    354                for (var9 = 0; var9 < Item.itemsList[var6].getRenderPasses(var7); ++var9)
    355                {
    356                    var10 = Item.itemsList[var6].getIconIndex(par3ItemStack, var9);
    357                    int var11 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, var9);
    358                    var12 = (float)(var11 >> 16 & 255) / 255.0F;
    359                    var13 = (float)(var11 >> 8 & 255) / 255.0F;
    360                    float var14 = (float)(var11 & 255) / 255.0F;
    361
    362                    if (this.field_77024_a)
    363                    {
    364                        GL11.glColor4f(var12, var13, var14, 1.0F);
    365                    }
    366
    367                    this.renderTexturedQuad(par4, par5, var10 % 16 * 16, var10 / 16 * 16, 16, 16);
    368                }
    369
    370                GL11.glEnable(GL11.GL_LIGHTING);
    371            }
    372            else if (var8 >= 0)
    373            {
    374                GL11.glDisable(GL11.GL_LIGHTING);
    375
    376                par2RenderEngine.bindTexture(par2RenderEngine.getTexture(par3ItemStack.getItem().getTextureFile()));
    377
    378                var9 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, 0);
    379                float var17 = (float)(var9 >> 16 & 255) / 255.0F;
    380                var16 = (float)(var9 >> 8 & 255) / 255.0F;
    381                var12 = (float)(var9 & 255) / 255.0F;
    382
    383                if (this.field_77024_a)
    384                {
    385                    GL11.glColor4f(var17, var16, var12, 1.0F);
    386                }
    387
    388                this.renderTexturedQuad(par4, par5, var8 % 16 * 16, var8 / 16 * 16, 16, 16);
    389                GL11.glEnable(GL11.GL_LIGHTING);
    390            }
    391        }
    392
    393        GL11.glEnable(GL11.GL_CULL_FACE);
    394    }
    395
    396    /**
    397     * Render the item's icon or block into the GUI, including the glint effect.
    398     */
    399    public void renderItemAndEffectIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5)
    400    {
    401        if (par3ItemStack != null)
    402        {
    403            if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2RenderEngine, par3ItemStack, field_77024_a, zLevel, (float)par4, (float)par5))
    404            {
    405                this.renderItemIntoGUI(par1FontRenderer, par2RenderEngine, par3ItemStack, par4, par5);
    406            }
    407
    408            if (par3ItemStack != null && par3ItemStack.hasEffect())
    409            {
    410                GL11.glDepthFunc(GL11.GL_GREATER);
    411                GL11.glDisable(GL11.GL_LIGHTING);
    412                GL11.glDepthMask(false);
    413                par2RenderEngine.bindTexture(par2RenderEngine.getTexture("%blur%/misc/glint.png"));
    414                this.zLevel -= 50.0F;
    415                GL11.glEnable(GL11.GL_BLEND);
    416                GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
    417                GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
    418                this.func_77018_a(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
    419                GL11.glDisable(GL11.GL_BLEND);
    420                GL11.glDepthMask(true);
    421                this.zLevel += 50.0F;
    422                GL11.glEnable(GL11.GL_LIGHTING);
    423                GL11.glDepthFunc(GL11.GL_LEQUAL);
    424            }
    425        }
    426    }
    427
    428    private void func_77018_a(int par1, int par2, int par3, int par4, int par5)
    429    {
    430        for (int var6 = 0; var6 < 2; ++var6)
    431        {
    432            if (var6 == 0)
    433            {
    434                GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    435            }
    436
    437            if (var6 == 1)
    438            {
    439                GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    440            }
    441
    442            float var7 = 0.00390625F;
    443            float var8 = 0.00390625F;
    444            float var9 = (float)(Minecraft.getSystemTime() % (long)(3000 + var6 * 1873)) / (3000.0F + (float)(var6 * 1873)) * 256.0F;
    445            float var10 = 0.0F;
    446            Tessellator var11 = Tessellator.instance;
    447            float var12 = 4.0F;
    448
    449            if (var6 == 1)
    450            {
    451                var12 = -1.0F;
    452            }
    453
    454            var11.startDrawingQuads();
    455            var11.addVertexWithUV((double)(par2 + 0), (double)(par3 + par5), (double)this.zLevel, (double)((var9 + (float)par5 * var12) * var7), (double)((var10 + (float)par5) * var8));
    456            var11.addVertexWithUV((double)(par2 + par4), (double)(par3 + par5), (double)this.zLevel, (double)((var9 + (float)par4 + (float)par5 * var12) * var7), (double)((var10 + (float)par5) * var8));
    457            var11.addVertexWithUV((double)(par2 + par4), (double)(par3 + 0), (double)this.zLevel, (double)((var9 + (float)par4) * var7), (double)((var10 + 0.0F) * var8));
    458            var11.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)this.zLevel, (double)((var9 + 0.0F) * var7), (double)((var10 + 0.0F) * var8));
    459            var11.draw();
    460        }
    461    }
    462
    463    /**
    464     * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the
    465     * specified position.
    466     */
    467    public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5)
    468    {
    469        if (par3ItemStack != null)
    470        {
    471            if (par3ItemStack.stackSize > 1)
    472            {
    473                String var6 = "" + par3ItemStack.stackSize;
    474                GL11.glDisable(GL11.GL_LIGHTING);
    475                GL11.glDisable(GL11.GL_DEPTH_TEST);
    476                par1FontRenderer.drawStringWithShadow(var6, par4 + 19 - 2 - par1FontRenderer.getStringWidth(var6), par5 + 6 + 3, 16777215);
    477                GL11.glEnable(GL11.GL_LIGHTING);
    478                GL11.glEnable(GL11.GL_DEPTH_TEST);
    479            }
    480
    481            if (par3ItemStack.isItemDamaged())
    482            {
    483                int var11 = (int)Math.round(13.0D - (double)par3ItemStack.getItemDamageForDisplay() * 13.0D / (double)par3ItemStack.getMaxDamage());
    484                int var7 = (int)Math.round(255.0D - (double)par3ItemStack.getItemDamageForDisplay() * 255.0D / (double)par3ItemStack.getMaxDamage());
    485                GL11.glDisable(GL11.GL_LIGHTING);
    486                GL11.glDisable(GL11.GL_DEPTH_TEST);
    487                GL11.glDisable(GL11.GL_TEXTURE_2D);
    488                Tessellator var8 = Tessellator.instance;
    489                int var9 = 255 - var7 << 16 | var7 << 8;
    490                int var10 = (255 - var7) / 4 << 16 | 16128;
    491                this.renderQuad(var8, par4 + 2, par5 + 13, 13, 2, 0);
    492                this.renderQuad(var8, par4 + 2, par5 + 13, 12, 1, var10);
    493                this.renderQuad(var8, par4 + 2, par5 + 13, var11, 1, var9);
    494                GL11.glEnable(GL11.GL_TEXTURE_2D);
    495                GL11.glEnable(GL11.GL_LIGHTING);
    496                GL11.glEnable(GL11.GL_DEPTH_TEST);
    497                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    498            }
    499        }
    500    }
    501
    502    /**
    503     * Adds a quad to the tesselator at the specified position with the set width and height and color.  Args:
    504     * tessellator, x, y, width, height, color
    505     */
    506    private void renderQuad(Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6)
    507    {
    508        par1Tessellator.startDrawingQuads();
    509        par1Tessellator.setColorOpaque_I(par6);
    510        par1Tessellator.addVertex((double)(par2 + 0), (double)(par3 + 0), 0.0D);
    511        par1Tessellator.addVertex((double)(par2 + 0), (double)(par3 + par5), 0.0D);
    512        par1Tessellator.addVertex((double)(par2 + par4), (double)(par3 + par5), 0.0D);
    513        par1Tessellator.addVertex((double)(par2 + par4), (double)(par3 + 0), 0.0D);
    514        par1Tessellator.draw();
    515    }
    516
    517    /**
    518     * Adds a textured quad to the tesselator at the specified position with the specified texture coords, width and
    519     * height.  Args: x, y, u, v, width, height
    520     */
    521    public void renderTexturedQuad(int par1, int par2, int par3, int par4, int par5, int par6)
    522    {
    523        float var7 = 0.00390625F;
    524        float var8 = 0.00390625F;
    525        Tessellator var9 = Tessellator.instance;
    526        var9.startDrawingQuads();
    527        var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + par6) * var8));
    528        var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + par6) * var8));
    529        var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + 0) * var8));
    530        var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + 0) * var8));
    531        var9.draw();
    532    }
    533
    534    /**
    535     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    536     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    537     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    538     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    539     */
    540    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    541    {
    542        this.doRenderItem((EntityItem)par1Entity, par2, par4, par6, par8, par9);
    543    }
    544
    545    /* ==== Forge start ===== */
    546    /**
    547     * Items should spread out when rendered in 3d?
    548     * @return
    549     */
    550    public boolean shouldSpreadItems()
    551    {
    552        return true;
    553    }
    554
    555    /**
    556     * Items should have a bob effect
    557     * @return
    558     */
    559    public boolean shouldBob()
    560    {
    561        return true;
    562    }
    563
    564    public byte getMiniBlockCountForItemStack(ItemStack stack)
    565    {
    566        byte var13 = 1;
    567        if (stack.stackSize > 1)
    568        {
    569            var13 = 2;
    570        }
    571
    572        if (stack.stackSize > 5)
    573        {
    574            var13 = 3;
    575        }
    576
    577        if (stack.stackSize > 20)
    578        {
    579            var13 = 4;
    580        }
    581
    582        if (stack.stackSize > 40)
    583        {
    584            var13 = 5;
    585        }
    586        return var13;
    587    }
    588
    589    /**
    590     * Allows for a subclass to override how many rendered items appear in a
    591     * "mini item 3d stack"
    592     * @param stack
    593     * @return
    594     */
    595    public byte getMiniItemCountForItemStack(ItemStack stack)
    596    {
    597        byte var24;
    598        int var19 = stack.stackSize;
    599        if (var19 < 2)
    600        {
    601            var24 = 1;
    602        }
    603        else if (var19 < 16)
    604        {
    605            var24 = 2;
    606        }
    607        else if (var19 < 32)
    608        {
    609            var24 = 3;
    610        }
    611        else
    612        {
    613            var24 = 4;
    614        }
    615        return var24;
    616    }
    617}