protected void doRenderItem( ItemRenderType type, ItemStack item, Item iconItem, FluidStack liquid) { IIcon icon = iconItem.getIcon(item, 0); IIcon mask = iconItem.getIcon(item, 1); boolean hasLiquid = liquid != null; IIcon fluid = hasLiquid ? liquid != null ? liquid.getFluid().getIcon(liquid) : null : mask; int liquidSheet = hasLiquid & liquid != null ? liquid.getFluid().getSpriteNumber() : 0; int colorMult = hasLiquid & liquid != null ? liquid.getFluid().getColor(liquid) : 0xFFFFFF; boolean isFloaty = hasLiquid & liquid != null ? liquid.getFluid().getDensity(liquid) < 0 : false; if (fluid == null) { fluid = Blocks.flowing_lava.getIcon(2, 0); liquidSheet = 0; colorMult = 0x3F3F3F; } TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; GL11.glPushMatrix(); Tessellator tessellator = Tessellator.instance; float iconMinX = icon.getMinU(); float iconMaxX = icon.getMaxU(); float iconMinY = icon.getMinV(); float iconMaxY = icon.getMaxV(); float maskMinX = mask.getMinU(); float maskMaxX = mask.getMaxU(); float maskMinY = mask.getMinV(); float maskMaxY = mask.getMaxV(); float fluidMinX = fluid.getMinU(); float fluidMaxX = fluid.getMaxU(); float fluidMinY = fluid.getMinV(); float fluidMaxY = fluid.getMaxV(); if (isFloaty && canFlip) { iconMaxY = icon.getMinV(); iconMinY = icon.getMaxV(); maskMaxY = mask.getMinV(); maskMinY = mask.getMaxV(); fluidMaxY = fluid.getMinV(); fluidMinY = fluid.getMaxV(); } TextureUtil.func_147950_a(false, false); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); OpenGlHelper.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); if (type == ItemRenderType.INVENTORY) { GL11.glDisable(GL11.GL_LIGHTING); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0, 16, 0, iconMinX, iconMaxY); tessellator.addVertexWithUV(16, 16, 0, iconMaxX, iconMaxY); tessellator.addVertexWithUV(16, 0, 0, iconMaxX, iconMinY); tessellator.addVertexWithUV(0, 0, 0, iconMinX, iconMinY); tessellator.draw(); if (hasLiquid) { tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0, 16, 0.001, maskMinX, maskMaxY); tessellator.addVertexWithUV(16, 16, 0.001, maskMaxX, maskMaxY); tessellator.addVertexWithUV(16, 0, 0.001, maskMaxX, maskMinY); tessellator.addVertexWithUV(0, 0, 0.001, maskMinX, maskMinY); tessellator.draw(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDepthMask(false); GL11.glMatrixMode(GL11.GL_TEXTURE); bindTexture(renderEngine, liquidSheet); OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO); tessellator.startDrawingQuads(); tessellator.setColorOpaque_I(colorMult); tessellator.addVertexWithUV(0, 16, 0.001, fluidMinX, fluidMaxY); tessellator.addVertexWithUV(16, 16, 0.001, fluidMaxX, fluidMaxY); tessellator.addVertexWithUV(16, 0, 0.001, fluidMaxX, fluidMinY); tessellator.addVertexWithUV(0, 0, 0.001, fluidMinX, fluidMinY); tessellator.draw(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDepthMask(true); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glEnable(GL11.GL_LIGHTING); } else { GL11.glEnable(GL12.GL_RESCALE_NORMAL); if (type == ItemRenderType.ENTITY) { GL11.glTranslatef(0.5f, 4 / -16f, 0); GL11.glRotatef(180, 0, 1, 0); } ItemRenderer.renderItemIn2D( tessellator, iconMaxX, iconMinY, iconMinX, iconMaxY, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); if (hasLiquid) { tessellator.startDrawingQuads(); tessellator.setNormal(0, 0, 1); tessellator.addVertexWithUV(0, 0, 0.001, maskMaxX, maskMaxY); tessellator.addVertexWithUV(1, 0, 0.001, maskMinX, maskMaxY); tessellator.addVertexWithUV(1, 1, 0.001, maskMinX, maskMinY); tessellator.addVertexWithUV(0, 1, 0.001, maskMaxX, maskMinY); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0, 0, -1); tessellator.addVertexWithUV(0, 1, -0.0635, maskMinX, maskMinY); tessellator.addVertexWithUV(1, 1, -0.0635, maskMaxX, maskMinY); tessellator.addVertexWithUV(1, 0, -0.0635, maskMaxX, maskMaxY); tessellator.addVertexWithUV(0, 0, -0.0635, maskMinX, maskMaxY); tessellator.draw(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDepthMask(false); bindTexture(renderEngine, liquidSheet); OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO); tessellator.startDrawingQuads(); tessellator.setNormal(0, 0, 1); tessellator.setColorOpaque_I(colorMult); tessellator.addVertexWithUV(0, 0, 0.001, fluidMaxX, fluidMaxY); tessellator.addVertexWithUV(1, 0, 0.001, fluidMinX, fluidMaxY); tessellator.addVertexWithUV(1, 1, 0.001, fluidMinX, fluidMinY); tessellator.addVertexWithUV(0, 1, 0.001, fluidMaxX, fluidMinY); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0, 0, -1); tessellator.setColorOpaque_I(colorMult); tessellator.addVertexWithUV(0, 1, -0.0635, fluidMinX, fluidMinY); tessellator.addVertexWithUV(1, 1, -0.0635, fluidMaxX, fluidMinY); tessellator.addVertexWithUV(1, 0, -0.0635, fluidMaxX, fluidMaxY); tessellator.addVertexWithUV(0, 0, -0.0635, fluidMinX, fluidMaxY); tessellator.draw(); GL11.glDepthMask(true); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); } OpenGlHelper.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glDisable(GL11.GL_ALPHA_TEST); TextureUtil.func_147945_b(); GL11.glPopMatrix(); }
public static void renderItem(EntityLivingBase entity, ItemStack itemStack, int renderPass) { TextureManager texturemanager = FMLClientHandler.instance().getClient().getTextureManager(); Item item = itemStack.getItem(); Block block = Block.getBlockFromItem(item); GL11.glPushMatrix(); if (itemStack.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) { texturemanager.bindTexture(texturemanager.getResourceLocation(0)); if (itemStack != null && block != null && block.getRenderBlockPass() != 0) { GL11.glDepthMask(false); RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F); GL11.glDepthMask(true); } else { RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F); } } else { IIcon iicon = entity.getItemIcon(itemStack, renderPass); if (iicon == null) { GL11.glPopMatrix(); return; } texturemanager.bindTexture( texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); TextureUtil.func_152777_a(false, false, 1.0F); Tessellator tessellator = Tessellator.instance; float minU = iicon.getMinU(); float maxU = iicon.getMaxU(); float minV = iicon.getMinV(); float maxV = iicon.getMaxV(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(0.0F, -0.3F, 0.0F); GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); ItemRenderer.renderItemIn2D( tessellator, maxU, minV, minU, maxV, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); if (itemStack.hasEffect(renderPass)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); texturemanager.bindTexture(RenderHelper.RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(768, 1, 1, 0); GL11.glColor4f(0.38F, 0.19F, 0.608F, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); GL11.glScalef(0.125F, 0.125F, 0.125F); float animOffset = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(animOffset, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(0.125F, 0.125F, 0.125F); animOffset = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-animOffset, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); texturemanager.bindTexture( texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); TextureUtil.func_147945_b(); } if (itemStack != null && block != null && block.getRenderBlockPass() != 0) { GL11.glDisable(GL11.GL_BLEND); } GL11.glPopMatrix(); }