Created
December 5, 2013 10:47
-
-
Save Jezza/7803411 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package me.jezzadabomb.es2.client.tickers; | |
| import static org.lwjgl.opengl.GL11.*; | |
| import java.util.ArrayList; | |
| import java.util.EnumSet; | |
| import me.jezzadabomb.es2.common.core.ESLogger; | |
| import me.jezzadabomb.es2.common.hud.StoredQueues; | |
| import me.jezzadabomb.es2.common.packets.InventoryPacket; | |
| import net.minecraft.client.Minecraft; | |
| import net.minecraft.client.entity.EntityClientPlayerMP; | |
| import net.minecraft.client.gui.FontRenderer; | |
| import net.minecraft.client.renderer.Tessellator; | |
| import net.minecraft.client.renderer.entity.RenderManager; | |
| import net.minecraft.item.ItemStack; | |
| import org.lwjgl.opengl.GL11; | |
| import cpw.mods.fml.client.FMLClientHandler; | |
| import cpw.mods.fml.common.ITickHandler; | |
| import cpw.mods.fml.common.TickType; | |
| import cpw.mods.fml.relauncher.Side; | |
| import cpw.mods.fml.relauncher.SideOnly; | |
| @SideOnly(Side.CLIENT) | |
| public class HUDHandler implements ITickHandler { | |
| EntityClientPlayerMP player; | |
| Minecraft mc; | |
| public static ArrayList<InventoryPacket> packetList; | |
| public ArrayList<InventoryPacket> removeList; | |
| public HUDHandler() { | |
| mc = FMLClientHandler.instance().getClient(); | |
| player = mc.thePlayer; | |
| packetList = new ArrayList<InventoryPacket>(0); | |
| removeList = new ArrayList<InventoryPacket>(0); | |
| } | |
| public static void addHUDHandler(InventoryPacket inventoryPacket) { | |
| if (!packetList.contains(inventoryPacket)) { | |
| packetList.add(inventoryPacket); | |
| } | |
| } | |
| public void printPacketList() { | |
| for (InventoryPacket p : packetList) { | |
| System.out.println("PacketList: " + p); | |
| System.out.println("X: " + p.x); | |
| System.out.println("Y: " + p.y); | |
| System.out.println("Z: " + p.z); | |
| for (ItemStack i : p.itemStacks) { | |
| System.out.println(i); | |
| } | |
| System.out.println(); | |
| } | |
| } | |
| @Override | |
| public void tickStart(EnumSet<TickType> type, Object... tickData) { | |
| } | |
| @Override | |
| public void tickEnd(EnumSet<TickType> type, Object... tickData) { | |
| // printPacketList(); | |
| if (packetList.isEmpty()) { | |
| return; | |
| } | |
| for (InventoryPacket p : packetList) { | |
| if (!StoredQueues.instance().getStrXYZ(p.inventoryTitle, p.x, p.y, | |
| p.z)) { | |
| removeList.add(p); | |
| } | |
| } | |
| packetList.removeAll(removeList); | |
| if (type.contains(TickType.RENDER)) { | |
| if (!StoredQueues.instance().getPlayer().isEmpty()) { | |
| renderWorld(); | |
| } | |
| } | |
| } | |
| public void renderWorld() { | |
| for (InventoryPacket p : packetList) { | |
| drawGuiAtXYZ(p); | |
| } | |
| } | |
| public void drawGuiAtXYZ(InventoryPacket p) { | |
| //System.out.println("Rendering: " + p); | |
| glPushMatrix(); | |
| glTranslatef((float) p.x - 0.5F, (float) p.y + 1.5F, (float) p.z - 0.5F); | |
| glColor4f(0.25F, 0.25F, 0.25F, 0.0F); | |
| glBegin(GL_QUADS); | |
| glVertex3f(0.0F, 0.0F, 1.0F); | |
| glVertex3f(0.0F, 2.0F, 3.0F); | |
| glVertex3f(2.0F, 2.0F, 5.0F); | |
| glVertex3f(2.0F, 0.0F, 6.0F); | |
| glEnd(); | |
| glPopMatrix(); | |
| } | |
| @Override | |
| public EnumSet<TickType> ticks() { | |
| return EnumSet.of(TickType.RENDER); | |
| } | |
| @Override | |
| public String getLabel() { | |
| return "ES2-ClientRenderer"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment