38 lines
1.7 KiB
Java
38 lines
1.7 KiB
Java
package com.pahimar.ee3.client.util;
|
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
import net.minecraft.client.renderer.texture.TextureMap;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.IIcon;
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
public class RenderUtils
|
|
{
|
|
public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale)
|
|
{
|
|
IIcon icon = itemStack.getIconIndex();
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
|
int overlayColour = itemStack.getItem().getColorFromItemStack(itemStack, 0);
|
|
float red = (overlayColour >> 16 & 255) / 255.0F;
|
|
float green = (overlayColour >> 8 & 255) / 255.0F;
|
|
float blue = (overlayColour & 255) / 255.0F;
|
|
GL11.glColor4f(red, green, blue, opacity);
|
|
drawTexturedQuad(x, y, icon, 16 * scale, 16 * scale, -90);
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
}
|
|
|
|
public static void drawTexturedQuad(int x, int y, IIcon icon, float width, float height, double zLevel)
|
|
{
|
|
Tessellator tessellator = Tessellator.instance;
|
|
tessellator.startDrawingQuads();
|
|
tessellator.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getMaxV());
|
|
tessellator.addVertexWithUV(x + width, y + height, zLevel, icon.getMaxU(), icon.getMaxV());
|
|
tessellator.addVertexWithUV(x + width, y, zLevel, icon.getMaxU(), icon.getMinV());
|
|
tessellator.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV());
|
|
tessellator.draw();
|
|
}
|
|
}
|