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 GL11.glTranslatef(0.0F, 0.0F, f12 + f11); 242 // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... 243 if (k > 0 && shouldSpreadItems()) 244 { 245 float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; 246 float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; 247 float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; 248 GL11.glTranslatef(x, y, f12 + f11); 249 } 250 else 251 { 252 GL11.glTranslatef(0f, 0f, f12 + f11); 253 } 254 255 if (itemstack.getItemSpriteNumber() == 0) 256 { 257 this.loadTexture("/terrain.png"); 258 } 259 else 260 { 261 this.loadTexture("/gui/items.png"); 262 } 263 264 GL11.glColor4f(par5, par6, par7, 1.0F); 265 ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getSheetWidth(), par2Icon.getSheetHeight(), f12); 266 267 if (itemstack != null && itemstack.hasEffect()) 268 { 269 GL11.glDepthFunc(GL11.GL_EQUAL); 270 GL11.glDisable(GL11.GL_LIGHTING); 271 this.renderManager.renderEngine.bindTexture("%blur%/misc/glint.png"); 272 GL11.glEnable(GL11.GL_BLEND); 273 GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); 274 float f13 = 0.76F; 275 GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); 276 GL11.glMatrixMode(GL11.GL_TEXTURE); 277 GL11.glPushMatrix(); 278 float f14 = 0.125F; 279 GL11.glScalef(f14, f14, f14); 280 float f15 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; 281 GL11.glTranslatef(f15, 0.0F, 0.0F); 282 GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); 283 ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); 284 GL11.glPopMatrix(); 285 GL11.glPushMatrix(); 286 GL11.glScalef(f14, f14, f14); 287 f15 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; 288 GL11.glTranslatef(-f15, 0.0F, 0.0F); 289 GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); 290 ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); 291 GL11.glPopMatrix(); 292 GL11.glMatrixMode(GL11.GL_MODELVIEW); 293 GL11.glDisable(GL11.GL_BLEND); 294 GL11.glEnable(GL11.GL_LIGHTING); 295 GL11.glDepthFunc(GL11.GL_LEQUAL); 296 } 297 } 298 299 GL11.glPopMatrix(); 300 } 301 else 302 { 303 for (int l = 0; l < par3; ++l) 304 { 305 GL11.glPushMatrix(); 306 307 if (l > 0) 308 { 309 f11 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; 310 float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; 311 float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; 312 GL11.glTranslatef(f11, f16, f17); 313 } 314 315 if (!renderInFrame) 316 { 317 GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); 318 } 319 320 GL11.glColor4f(par5, par6, par7, 1.0F); 321 tessellator.startDrawingQuads(); 322 tessellator.setNormal(0.0F, 1.0F, 0.0F); 323 tessellator.addVertexWithUV((double)(0.0F - f9), (double)(0.0F - f10), 0.0D, (double)f4, (double)f7); 324 tessellator.addVertexWithUV((double)(f8 - f9), (double)(0.0F - f10), 0.0D, (double)f5, (double)f7); 325 tessellator.addVertexWithUV((double)(f8 - f9), (double)(1.0F - f10), 0.0D, (double)f5, (double)f6); 326 tessellator.addVertexWithUV((double)(0.0F - f9), (double)(1.0F - f10), 0.0D, (double)f4, (double)f6); 327 tessellator.draw(); 328 GL11.glPopMatrix(); 329 } 330 } 331 } 332 333 /** 334 * Renders the item's icon or block into the UI at the specified position. 335 */ 336 public void renderItemIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5) 337 { 338 int k = par3ItemStack.itemID; 339 int l = par3ItemStack.getItemDamage(); 340 Icon icon = par3ItemStack.getIconIndex(); 341 float f; 342 float f1; 343 float f2; 344 345 Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null); 346 if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType())) 347 { 348 par2RenderEngine.bindTexture("/terrain.png"); 349 GL11.glPushMatrix(); 350 GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel); 351 GL11.glScalef(10.0F, 10.0F, 10.0F); 352 GL11.glTranslatef(1.0F, 0.5F, 1.0F); 353 GL11.glScalef(1.0F, 1.0F, -1.0F); 354 GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); 355 GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); 356 int i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); 357 f2 = (float)(i1 >> 16 & 255) / 255.0F; 358 f = (float)(i1 >> 8 & 255) / 255.0F; 359 f1 = (float)(i1 & 255) / 255.0F; 360 361 if (this.renderWithColor) 362 { 363 GL11.glColor4f(f2, f, f1, 1.0F); 364 } 365 366 GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); 367 this.itemRenderBlocks.useInventoryTint = this.renderWithColor; 368 this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F); 369 this.itemRenderBlocks.useInventoryTint = true; 370 GL11.glPopMatrix(); 371 } 372 else 373 { 374 int j1; 375 376 if (Item.itemsList[k].requiresMultipleRenderPasses()) 377 { 378 GL11.glDisable(GL11.GL_LIGHTING); 379 par2RenderEngine.bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? "/terrain.png" : "/gui/items.png"); 380 381 for (j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) 382 { 383 Icon icon1 = Item.itemsList[k].getIcon(par3ItemStack, j1); 384 int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1); 385 f = (float)(k1 >> 16 & 255) / 255.0F; 386 f1 = (float)(k1 >> 8 & 255) / 255.0F; 387 float f3 = (float)(k1 & 255) / 255.0F; 388 389 if (this.renderWithColor) 390 { 391 GL11.glColor4f(f, f1, f3, 1.0F); 392 } 393 394 this.renderIcon(par4, par5, icon1, 16, 16); 395 } 396 397 GL11.glEnable(GL11.GL_LIGHTING); 398 } 399 else 400 { 401 GL11.glDisable(GL11.GL_LIGHTING); 402 403 if (par3ItemStack.getItemSpriteNumber() == 0) 404 { 405 par2RenderEngine.bindTexture("/terrain.png"); 406 } 407 else 408 { 409 par2RenderEngine.bindTexture("/gui/items.png"); 410 } 411 412 if (icon == null) 413 { 414 icon = par2RenderEngine.getMissingIcon(par3ItemStack.getItemSpriteNumber()); 415 } 416 417 j1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0); 418 float f4 = (float)(j1 >> 16 & 255) / 255.0F; 419 f2 = (float)(j1 >> 8 & 255) / 255.0F; 420 f = (float)(j1 & 255) / 255.0F; 421 422 if (this.renderWithColor) 423 { 424 GL11.glColor4f(f4, f2, f, 1.0F); 425 } 426 427 this.renderIcon(par4, par5, icon, 16, 16); 428 GL11.glEnable(GL11.GL_LIGHTING); 429 } 430 } 431 432 GL11.glEnable(GL11.GL_CULL_FACE); 433 } 434 435 /** 436 * Render the item's icon or block into the GUI, including the glint effect. 437 */ 438 public void renderItemAndEffectIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5) 439 { 440 if (par3ItemStack != null) 441 { 442 if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2RenderEngine, par3ItemStack, renderWithColor, zLevel, (float)par4, (float)par5)) 443 { 444 this.renderItemIntoGUI(par1FontRenderer, par2RenderEngine, par3ItemStack, par4, par5); 445 } 446 447 if (par3ItemStack.hasEffect()) 448 { 449 GL11.glDepthFunc(GL11.GL_GREATER); 450 GL11.glDisable(GL11.GL_LIGHTING); 451 GL11.glDepthMask(false); 452 par2RenderEngine.bindTexture("%blur%/misc/glint.png"); 453 this.zLevel -= 50.0F; 454 GL11.glEnable(GL11.GL_BLEND); 455 GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); 456 GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); 457 this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); 458 GL11.glDisable(GL11.GL_BLEND); 459 GL11.glDepthMask(true); 460 this.zLevel += 50.0F; 461 GL11.glEnable(GL11.GL_LIGHTING); 462 GL11.glDepthFunc(GL11.GL_LEQUAL); 463 } 464 } 465 } 466 467 private void renderGlint(int par1, int par2, int par3, int par4, int par5) 468 { 469 for (int j1 = 0; j1 < 2; ++j1) 470 { 471 if (j1 == 0) 472 { 473 GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); 474 } 475 476 if (j1 == 1) 477 { 478 GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); 479 } 480 481 float f = 0.00390625F; 482 float f1 = 0.00390625F; 483 float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F; 484 float f3 = 0.0F; 485 Tessellator tessellator = Tessellator.instance; 486 float f4 = 4.0F; 487 488 if (j1 == 1) 489 { 490 f4 = -1.0F; 491 } 492 493 tessellator.startDrawingQuads(); 494 tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + par5), (double)this.zLevel, (double)((f2 + (float)par5 * f4) * f), (double)((f3 + (float)par5) * f1)); 495 tessellator.addVertexWithUV((double)(par2 + par4), (double)(par3 + par5), (double)this.zLevel, (double)((f2 + (float)par4 + (float)par5 * f4) * f), (double)((f3 + (float)par5) * f1)); 496 tessellator.addVertexWithUV((double)(par2 + par4), (double)(par3 + 0), (double)this.zLevel, (double)((f2 + (float)par4) * f), (double)((f3 + 0.0F) * f1)); 497 tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)this.zLevel, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1)); 498 tessellator.draw(); 499 } 500 } 501 502 /** 503 * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the 504 * specified position. 505 */ 506 public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5) 507 { 508 this.renderItemStack(par1FontRenderer, par2RenderEngine, par3ItemStack, par4, par5, (String)null); 509 } 510 511 public void renderItemStack(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5, String par6Str) 512 { 513 if (par3ItemStack != null) 514 { 515 if (par3ItemStack.stackSize > 1 || par6Str != null) 516 { 517 String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; 518 GL11.glDisable(GL11.GL_LIGHTING); 519 GL11.glDisable(GL11.GL_DEPTH_TEST); 520 par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); 521 GL11.glEnable(GL11.GL_LIGHTING); 522 GL11.glEnable(GL11.GL_DEPTH_TEST); 523 } 524 525 if (par3ItemStack.isItemDamaged()) 526 { 527 int k = (int)Math.round(13.0D - (double)par3ItemStack.getItemDamageForDisplay() * 13.0D / (double)par3ItemStack.getMaxDamage()); 528 int l = (int)Math.round(255.0D - (double)par3ItemStack.getItemDamageForDisplay() * 255.0D / (double)par3ItemStack.getMaxDamage()); 529 GL11.glDisable(GL11.GL_LIGHTING); 530 GL11.glDisable(GL11.GL_DEPTH_TEST); 531 GL11.glDisable(GL11.GL_TEXTURE_2D); 532 Tessellator tessellator = Tessellator.instance; 533 int i1 = 255 - l << 16 | l << 8; 534 int j1 = (255 - l) / 4 << 16 | 16128; 535 this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); 536 this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); 537 this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); 538 GL11.glEnable(GL11.GL_TEXTURE_2D); 539 GL11.glEnable(GL11.GL_LIGHTING); 540 GL11.glEnable(GL11.GL_DEPTH_TEST); 541 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 542 } 543 } 544 } 545 546 /** 547 * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: 548 * tessellator, x, y, width, height, color 549 */ 550 private void renderQuad(Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) 551 { 552 par1Tessellator.startDrawingQuads(); 553 par1Tessellator.setColorOpaque_I(par6); 554 par1Tessellator.addVertex((double)(par2 + 0), (double)(par3 + 0), 0.0D); 555 par1Tessellator.addVertex((double)(par2 + 0), (double)(par3 + par5), 0.0D); 556 par1Tessellator.addVertex((double)(par2 + par4), (double)(par3 + par5), 0.0D); 557 par1Tessellator.addVertex((double)(par2 + par4), (double)(par3 + 0), 0.0D); 558 par1Tessellator.draw(); 559 } 560 561 public void renderIcon(int par1, int par2, Icon par3Icon, int par4, int par5) 562 { 563 Tessellator tessellator = Tessellator.instance; 564 tessellator.startDrawingQuads(); 565 tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par5), (double)this.zLevel, (double)par3Icon.getMinU(), (double)par3Icon.getMaxV()); 566 tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + par5), (double)this.zLevel, (double)par3Icon.getMaxU(), (double)par3Icon.getMaxV()); 567 tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + 0), (double)this.zLevel, (double)par3Icon.getMaxU(), (double)par3Icon.getMinV()); 568 tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)par3Icon.getMinU(), (double)par3Icon.getMinV()); 569 tessellator.draw(); 570 } 571 572 /** 573 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then 574 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic 575 * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, 576 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. 577 */ 578 public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) 579 { 580 this.doRenderItem((EntityItem)par1Entity, par2, par4, par6, par8, par9); 581 } 582 583 /** 584 * Items should spread out when rendered in 3d? 585 * @return 586 */ 587 public boolean shouldSpreadItems() 588 { 589 return true; 590 } 591 592 /** 593 * Items should have a bob effect 594 * @return 595 */ 596 public boolean shouldBob() 597 { 598 return true; 599 } 600 601 public byte getMiniBlockCount(ItemStack stack) 602 { 603 byte ret = 1; 604 if (stack.stackSize > 1 ) ret = 2; 605 if (stack.stackSize > 5 ) ret = 3; 606 if (stack.stackSize > 20) ret = 4; 607 if (stack.stackSize > 40) ret = 5; 608 return ret; 609 } 610 611 /** 612 * Allows for a subclass to override how many rendered items appear in a 613 * "mini item 3d stack" 614 * @param stack 615 * @return 616 */ 617 public byte getMiniItemCount(ItemStack stack) 618 { 619 byte ret = 1; 620 if (stack.stackSize > 1) ret = 2; 621 if (stack.stackSize > 15) ret = 3; 622 if (stack.stackSize > 31) ret = 4; 623 return ret; 624 } 625}