|
@@ -0,0 +1,101 @@
|
|
|
|
+package me.km.networking;
|
|
|
|
+
|
|
|
|
+import me.km.KajetansMod;
|
|
|
|
+import net.minecraft.client.Minecraft;
|
|
|
|
+import net.minecraft.client.gui.FontRenderer;
|
|
|
|
+import net.minecraft.client.gui.Gui;
|
|
|
|
+import net.minecraft.client.gui.ScaledResolution;
|
|
|
|
+import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
+import net.minecraft.util.ResourceLocation;
|
|
|
|
+import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
+import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
+
|
|
|
|
+@SideOnly(Side.CLIENT)
|
|
|
|
+public class ItemStackDisplayGui extends Gui
|
|
|
|
+{
|
|
|
|
+ private static final ResourceLocation CUSTOM_ICONS = new ResourceLocation(KajetansMod.MODID, "textures/gui/itemstacks.png");
|
|
|
|
+
|
|
|
|
+ public final static ItemStackDisplayGui INSTANCE = new ItemStackDisplayGui(Minecraft.getMinecraft());
|
|
|
|
+
|
|
|
|
+ private final Minecraft mc;
|
|
|
|
+ private final int[] icons;
|
|
|
|
+ private boolean inactive = true;
|
|
|
|
+
|
|
|
|
+ public ItemStackDisplayGui(Minecraft mc)
|
|
|
|
+ {
|
|
|
|
+ this.mc = mc;
|
|
|
|
+ this.icons = new int[27];
|
|
|
|
+ clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setActive(boolean active)
|
|
|
|
+ {
|
|
|
|
+ this.inactive = !active;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setIcon(int index, int i, int count)
|
|
|
|
+ {
|
|
|
|
+ if(index >= 0 && index < 9)
|
|
|
|
+ {
|
|
|
|
+ index *= 3;
|
|
|
|
+ icons[index] = i < 48 ? 64 + ((i % 12) << 4) : (((i - 48) & 0xF) << 4);
|
|
|
|
+ icons[index + 1] = i < 48 ? (i / 12) << 4 : 64 + (((i - 48) >> 4) << 4);
|
|
|
|
+ icons[index + 2] = count;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public final void clear()
|
|
|
|
+ {
|
|
|
|
+ for(int i = 0; i < 27; i += 3)
|
|
|
|
+ {
|
|
|
|
+ icons[i] = 64;
|
|
|
|
+ icons[i + 1] = 0;
|
|
|
|
+ icons[i + 2] = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void paint()
|
|
|
|
+ {
|
|
|
|
+ if(inactive || mc.ingameGUI.getChatGUI().getChatOpen())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GlStateManager.enableBlend();
|
|
|
|
+
|
|
|
|
+ mc.getTextureManager().bindTexture(CUSTOM_ICONS);
|
|
|
|
+
|
|
|
|
+ ScaledResolution scaledresolution = new ScaledResolution(mc);
|
|
|
|
+ int screenWidth = scaledresolution.getScaledWidth();
|
|
|
|
+ int screenHeight = scaledresolution.getScaledHeight();
|
|
|
|
+ drawTexturedModalRect(screenWidth - 62, screenHeight - 62, 0, 0, 62, 62);
|
|
|
|
+
|
|
|
|
+ int i = 0;
|
|
|
|
+ for(int y = 59; y > 0; y -= 20)
|
|
|
|
+ {
|
|
|
|
+ for(int x = 59; x > 0; x -= 20)
|
|
|
|
+ {
|
|
|
|
+ drawTexturedModalRect(screenWidth - x, screenHeight - y, icons[i], icons[i + 1], 16, 16);
|
|
|
|
+ i += 3;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GlStateManager.disableBlend();
|
|
|
|
+
|
|
|
|
+ FontRenderer fr = mc.fontRenderer;
|
|
|
|
+ String s;
|
|
|
|
+ i = 2;
|
|
|
|
+ for(int y = 50; y > 0; y -= 20)
|
|
|
|
+ {
|
|
|
|
+ for(int x = 42; x > 0; x -= 20)
|
|
|
|
+ {
|
|
|
|
+ if(icons[i] != 0)
|
|
|
|
+ {
|
|
|
|
+ s = String.valueOf(icons[i]);
|
|
|
|
+ fr.drawStringWithShadow(s, (float)(screenWidth - x - fr.getStringWidth(s)), (float)(screenHeight - y), 16777215);
|
|
|
|
+ }
|
|
|
|
+ i += 3;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|