From 80889091fd3127e4deb73dc42f5a9c1297a98781 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 29 Jun 2014 13:58:47 +1000 Subject: [PATCH] Fixed event handlers --- .../java/biomesoplenty/BiomesOPlenty.java | 4 +- src/main/java/biomesoplenty/ClientProxy.java | 9 --- src/main/java/biomesoplenty/CommonProxy.java | 22 +----- .../api/BOPObfuscationHelper.java | 3 + .../common/eventhandler/BOPEventHandlers.java | 76 +++++++++++++++++++ .../gui/MainMenuEventHandler.java | 50 ++++++------ .../gui/StartupWarningEventHandler.java | 2 +- 7 files changed, 109 insertions(+), 57 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java rename src/main/java/biomesoplenty/common/eventhandler/{ => client}/gui/MainMenuEventHandler.java (81%) rename src/main/java/biomesoplenty/common/eventhandler/{ => client}/gui/StartupWarningEventHandler.java (96%) diff --git a/src/main/java/biomesoplenty/BiomesOPlenty.java b/src/main/java/biomesoplenty/BiomesOPlenty.java index 6086fdbc6..42448776f 100644 --- a/src/main/java/biomesoplenty/BiomesOPlenty.java +++ b/src/main/java/biomesoplenty/BiomesOPlenty.java @@ -14,6 +14,7 @@ import biomesoplenty.common.core.BOPItems; import biomesoplenty.common.core.BOPPackets; import biomesoplenty.common.core.BOPPotions; import biomesoplenty.common.core.BOPVanillaCompat; +import biomesoplenty.common.eventhandler.BOPEventHandlers; import biomesoplenty.common.helpers.CreativeTabsBOP; import biomesoplenty.common.integration.BOPIntegration; import biomesoplenty.common.integration.TreecapitatorIntegration; @@ -67,7 +68,8 @@ public class BiomesOPlenty BOPEntities.init(); BOPVanillaCompat.init(); - proxy.registerEventHandlers(); + BOPEventHandlers.init(); + proxy.registerRenderers(); BOPIntegration.preInit(); diff --git a/src/main/java/biomesoplenty/ClientProxy.java b/src/main/java/biomesoplenty/ClientProxy.java index a36adbb28..c6b50de17 100644 --- a/src/main/java/biomesoplenty/ClientProxy.java +++ b/src/main/java/biomesoplenty/ClientProxy.java @@ -39,7 +39,6 @@ import biomesoplenty.common.entities.EntityRosester; import biomesoplenty.common.entities.EntityWasp; import biomesoplenty.common.entities.projectiles.EntityDart; import biomesoplenty.common.entities.projectiles.EntityMudball; -import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; @@ -103,14 +102,6 @@ public class ClientProxy extends CommonProxy RenderingRegistry.registerBlockHandler(new BambooRenderer()); } - @Override - public void registerEventHandlers() - { - MinecraftForge.EVENT_BUS.register(StartupWarningEventHandler.instance); - MinecraftForge.EVENT_BUS.register(new ParticleRegistry()); - FMLCommonHandler.instance().bus().register(new FlowerScatterEventHandler()); - } - @Override public void spawnParticle(String string, double x, double y, double z) { diff --git a/src/main/java/biomesoplenty/CommonProxy.java b/src/main/java/biomesoplenty/CommonProxy.java index 5087d1571..6722b05b9 100644 --- a/src/main/java/biomesoplenty/CommonProxy.java +++ b/src/main/java/biomesoplenty/CommonProxy.java @@ -1,11 +1,11 @@ package biomesoplenty; import net.minecraftforge.common.MinecraftForge; +import biomesoplenty.common.eventhandler.client.gui.MainMenuEventHandler; +import biomesoplenty.common.eventhandler.client.gui.StartupWarningEventHandler; import biomesoplenty.common.eventhandler.entity.DyeEventHandler; import biomesoplenty.common.eventhandler.entity.FlippersEventHandler; import biomesoplenty.common.eventhandler.entity.TemptEventHandler; -import biomesoplenty.common.eventhandler.gui.MainMenuEventHandler; -import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler; import biomesoplenty.common.eventhandler.misc.BonemealEventHandler; import biomesoplenty.common.eventhandler.misc.BucketEventHandler; import biomesoplenty.common.eventhandler.network.ConnectionEventHandler; @@ -25,24 +25,6 @@ public class CommonProxy { } - public void registerEventHandlers() - { - FMLCommonHandler.instance().bus().register(new ConnectionEventHandler()); - - MinecraftForge.TERRAIN_GEN_BUS.register(new DecorationModificationEventHandler()); - MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeSizeEventHandler()); - MinecraftForge.TERRAIN_GEN_BUS.register(new VillageMaterialEventHandler()); - MinecraftForge.TERRAIN_GEN_BUS.register(new MapGenEventHandler()); - MinecraftForge.EVENT_BUS.register(new DyeEventHandler()); - MinecraftForge.EVENT_BUS.register(new FlippersEventHandler()); - MinecraftForge.EVENT_BUS.register(new TemptEventHandler()); - MinecraftForge.EVENT_BUS.register(new PotionParalysisEventHandler()); - MinecraftForge.EVENT_BUS.register(new PotionPossessionEventHandler()); - MinecraftForge.EVENT_BUS.register(new MainMenuEventHandler()); - MinecraftForge.EVENT_BUS.register(new BonemealEventHandler()); - MinecraftForge.EVENT_BUS.register(new BucketEventHandler()); - } - public void spawnParticle(String string, double x, double y, double z) { } diff --git a/src/main/java/biomesoplenty/api/BOPObfuscationHelper.java b/src/main/java/biomesoplenty/api/BOPObfuscationHelper.java index 731c59f69..2fe612900 100644 --- a/src/main/java/biomesoplenty/api/BOPObfuscationHelper.java +++ b/src/main/java/biomesoplenty/api/BOPObfuscationHelper.java @@ -33,6 +33,9 @@ public class BOPObfuscationHelper public static final String[] roofedForest = new String[] { "roofedForest", "field_150585_R" }; public static final String[] hell = new String[] { "hell", "field_76778_j" }; + //GuiMainMenu + public static final String[] titlePanoramaPaths = new String[] { "titlePanoramaPaths", "field_73978_o" }; + //Minecraft public static final String[] fileAssets = new String[] { "fileAssets", "field_110446_Y" }; } diff --git a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java new file mode 100644 index 000000000..a9044d04b --- /dev/null +++ b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java @@ -0,0 +1,76 @@ +package biomesoplenty.common.eventhandler; + +import net.minecraftforge.common.MinecraftForge; +import biomesoplenty.common.eventhandler.client.gui.MainMenuEventHandler; +import biomesoplenty.common.eventhandler.client.gui.StartupWarningEventHandler; +import biomesoplenty.common.eventhandler.entity.DyeEventHandler; +import biomesoplenty.common.eventhandler.entity.FlippersEventHandler; +import biomesoplenty.common.eventhandler.entity.TemptEventHandler; +import biomesoplenty.common.eventhandler.misc.BonemealEventHandler; +import biomesoplenty.common.eventhandler.misc.BucketEventHandler; +import biomesoplenty.common.eventhandler.network.ConnectionEventHandler; +import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler; +import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler; +import biomesoplenty.common.eventhandler.world.BiomeSizeEventHandler; +import biomesoplenty.common.eventhandler.world.DecorationModificationEventHandler; +import biomesoplenty.common.eventhandler.world.MapGenEventHandler; +import biomesoplenty.common.eventhandler.world.VillageMaterialEventHandler; +import cpw.mods.fml.common.FMLCommonHandler; + +public class BOPEventHandlers +{ + public static void init() + { + registerNetworkEventHandlers(); + registerWorldEventHandlers(); + registerEntityEventHandlers(); + registerPotionEventHandlers(); + registerGUIEventHandlers(); + registerMiscEventHandlers(); + //registerClientEventHandlers(); + } + + private static void registerNetworkEventHandlers() + { + FMLCommonHandler.instance().bus().register(new ConnectionEventHandler()); + } + + private static void registerWorldEventHandlers() + { + MinecraftForge.TERRAIN_GEN_BUS.register(new DecorationModificationEventHandler()); + MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeSizeEventHandler()); + MinecraftForge.TERRAIN_GEN_BUS.register(new VillageMaterialEventHandler()); + MinecraftForge.TERRAIN_GEN_BUS.register(new MapGenEventHandler()); + } + + private static void registerEntityEventHandlers() + { + MinecraftForge.EVENT_BUS.register(new DyeEventHandler()); + MinecraftForge.EVENT_BUS.register(new FlippersEventHandler()); + MinecraftForge.EVENT_BUS.register(new TemptEventHandler()); + } + + private static void registerPotionEventHandlers() + { + MinecraftForge.EVENT_BUS.register(new PotionParalysisEventHandler()); + MinecraftForge.EVENT_BUS.register(new PotionPossessionEventHandler()); + } + + private static void registerGUIEventHandlers() + { + MinecraftForge.EVENT_BUS.register(StartupWarningEventHandler.instance); + MinecraftForge.EVENT_BUS.register(new MainMenuEventHandler()); + } + + private static void registerMiscEventHandlers() + { + MinecraftForge.EVENT_BUS.register(new BonemealEventHandler()); + MinecraftForge.EVENT_BUS.register(new BucketEventHandler()); + } + + /*private static void registerClientEventHandlers() + { + MinecraftForge.EVENT_BUS.register(new ParticleRegistry()); + FMLCommonHandler.instance().bus().register(new FlowerScatterEventHandler()); + }*/ +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuEventHandler.java b/src/main/java/biomesoplenty/common/eventhandler/client/gui/MainMenuEventHandler.java similarity index 81% rename from src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuEventHandler.java rename to src/main/java/biomesoplenty/common/eventhandler/client/gui/MainMenuEventHandler.java index 11ef933fc..e3aab1329 100755 --- a/src/main/java/biomesoplenty/common/eventhandler/gui/MainMenuEventHandler.java +++ b/src/main/java/biomesoplenty/common/eventhandler/client/gui/MainMenuEventHandler.java @@ -1,26 +1,24 @@ -package biomesoplenty.common.eventhandler.gui; - -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; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -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")}; - - @SubscribeEvent - @SideOnly(Side.CLIENT) - 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"); - } - } -} +package biomesoplenty.common.eventhandler.client.gui; + +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.GuiOpenEvent; +import biomesoplenty.api.BOPObfuscationHelper; +import biomesoplenty.common.helpers.BOPReflectionHelper; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +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")}; + + @SubscribeEvent + public void openMainMenu(GuiOpenEvent event) + { + if (event.gui instanceof GuiMainMenu) + { + GuiMainMenu mainMenu = (GuiMainMenu)event.gui; + + BOPReflectionHelper.setPrivateFinalValue(GuiMainMenu.class, mainMenu, bopTitlePanoramaPaths, BOPObfuscationHelper.titlePanoramaPaths); + } + } +} diff --git a/src/main/java/biomesoplenty/common/eventhandler/gui/StartupWarningEventHandler.java b/src/main/java/biomesoplenty/common/eventhandler/client/gui/StartupWarningEventHandler.java similarity index 96% rename from src/main/java/biomesoplenty/common/eventhandler/gui/StartupWarningEventHandler.java rename to src/main/java/biomesoplenty/common/eventhandler/client/gui/StartupWarningEventHandler.java index c3c32c3e6..cc94ee787 100644 --- a/src/main/java/biomesoplenty/common/eventhandler/gui/StartupWarningEventHandler.java +++ b/src/main/java/biomesoplenty/common/eventhandler/client/gui/StartupWarningEventHandler.java @@ -1,4 +1,4 @@ -package biomesoplenty.common.eventhandler.gui; +package biomesoplenty.common.eventhandler.client.gui; import java.io.File; import java.io.IOException;