Skip to content

Commit

Permalink
Fixed setTimeout being registered for startup scripts on client side
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Nov 2, 2023
1 parent 0108f25 commit db806e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void registerBindings(BindingsEvent event) {
event.add("onEvent", new LegacyCodeHandler("onEvent()"));
event.add("java", new LegacyCodeHandler("java()"));

if (event.manager instanceof ServerScriptManager sm && sm.server != null) {
if (event.getType().isServer() && event.manager instanceof ServerScriptManager sm && sm.server != null) {
var se = sm.server.kjs$getScheduledEvents();

event.add("setTimeout", new ScheduledEvents.TimeoutJSFunction(se, false, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ public void registerBindings(BindingsEvent event) {
event.add("Client", Minecraft.getInstance());
event.add("Painter", Painter.INSTANCE);

var se = Minecraft.getInstance().kjs$getScheduledEvents();
if (event.getType().isClient()) {
var se = Minecraft.getInstance().kjs$getScheduledEvents();

event.add("setTimeout", new ScheduledEvents.TimeoutJSFunction(se, false, false));
event.add("clearTimeout", new ScheduledEvents.TimeoutJSFunction(se, true, false));
event.add("setInterval", new ScheduledEvents.TimeoutJSFunction(se, false, true));
event.add("clearInterval", new ScheduledEvents.TimeoutJSFunction(se, true, true));
event.add("setTimeout", new ScheduledEvents.TimeoutJSFunction(se, false, false));
event.add("clearTimeout", new ScheduledEvents.TimeoutJSFunction(se, true, false));
event.add("setInterval", new ScheduledEvents.TimeoutJSFunction(se, false, true));
event.add("clearInterval", new ScheduledEvents.TimeoutJSFunction(se, true, true));
}
}
}

0 comments on commit db806e9

Please sign in to comment.