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