diff options
-rw-r--r-- | src/main/java/makamys/neodymium/MixinConfigPlugin.java | 6 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/Neodymium.java | 29 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/util/Proxy.java | 17 |
3 files changed, 41 insertions, 11 deletions
diff --git a/src/main/java/makamys/neodymium/MixinConfigPlugin.java b/src/main/java/makamys/neodymium/MixinConfigPlugin.java index df3c76c..936c70c 100644 --- a/src/main/java/makamys/neodymium/MixinConfigPlugin.java +++ b/src/main/java/makamys/neodymium/MixinConfigPlugin.java @@ -2,12 +2,14 @@ package makamys.neodymium; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; import org.spongepowered.asm.lib.tree.ClassNode; import org.spongepowered.asm.mixin.MixinEnvironment; import org.spongepowered.asm.mixin.MixinEnvironment.Phase; +import org.spongepowered.asm.mixin.MixinEnvironment.Side; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -18,6 +20,8 @@ public class MixinConfigPlugin implements IMixinConfigPlugin { @Override public void onLoad(String mixinPackage) { + if(MixinEnvironment.getCurrentEnvironment().getSide() == Side.SERVER) return; + Config.reloadConfig(); Phase phase = MixinEnvironment.getCurrentEnvironment().getPhase(); @@ -41,6 +45,8 @@ public class MixinConfigPlugin implements IMixinConfigPlugin { @Override public List<String> getMixins() { + if(MixinEnvironment.getCurrentEnvironment().getSide() == Side.SERVER) return Collections.emptyList(); + List<String> mixins = new ArrayList<>(); Phase phase = MixinEnvironment.getCurrentEnvironment().getPhase(); if(phase == Phase.DEFAULT) { diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java index 320e46a..3a489cf 100644 --- a/src/main/java/makamys/neodymium/Neodymium.java +++ b/src/main/java/makamys/neodymium/Neodymium.java @@ -17,6 +17,7 @@ import org.apache.commons.lang3.tuple.Pair; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLConstructionEvent; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -33,6 +34,7 @@ import makamys.neodymium.command.NeodymiumCommand; import makamys.neodymium.config.Config; import makamys.neodymium.renderer.NeoRenderer; import makamys.neodymium.util.ChatUtil; +import makamys.neodymium.util.Proxy; import makamys.neodymium.util.WarningHelper; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; @@ -42,9 +44,19 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.WorldEvent; -@Mod(modid = MODID, version = VERSION, guiFactory = "makamys.neodymium.config.GuiFactory") -public class Neodymium -{ +public class Neodymium implements Proxy { + + @Mod(modid = MODID, version = VERSION, guiFactory = "makamys.neodymium.config.GuiFactory") + public static class ModContainer { + @SidedProxy(serverSide = "makamys.neodymium.util.Proxy$NullProxy", clientSide = "makamys.neodymium.Neodymium") + private static Proxy proxy; + @EventHandler + public void construct(FMLConstructionEvent event) { proxy.construct(event); } + @EventHandler + public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } + @EventHandler + public void init(FMLInitializationEvent event) { proxy.init(event); } + } private static final Config.ReloadInfo CONFIG_RELOAD_INFO = new Config.ReloadInfo(); @@ -56,15 +68,12 @@ public class Neodymium private static World rendererWorld; - @EventHandler - public void preInit(FMLConstructionEvent event) { + public void construct(FMLConstructionEvent event) { MCLib.init(); Compat.init(); } - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { + public void preInit(FMLPreInitializationEvent event) { MCLibModules.updateCheckAPI.submitModTask(MODID, "@UPDATE_URL@"); if(VERSION.equals("@VERSION@")) { @@ -73,9 +82,7 @@ public class Neodymium } } - @EventHandler - public void init(FMLInitializationEvent event) - { + public void init(FMLInitializationEvent event) { FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); NeodymiumCommand.init(); diff --git a/src/main/java/makamys/neodymium/util/Proxy.java b/src/main/java/makamys/neodymium/util/Proxy.java new file mode 100644 index 0000000..592a0fb --- /dev/null +++ b/src/main/java/makamys/neodymium/util/Proxy.java @@ -0,0 +1,17 @@ +package makamys.neodymium.util; + +import cpw.mods.fml.common.event.FMLConstructionEvent; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public interface Proxy { + public default void construct(FMLConstructionEvent event) {} + public default void preInit(FMLPreInitializationEvent event) {} + public default void init(FMLInitializationEvent event) {} + public default void postInit(FMLPostInitializationEvent event) {} + public default void loadComplete(FMLLoadCompleteEvent event) {} + + public static class NullProxy implements Proxy {} +} |