From 41642969aefa424f84fbafec48532c8b8617bfa4 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Tue, 14 Jan 2014 23:03:43 +1100 Subject: [PATCH] And now we no longer override GuiMainMenu. Hackery rocks! --- .../common/eventhandler/BOPEventHandlers.java | 4 +-- .../gui/MainMenuEventHandler.java} | 29 ++++++++++--------- .../gui/MainMenuOverrideEventHandler.java | 18 ------------ 3 files changed, 18 insertions(+), 33 deletions(-) rename src/main/java/biomesoplenty/{client/gui/GuiMainMenuBOP.java => common/eventhandler/gui/MainMenuEventHandler.java} (56%) delete mode 100755 src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuOverrideEventHandler.java diff --git a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java index 1277ab915..e390f014d 100755 --- a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java +++ b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java @@ -4,7 +4,7 @@ import net.minecraftforge.common.MinecraftForge; import biomesoplenty.common.eventhandler.entity.DyeEventHandler; import biomesoplenty.common.eventhandler.entity.FlippersEventHandler; import biomesoplenty.common.eventhandler.entity.TemptEventHandler; -import biomesoplenty.common.eventhandler.gui.MainMenuOverrideEventHandler; +import biomesoplenty.common.eventhandler.gui.MainMenuEventHandler; import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler; import biomesoplenty.common.eventhandler.misc.CapeEventHandler; import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler; @@ -45,7 +45,7 @@ public class BOPEventHandlers private static void registerGUIEventHandlers() { MinecraftForge.EVENT_BUS.register(StartupWarningEventHandler.instance); - MinecraftForge.EVENT_BUS.register(new MainMenuOverrideEventHandler()); + MinecraftForge.EVENT_BUS.register(new MainMenuEventHandler()); } private static void registerMiscEventHandlers() diff --git a/src/main/java/biomesoplenty/client/gui/GuiMainMenuBOP.java b/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuEventHandler.java similarity index 56% rename from src/main/java/biomesoplenty/client/gui/GuiMainMenuBOP.java rename to src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuEventHandler.java index 4978ab517..ae53b37c7 100755 --- a/src/main/java/biomesoplenty/client/gui/GuiMainMenuBOP.java +++ b/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuEventHandler.java @@ -1,20 +1,23 @@ -package biomesoplenty.client.gui; +package biomesoplenty.common.eventhandler.gui; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import biomesoplenty.common.helpers.BOPReflectionHelper; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.GuiOpenEvent; +import biomesoplenty.common.helpers.BOPReflectionHelper; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; -public class GuiMainMenuBOP extends GuiMainMenu +public class MainMenuEventHandler { public static ResourceLocation[] bopTitlePanoramaPaths = new ResourceLocation[] {new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_0.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_1.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_2.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_3.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_4.png"), new ResourceLocation("biomesoplenty:textures/gui/title/background/panorama_5.png")}; - public GuiMainMenuBOP() - { - super(); - - BOPReflectionHelper.setPrivateFinalValue(GuiMainMenu.class, this, bopTitlePanoramaPaths, "titlePanoramaPaths", "field_73978_o"); - } -} \ No newline at end of file + @SubscribeEvent + public void openMainMenu(GuiOpenEvent event) + { + if (event.gui instanceof GuiMainMenu) + { + GuiMainMenu mainMenu = (GuiMainMenu)event.gui; + + BOPReflectionHelper.setPrivateFinalValue(GuiMainMenu.class, mainMenu, bopTitlePanoramaPaths, "titlePanoramaPaths", "field_73978_o"); + } + } +} diff --git a/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuOverrideEventHandler.java b/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuOverrideEventHandler.java deleted file mode 100755 index b15072800..000000000 --- a/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuOverrideEventHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -package biomesoplenty.common.eventhandler.gui; - -import biomesoplenty.client.gui.GuiMainMenuBOP; -import net.minecraft.client.gui.GuiMainMenu; -import net.minecraftforge.client.event.GuiOpenEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class MainMenuOverrideEventHandler -{ - @SubscribeEvent - public void openMainMenu(GuiOpenEvent event) - { - if (event.gui instanceof GuiMainMenu) - { - event.gui = new GuiMainMenuBOP(); - } - } -}