From 45ae3a360b3e960ec3a10963a7167824088cbdb3 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 | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) 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/Chunk-System-Starlight-from-Moonrise.patch b/patches/server/Chunk-System-Starlight-from-Moonrise.patch index 280222da0b..9f4b45a4f5 100644 --- a/patches/server/Chunk-System-Starlight-from-Moonrise.patch +++ b/patches/server/Chunk-System-Starlight-from-Moonrise.patch @@ -5213,6 +5213,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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,6 +22558,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/Main.java ++++ b/src/main/java/net/minecraft/server/Main.java +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java @@ -22670,6 +22690,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.profiler.popPush("nextTickWait"); this.mayHaveDelayedTasks = true; this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + i, this.nextTickTimeNanos); +@@ -0,0 +0,0 @@ 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; + } +@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop