From 9d12dfb8e21c9b51a4698c5af2c5050b18d5cf1b Mon Sep 17 00:00:00 2001 From: radmanplays <95340057+radmanplays@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:45:52 +0330 Subject: [PATCH] add update event --- .../net/minecraft/client/entity/EntityPlayerSP.edit.java | 6 +++++- sources/main/java/net/eaglerforge/api/GlobalsListener.java | 6 +++--- sources/main/java/net/eaglerforge/api/ModAPI.java | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.edit.java b/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.edit.java index a22b273..6988e9e 100644 --- a/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.edit.java +++ b/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.edit.java @@ -30,7 +30,11 @@ + this.statWriter = statWriter; -> CHANGE 116 : 123 @ 116 : 117 +> INSERT 19 : 20 @ 19 + ++ mc.modapi.onUpdate(); + +> CHANGE 97 : 104 @ 97 : 98 ~ if (((sendQueue.getNetworkManager() instanceof ClientIntegratedServerNetworkManager) ~ || (sendQueue.getNetworkManager() instanceof LANClientNetworkManager)) diff --git a/sources/main/java/net/eaglerforge/api/GlobalsListener.java b/sources/main/java/net/eaglerforge/api/GlobalsListener.java index 6b9e42a..03c699c 100644 --- a/sources/main/java/net/eaglerforge/api/GlobalsListener.java +++ b/sources/main/java/net/eaglerforge/api/GlobalsListener.java @@ -17,12 +17,12 @@ class GlobalsListener { void onUpdate(); } - @JSBody(params = { "handler" }, script = "window.PluginAPI.globals.onGlobalsUpdate = handler;") + @JSBody(params = { "handler" }, script = "window.ModAPI.globals.onGlobalsUpdate = handler;") static native void provideCallback(GlobalsHandler handler); - @JSBody(params = { "handler" }, script = "window.PluginAPI.globals.onRequire = handler;") + @JSBody(params = { "handler" }, script = "window.ModAPI.globals.onRequire = handler;") static native void provideRequireCallback(GlobalsHandler handler); - @JSBody(params = { "handler" }, script = "window.PluginAPI.update = handler;") + @JSBody(params = { "handler" }, script = "window.ModAPI.update = handler;") static native void provideUpdateCallback(UpdateHandler handler); } \ No newline at end of file diff --git a/sources/main/java/net/eaglerforge/api/ModAPI.java b/sources/main/java/net/eaglerforge/api/ModAPI.java index a46ebbd..12a2edb 100644 --- a/sources/main/java/net/eaglerforge/api/ModAPI.java +++ b/sources/main/java/net/eaglerforge/api/ModAPI.java @@ -59,6 +59,10 @@ public class ModAPI { this.mc = mcIn; requiredList = new ArrayList(); initAPI(version); + newEvent("update"); + globalsFunctor(this); + globalsRequireFunctor(this); + globalsUpdateFunctor(this); getModAPI().setCallbackVoidWithDataArg("displayToChat", (BaseData params) -> { mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(params.getString("msg"))); }); @@ -112,5 +116,6 @@ public class ModAPI { } public void onUpdate() { + ModAPI.callEvent("update", new ModData()); } }