From 46186569d5cb462f90e59a37dc17a9fad51cfa4a Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Wed, 1 Jul 2015 16:11:31 +0100 Subject: Added a curse tab, added a config to enable/disable extra jewelry info, plus more! --- .../jewelrycraft/client/TabRegistry.java | 170 ++++++++++----------- 1 file changed, 85 insertions(+), 85 deletions(-) (limited to 'src/main/java/darkknight/jewelrycraft/client/TabRegistry.java') diff --git a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java index 6ba37ad..e35f305 100644 --- a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java +++ b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java @@ -1,86 +1,86 @@ -package darkknight.jewelrycraft.client; - -import java.util.ArrayList; -import java.util.List; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.network.play.client.C0DPacketCloseWindow; -import net.minecraftforge.client.event.GuiScreenEvent; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.client.*; - -/** - * @author TinkersConstruct - */ -public class TabRegistry -{ - private static ArrayList tabList = new ArrayList(); - - public static void registerTab(AbstractTab tab) - { - tabList.add(tab); - } - - public static ArrayList getTabList() - { - return tabList; - } - - @SideOnly (Side.CLIENT) - @SubscribeEvent - public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) - { - if ((event.gui instanceof GuiInventory)){ - int xSize = 176; - int ySize = 166; - int guiLeft = (event.gui.width - xSize) / 2; - int guiTop = (event.gui.height - ySize) / 2; - if (!mc.thePlayer.getActivePotionEffects().isEmpty()) if (Loader.isModLoaded("NotEnoughItems")){ - try{ - // Check whether NEI is hidden and enabled - Class c = Class.forName("codechicken.nei.NEIClientConfig"); - Object hidden = c.getMethod("isHidden").invoke(null); - Object enabled = c.getMethod("isEnabled").invoke(null); - if (hidden != null && hidden instanceof Boolean && enabled != null && enabled instanceof Boolean) if ((Boolean)hidden || !((Boolean)enabled)) guiLeft += 60; - } - catch(Exception e){} - }else guiLeft += 60; - updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); - addTabsToList(event.buttonList); - } - } - - private static Minecraft mc = FMLClientHandler.instance().getClient(); - - public static void openInventoryGui() - { - mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(mc.thePlayer.openContainer.windowId)); - GuiInventory inventory = new GuiInventory(mc.thePlayer); - mc.displayGuiScreen(inventory); - } - - public static void updateTabValues(int cornerX, int cornerY, Class selectedButton) - { - int count = 1; - for(int i = 0; i < tabList.size(); i++){ - AbstractTab t = tabList.get(i); - if (t.shouldAddToList()){ - t.id = count; - t.xPosition = cornerX + 151 + (t.id==1?9:0); - t.yPosition = cornerY + 64; - t.enabled = !t.getClass().equals(selectedButton); - count++; - } - } - } - - public static void addTabsToList(List buttonList) - { - for(AbstractTab tab: tabList) - if (tab.shouldAddToList() && tab.enabled) buttonList.add(tab); - } +package darkknight.jewelrycraft.client; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.network.play.client.C0DPacketCloseWindow; +import net.minecraftforge.client.event.GuiScreenEvent; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.client.*; + +/** + * @author TinkersConstruct + */ +public class TabRegistry { + private static ArrayList tabList = new ArrayList(); + + public static void registerTab(AbstractTab tab) { + tabList.add(tab); + } + + public static ArrayList getTabList() { + return tabList; + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { + if ((event.gui instanceof GuiInventory)) { + int xSize = 176; + int ySize = 166; + int guiLeft = (event.gui.width - xSize) / 2; + int guiTop = (event.gui.height - ySize) / 2; + if (!mc.thePlayer.getActivePotionEffects().isEmpty()) if (Loader.isModLoaded("NotEnoughItems")) { + try { + // Check whether NEI is hidden and enabled + Class c = Class.forName("codechicken.nei.NEIClientConfig"); + Object hidden = c.getMethod("isHidden").invoke(null); + Object enabled = c.getMethod("isEnabled").invoke(null); + if (hidden != null && hidden instanceof Boolean && enabled != null && enabled instanceof Boolean) if ((Boolean) hidden || !((Boolean) enabled)) guiLeft += 60; + } catch (Exception e) { + } + } else guiLeft += 60; + updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); + addTabsToList(event.buttonList); + } + } + + private static Minecraft mc = FMLClientHandler.instance().getClient(); + + public static void openInventoryGui() { + mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(mc.thePlayer.openContainer.windowId)); + GuiInventory inventory = new GuiInventory(mc.thePlayer); + mc.displayGuiScreen(inventory); + } + + public static void updateTabValues(int cornerX, int cornerY, Class selectedButton) { + int count = 0; + for (int i = 0; i < tabList.size(); i++) { + AbstractTab t = tabList.get(i); + if (t.shouldAddToList()) { + if (selectedButton.equals(TabCurses.class)) { + t.xPosition = cornerX + 195; + t.yPosition = cornerY + count*20; + }else if (selectedButton.equals(TabJewelry.class)) { + t.xPosition = cornerX + 140 + count * 20; + t.yPosition = cornerY + 64; + } else { + t.xPosition = cornerX + 131 + count * 20; + t.yPosition = cornerY + 64; + } + t.enabled = !t.getClass().equals(selectedButton); + if (t.enabled) count++; + } + } + } + + public static void addTabsToList(List buttonList) { + for (AbstractTab tab : tabList) + if (tab.shouldAddToList() && tab.enabled) buttonList.add(tab); + } } \ No newline at end of file -- cgit v1.2.3