diff --git a/src/main/java/com/tttsaurus/ingameinfo/common/api/event/IgiGuiInitEvent.java b/src/main/java/com/tttsaurus/ingameinfo/common/api/event/IgiGuiInitEvent.java new file mode 100644 index 0000000..047fcba --- /dev/null +++ b/src/main/java/com/tttsaurus/ingameinfo/common/api/event/IgiGuiInitEvent.java @@ -0,0 +1,8 @@ +package com.tttsaurus.ingameinfo.common.api.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class IgiGuiInitEvent extends Event +{ + +} diff --git a/src/main/java/com/tttsaurus/ingameinfo/common/impl/gui/IgiGuiLifeCycle.java b/src/main/java/com/tttsaurus/ingameinfo/common/impl/gui/IgiGuiLifeCycle.java index 8617044..848ea79 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/common/impl/gui/IgiGuiLifeCycle.java +++ b/src/main/java/com/tttsaurus/ingameinfo/common/impl/gui/IgiGuiLifeCycle.java @@ -1,6 +1,6 @@ package com.tttsaurus.ingameinfo.common.impl.gui; -import com.tttsaurus.ingameinfo.common.api.gui.IgiGuiManager; +import com.tttsaurus.ingameinfo.common.api.event.IgiGuiInitEvent; import com.tttsaurus.ingameinfo.common.api.gui.IgiGuiContainer; import com.tttsaurus.ingameinfo.common.api.gui.delegate.placeholder.IPlaceholderDrawScreen; import com.tttsaurus.ingameinfo.common.api.gui.delegate.placeholder.IPlaceholderKeyTyped; @@ -9,6 +9,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; @@ -277,15 +278,14 @@ public void type(int keycode) } // - // testing - if (flag) + if (initFlag) { - flag = false; - IgiGuiManager.openGui("test"); + initFlag = false; + MinecraftForge.EVENT_BUS.post(new IgiGuiInitEvent()); } } - private static boolean flag = true; + private static boolean initFlag = true; // placeholder related private static boolean isPlaceholderGuiOn = false; diff --git a/src/main/java/com/tttsaurus/ingameinfo/common/impl/mvvm/registry/MvvmRegisterEventHandler.java b/src/main/java/com/tttsaurus/ingameinfo/common/impl/mvvm/registry/MvvmRegisterEventHandler.java index fb5bdcb..187b178 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/common/impl/mvvm/registry/MvvmRegisterEventHandler.java +++ b/src/main/java/com/tttsaurus/ingameinfo/common/impl/mvvm/registry/MvvmRegisterEventHandler.java @@ -17,7 +17,5 @@ public static void onMvvmRegister(MvvmRegisterEvent event) crtViewModel.runtimeMvvm = mvvm; MvvmRegistry.setIgiGuiContainer(mvvm, crtViewModel); } - - //MvvmRegistry.autoRegister("test", TestViewModel.class); } } diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/event/IIgiGuiInitEvent.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/event/IIgiGuiInitEvent.java new file mode 100644 index 0000000..38f6950 --- /dev/null +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/event/IIgiGuiInitEvent.java @@ -0,0 +1,12 @@ +package com.tttsaurus.ingameinfo.plugin.crt.api.event; + +import crafttweaker.annotations.ZenRegister; +import crafttweaker.api.event.IEventCancelable; +import stanhebben.zenscript.annotations.ZenClass; + +@ZenRegister +@ZenClass("mods.ingameinfo.event.IgiGuiInitEvent") +public interface IIgiGuiInitEvent extends IEventCancelable +{ + +} diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameFpsEventListener.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameFpsEventListener.java index d7850f6..d70a022 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameFpsEventListener.java +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameFpsEventListener.java @@ -4,7 +4,7 @@ import stanhebben.zenscript.annotations.ZenClass; @ZenRegister -@ZenClass("mods.ingameinfo.event.IGameFpsEventListener") +@ZenClass("mods.ingameinfo.igievent.GameFpsEventListener") public interface IGameFpsEventListener { void invoke(int arg0); diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameMemoryEventListener.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameMemoryEventListener.java index 9f7ab87..20a7cf7 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameMemoryEventListener.java +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IGameMemoryEventListener.java @@ -4,7 +4,7 @@ import stanhebben.zenscript.annotations.ZenClass; @ZenRegister -@ZenClass("mods.ingameinfo.event.IGameMemoryEventListener") +@ZenClass("mods.ingameinfo.igievent.GameMemoryEventListener") public interface IGameMemoryEventListener { void invoke(long arg0); diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IIgiGuiFpsEventListener.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IIgiGuiFpsEventListener.java index c2ea2c5..a0b5e30 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IIgiGuiFpsEventListener.java +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/api/igievent/IIgiGuiFpsEventListener.java @@ -4,7 +4,7 @@ import stanhebben.zenscript.annotations.ZenClass; @ZenRegister -@ZenClass("mods.ingameinfo.event.IIgiGuiFpsEventListener") +@ZenClass("mods.ingameinfo.igievent.IgiGuiFpsEventListener") public interface IIgiGuiFpsEventListener { void invoke(int arg0); diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtEventManager.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtEventManager.java new file mode 100644 index 0000000..4629cae --- /dev/null +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtEventManager.java @@ -0,0 +1,38 @@ +package com.tttsaurus.ingameinfo.plugin.crt.impl; + +import com.tttsaurus.ingameinfo.common.api.event.IgiGuiInitEvent; +import com.tttsaurus.ingameinfo.plugin.crt.api.event.IIgiGuiInitEvent; +import com.tttsaurus.ingameinfo.plugin.crt.impl.event.McIgiGuiInitEvent; +import crafttweaker.annotations.ZenRegister; +import crafttweaker.api.event.IEventHandle; +import crafttweaker.api.event.IEventManager; +import crafttweaker.util.EventList; +import crafttweaker.util.IEventHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenExpansion; +import stanhebben.zenscript.annotations.ZenMethod; + +@ZenRegister +@ZenClass("mods.ingameinfo.IEventManager") +@ZenExpansion("crafttweaker.events.IEventManager") +public class CrtEventManager +{ + private static final EventList igiGuiInitEventList = new EventList<>(); + + @ZenMethod + public static IEventHandle onIgiGuiInit(IEventManager manager, IEventHandler event) + { + return igiGuiInitEventList.add(event); + } + + public static final class Handler + { + @SubscribeEvent + public static void onIgiGuiInit(IgiGuiInitEvent event) + { + if (igiGuiInitEventList.hasHandlers()) + igiGuiInitEventList.publish(new McIgiGuiInitEvent(event)); + } + } +} diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtMvvm.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtMvvm.java index ebc7888..1dd8497 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtMvvm.java +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/CrtMvvm.java @@ -8,7 +8,7 @@ @ZenRegister @ZenClass("mods.ingameinfo.mvvm.Mvvm") -public class CrtMvvm +public final class CrtMvvm { public static List mvvms = new ArrayList<>(); public static String currentMvvm; diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/EventCenterWrapper.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/EventCenterWrapper.java index 586cd16..f04462d 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/EventCenterWrapper.java +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/EventCenterWrapper.java @@ -9,7 +9,7 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenRegister -@ZenClass("mods.ingameinfo.event.EventCenter") +@ZenClass("mods.ingameinfo.igievent.EventCenter") public final class EventCenterWrapper { @ZenMethod diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/IgiGuiManagerWrapper.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/IgiGuiManagerWrapper.java new file mode 100644 index 0000000..c9f4786 --- /dev/null +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/IgiGuiManagerWrapper.java @@ -0,0 +1,22 @@ +package com.tttsaurus.ingameinfo.plugin.crt.impl; + +import com.tttsaurus.ingameinfo.common.api.gui.IgiGuiManager; +import crafttweaker.annotations.ZenRegister; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@ZenRegister +@ZenClass("mods.ingameinfo.gui.IgiGuiManager") +public final class IgiGuiManagerWrapper +{ + @ZenMethod + public static String openGui(String mvvmRegistryName) + { + return IgiGuiManager.openGui(mvvmRegistryName); + } + @ZenMethod + public static void closeGui(String uuid) + { + IgiGuiManager.closeGui(uuid); + } +} diff --git a/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/event/McIgiGuiInitEvent.java b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/event/McIgiGuiInitEvent.java new file mode 100644 index 0000000..444147f --- /dev/null +++ b/src/main/java/com/tttsaurus/ingameinfo/plugin/crt/impl/event/McIgiGuiInitEvent.java @@ -0,0 +1,26 @@ +package com.tttsaurus.ingameinfo.plugin.crt.impl.event; + +import com.tttsaurus.ingameinfo.common.api.event.IgiGuiInitEvent; +import com.tttsaurus.ingameinfo.plugin.crt.api.event.IIgiGuiInitEvent; + +public class McIgiGuiInitEvent implements IIgiGuiInitEvent +{ + private final IgiGuiInitEvent event; + + public McIgiGuiInitEvent(IgiGuiInitEvent event) + { + this.event = event; + } + + @Override + public boolean isCanceled() + { + return false; + } + + @Override + public void setCanceled(boolean canceled) + { + + } +} diff --git a/src/main/java/com/tttsaurus/ingameinfo/proxy/CommonProxy.java b/src/main/java/com/tttsaurus/ingameinfo/proxy/CommonProxy.java index 9318b0d..654bce2 100644 --- a/src/main/java/com/tttsaurus/ingameinfo/proxy/CommonProxy.java +++ b/src/main/java/com/tttsaurus/ingameinfo/proxy/CommonProxy.java @@ -14,6 +14,7 @@ import com.tttsaurus.ingameinfo.common.impl.appcommunication.spotify.InGameCommandHandler; import com.tttsaurus.ingameinfo.common.impl.gui.registry.ElementRegistry; import com.tttsaurus.ingameinfo.common.impl.mvvm.registry.MvvmRegisterEventHandler; +import com.tttsaurus.ingameinfo.plugin.crt.impl.CrtEventManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -33,9 +34,14 @@ public void init(FMLInitializationEvent event, Logger logger) InternalMethods.instance = new InternalMethods(); + // core MinecraftForge.EVENT_BUS.register(IgiGuiLifeCycle.class); MinecraftForge.EVENT_BUS.register(MvvmRegisterEventHandler.class); + // crt support + MinecraftForge.EVENT_BUS.register(CrtEventManager.Handler.class); + + // app communication MinecraftForge.EVENT_BUS.register(InGameCommandHandler.class); String myPackage = "com.tttsaurus.ingameinfo";