add update event

This commit is contained in:
radmanplays 2024-02-15 22:45:52 +03:30
parent 00d76e5f27
commit 9d12dfb8e2
3 changed files with 13 additions and 4 deletions

View File

@ -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))

View File

@ -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);
}

View File

@ -59,6 +59,10 @@ public class ModAPI {
this.mc = mcIn;
requiredList = new ArrayList<String>();
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());
}
}