From 89376d58bf92e0d2e4629361f95fd7c158f97787 Mon Sep 17 00:00:00 2001 From: Nazrin Date: Fri, 16 Jun 2023 11:04:16 -0700 Subject: [PATCH] Change method of not ticking empty scenes (#2211) --- src/main/java/emu/grasscutter/game/world/Scene.java | 4 ---- src/main/java/emu/grasscutter/game/world/World.java | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 9bca99fdf..94f36afc5 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -556,10 +556,6 @@ public final class Scene { this.finishLoading(); this.checkPlayerRespawn(); if (this.tickCount++ % 10 == 0) this.broadcastPacket(new PacketSceneTimeNotify(this)); - if (this.getPlayerCount() <= 0 && !this.dontDestroyWhenEmpty) { - this.getScriptManager().onDestroy(); - this.getWorld().deregisterScene(this); - } } /** Validates a player's current position. Teleports the player if the player is out of bounds. */ diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index 8c7595f33..d21aeeb33 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -437,7 +437,9 @@ public class World implements Iterable { // Check if there are players in this world. if (this.getPlayerCount() == 0) return true; // Tick all associated scenes. - this.getScenes().forEach((k, scene) -> scene.onTick()); + this.getScenes().forEach((k, scene) -> { + if (scene.getPlayerCount() > 0) scene.onTick(); + }); // sync time every 10 seconds if (this.tickCount % 10 == 0) {