@SubscribeEvent
public void drawText(RenderGameOverlayEvent.Post event) {
switch(event.type) {
case ALL:
renderHotbar(event.resolution.getScaledWidth(), event.resolution.getScaledHeight(), event.partialTicks);
default:
break;
}
}
private static void renderHotbar(int width, int height, float partialTicks) {
InventoryPlayer inv = mc.thePlayer.inventory;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemRenderer.zLevel += 200;
int x = width / 2 - 66 + 0 * 25 + 2;
int z = height - 72;
renderInventorySlot(inv.mainInventory.length + 3, x, z, partialTicks);
x = width / 2 - 66 + 1 * 25 + 2;
renderInventorySlot(inv.mainInventory.length + 2, x, z, partialTicks);
x = width / 2 - 38 + 2 * 25 + 2;
renderInventorySlot(inv.mainInventory.length + 1, x, z, partialTicks);
x = width / 2 - 38 + 3 * 25 + 2;
renderInventorySlot(inv.mainInventory.length + 0, x, z, partialTicks);
itemRenderer.zLevel -= 200;
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
private static void renderInventorySlot(int slotID, int x, int y, float par4) {
ItemStack itemstack = mc.thePlayer.inventory.getStackInSlot(slotID);
if (itemstack != null) {
float f1 = (float)itemstack.animationsToGo - par4;
if (f1 > 0.0F) {
GL11.glPushMatrix();
float f2 = 1.0F + f1 / 5.0F;
GL11.glTranslatef((float)(x + 8), (float)(y + 12), 0.0F);
GL11.glScalef(1.0F / f2, (f2 + 1.0F) / 2.0F, 1.0F);
GL11.glTranslatef((float)(-(x + 8)), (float)(-(y + 12)), 0.0F);
}
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y);
if (f1 > 0.0F) GL11.glPopMatrix();
itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y);
}
}