diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index 6a47abaff43..f7f15e8fdaf 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -126,7 +126,6 @@ public Object getClientGuiElement (int ID, EntityPlayer player, World world, int if (ID == ArmorProxyCommon.inventoryGui) { GuiInventory inventory = new GuiInventory(player); - TabRegistry.addTabsToInventory(inventory); return inventory; } if (ID == ArmorProxyCommon.armorGuiID) diff --git a/src/main/java/tconstruct/client/TControls.java b/src/main/java/tconstruct/client/TControls.java index 6e038b7ff87..6e5f2e34d63 100644 --- a/src/main/java/tconstruct/client/TControls.java +++ b/src/main/java/tconstruct/client/TControls.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; +import net.minecraftforge.common.MinecraftForge; import tconstruct.TConstruct; import tconstruct.armor.ArmorProxyClient; import tconstruct.armor.ArmorProxyCommon; @@ -69,10 +70,9 @@ public void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepea { openArmorGui();// mc.thePlayer.username); } - if (kb == invKey && mc.currentScreen != null && mc.currentScreen.getClass() == GuiInventory.class)// && - // !mc.playerController.isInCreativeMode()) + if (kb == invKey && mc.currentScreen != null && mc.currentScreen.getClass() == GuiInventory.class)// &&// !mc.playerController.isInCreativeMode()) { - TabRegistry.addTabsToInventory((GuiContainer) mc.currentScreen); + MinecraftForge.EVENT_BUS.register(new TabRegistry()); } if (kb == jumpKey) // Double jump { @@ -173,14 +173,14 @@ public static void openKnapsackGui () AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID); updateServer(packet); } - - private void toggleGoggles() + + private void toggleGoggles () { AbstractPacket packet = new GogglePacket(activeGoggles); updateServer(packet); } - - private void toggleBelt() + + private void toggleBelt () { AbstractPacket packet = new BeltPacket(); updateServer(packet); diff --git a/src/main/java/tconstruct/client/tabs/TabRegistry.java b/src/main/java/tconstruct/client/tabs/TabRegistry.java index 5dd5039115e..a6c2a33b76a 100644 --- a/src/main/java/tconstruct/client/tabs/TabRegistry.java +++ b/src/main/java/tconstruct/client/tabs/TabRegistry.java @@ -6,7 +6,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraftforge.client.event.GuiScreenEvent; import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class TabRegistry { @@ -21,18 +25,20 @@ public static ArrayList getTabList () { return tabList; } - - public static void addTabsToInventory (GuiContainer gui) + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void guiPostInit (GuiScreenEvent.InitGuiEvent.Post event) { - if (gui.getClass() == GuiInventory.class) + if ((event.gui instanceof GuiInventory)) { - // Values are public at runtime. - int cornerX = gui.guiLeft; - int cornerY = gui.guiTop; - gui.buttonList.clear(); - - updateTabValues(cornerX, cornerY, InventoryTabVanilla.class); - addTabsToList(gui.buttonList); + int xSize = 176; + int ySize = 166; + int guiLeft = (event.gui.width - xSize) / 2; + int guiTop = (event.gui.height - ySize) / 2; + + updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); + addTabsToList(event.gui.buttonList); } } @@ -43,7 +49,6 @@ public static void openInventoryGui () mc.thePlayer.closeScreen(); GuiInventory inventory = new GuiInventory(mc.thePlayer); mc.displayGuiScreen(inventory); - TabRegistry.addTabsToInventory(inventory); } public static void updateTabValues (int cornerX, int cornerY, Class selectedButton)