From c0268ca86eeb5ca767e5e2860aa2d936e5e7fc4f Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Wed, 19 Jun 2024 09:27:15 -0700 Subject: [PATCH] Copy missing diff from old chunk system patch Fixes: - EntitiesLoadEvent/EntitiesUnloadEvent not firing - Chunks not saving properly in a lot of cases --- leaf_notes.txt | 1 - ...Chunk-System-Starlight-from-Moonrise.patch | 84 +++++++++++++++++-- patches/server/1002-Anti-Xray.patch | 2 +- patches/server/1008-Optimize-Hoppers.patch | 2 +- ...009-Entity-load-save-limit-per-chunk.patch | 2 +- .../1023-Improved-Watchdog-Support.patch | 6 +- 6 files changed, 84 insertions(+), 13 deletions(-) diff --git a/leaf_notes.txt b/leaf_notes.txt index 30da036b0f..7c8d0c37cc 100644 --- a/leaf_notes.txt +++ b/leaf_notes.txt @@ -7,7 +7,6 @@ on another note, clean up mcutils... -later, run a diff compared to the mod and move all of the diff to separate classes apply todo in levelmixin to fix later: diff --git a/patches/server/0991-Chunk-System-Starlight-from-Moonrise.patch b/patches/server/0991-Chunk-System-Starlight-from-Moonrise.patch index 4e4ba2ac38..3a0997f047 100644 --- a/patches/server/0991-Chunk-System-Starlight-from-Moonrise.patch +++ b/patches/server/0991-Chunk-System-Starlight-from-Moonrise.patch @@ -5029,10 +5029,10 @@ index 0000000000000000000000000000000000000000..755b08dd32e568d341ceef8a8aef8418 +} diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java new file mode 100644 -index 0000000000000000000000000000000000000000..19672631d7c69ade16a6f966c72a4a9d57b77c55 +index 0000000000000000000000000000000000000000..997b05167c19472acb98edac32d4548cc65efa8e --- /dev/null +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -@@ -0,0 +1,811 @@ +@@ -0,0 +1,819 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.level.entity; + +import ca.spottedleaf.moonrise.common.list.EntityList; @@ -5213,6 +5213,14 @@ index 0000000000000000000000000000000000000000..19672631d7c69ade16a6f966c72a4a9d + + return ret.toArray(new org.bukkit.entity.Entity[0]); + } ++ ++ public void callEntitiesLoadEvent() { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callEntitiesLoadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); ++ } ++ ++ public void callEntitiesUnloadEvent() { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callEntitiesUnloadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); ++ } + // Paper end + + private List getAllEntities() { @@ -22550,8 +22558,20 @@ index 73e83d56a340f0c7dcb8ff737d621003e72c6de4..d05297d77147ab68f8c5bb08f13a1f88 public static boolean isTickThreadFor(final ServerLevel world, final int chunkX, final int chunkZ, final int radius) { return isTickThread(); } +diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java +index c33f85b570f159ab465b5a10a8044a81f2797f43..244a19ecd0234fa1d7a6ecfea20751595688605d 100644 +--- a/src/main/java/net/minecraft/server/Main.java ++++ b/src/main/java/net/minecraft/server/Main.java +@@ -320,6 +320,7 @@ public class Main { + + convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); + */ ++ Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async + final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> { + DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::createFromGameruleRadius); + diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 6915522f669631779c1fb8a8e2db330f4b9fb921..cd69971065b13353353eca55f6e145949390de11 100644 +index 6915522f669631779c1fb8a8e2db330f4b9fb921..3aecd55b9a069710c5d383b2f9113b147ad1ab57 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -198,7 +198,7 @@ import org.bukkit.event.server.ServerLoadEvent; @@ -22670,6 +22690,29 @@ index 6915522f669631779c1fb8a8e2db330f4b9fb921..cd69971065b13353353eca55f6e14594 this.profiler.popPush("nextTickWait"); this.mayHaveDelayedTasks = true; this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + i, this.nextTickTimeNanos); +@@ -1594,7 +1604,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { +- for (final Entity entity : level.getEntities().getAll()) { ++ for (final Entity entity : level.moonrise$getEntityLookup().getAllCopy()) { // Paper - rewrite chunk system + if (entity.isRemoved()) { + continue; + } +@@ -2661,6 +2671,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop