Skip to content

Commit

Permalink
Added igi gui init event
Browse files Browse the repository at this point in the history
  • Loading branch information
tttsaurus committed Jan 5, 2025
1 parent e928223 commit 6f9af02
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.tttsaurus.ingameinfo.common.api.event;

import net.minecraftforge.fml.common.eventhandler.Event;

public class IgiGuiInitEvent extends Event
{

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -277,15 +278,14 @@ public void type(int keycode)
}
//</editor-fold>

// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ public static void onMvvmRegister(MvvmRegisterEvent event)
crtViewModel.runtimeMvvm = mvvm;
MvvmRegistry.setIgiGuiContainer(mvvm, crtViewModel);
}

//MvvmRegistry.autoRegister("test", TestViewModel.class);
}
}
Original file line number Diff line number Diff line change
@@ -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
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<IIgiGuiInitEvent> igiGuiInitEventList = new EventList<>();

@ZenMethod
public static IEventHandle onIgiGuiInit(IEventManager manager, IEventHandler<IIgiGuiInitEvent> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@ZenRegister
@ZenClass("mods.ingameinfo.mvvm.Mvvm")
public class CrtMvvm
public final class CrtMvvm
{
public static List<String> mvvms = new ArrayList<>();
public static String currentMvvm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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)
{

}
}
6 changes: 6 additions & 0 deletions src/main/java/com/tttsaurus/ingameinfo/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down

0 comments on commit 6f9af02

Please sign in to comment.