mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-25 14:34:22 +00:00
Speeding up TabRegistry event registration
This commit is contained in:
1 parent
6aacbb0387
commit
7a565178a4
2 files changed
+22
-16
No files matched your search
@@ -62,7 +62,7 @@ public class ArmorProxyClient extends ArmorProxyCommon {
|
||||
controlInstance = new ArmorControls();
|
||||
FMLCommonHandler.instance().bus().register(controlInstance.handler);
|
||||
MinecraftForge.EVENT_BUS.register(controlInstance.handler);
|
||||
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
||||
MinecraftForge.EVENT_BUS.register(new TabRegistry().handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class TabRegistry {
|
||||
|
||||
private static final ArrayList<AbstractTab> tabList = new ArrayList<>();
|
||||
public EventHandler handler;
|
||||
public TabRegistry() {
|
||||
handler = new EventHandler();
|
||||
}
|
||||
|
||||
public static void registerTab(AbstractTab tab) {
|
||||
tabList.add(tab);
|
||||
@@ -26,21 +30,6 @@ public class TabRegistry {
|
||||
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;
|
||||
guiLeft += getPotionOffset();
|
||||
|
||||
updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class);
|
||||
addTabsToList(event.gui.buttonList);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
public static void openInventoryGui() {
|
||||
@@ -95,4 +84,21 @@ public class TabRegistry {
|
||||
// No potions, no offset needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
public class EventHandler{
|
||||
@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;
|
||||
guiLeft += getPotionOffset();
|
||||
|
||||
updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class);
|
||||
addTabsToList(event.gui.buttonList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user