From c1c203f3de768cf6d33f030f384e19ec5536683a Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Mon, 25 Aug 2025 15:17:41 -0400 Subject: [PATCH] Fix failedSpawnAttemptsData copied many times --- ...Paper-PR-Throttle-failed-spawn-attempts.patch | 16 +++++++--------- .../features/0225-Optimise-chunkUnloads.patch | 12 ++++++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/leaf-server/minecraft-patches/features/0211-Paper-PR-Throttle-failed-spawn-attempts.patch b/leaf-server/minecraft-patches/features/0211-Paper-PR-Throttle-failed-spawn-attempts.patch index ee31b121..18c67d57 100644 --- a/leaf-server/minecraft-patches/features/0211-Paper-PR-Throttle-failed-spawn-attempts.patch +++ b/leaf-server/minecraft-patches/features/0211-Paper-PR-Throttle-failed-spawn-attempts.patch @@ -175,7 +175,7 @@ index 686c031ec73acc80683aaa39a78fe9221f0215a6..7fc5e56586f2fe8ea1a7437b42da8933 // Paper start - rewrite chunk system private volatile ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles; diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index e04d3479383cd480cf35ed7ac3c82e7f6fb69e28..2c10d216929fbc7f00385e4baac3aa60c203b799 100644 +index e04d3479383cd480cf35ed7ac3c82e7f6fb69e28..08b98e60518027a6d0aa99d03ba02982355ffa76 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -94,6 +94,7 @@ public record SerializableChunkData( @@ -214,23 +214,21 @@ index e04d3479383cd480cf35ed7ac3c82e7f6fb69e28..2c10d216929fbc7f00385e4baac3aa60 ); } } -@@ -426,6 +441,15 @@ public record SerializableChunkData( +@@ -426,6 +441,13 @@ public record SerializableChunkData( chunkAccess.addPackedPostProcess(this.postProcessingSections[i], i); } + // Paper PR start - throttle failed spawn attempts + long[] failedSpawnAttemptsData = this.failedSpawnAttempts; + if (failedSpawnAttemptsData != null) { -+ for (net.minecraft.world.entity.MobCategory mobCategory : net.minecraft.world.entity.MobCategory.values()) { -+ System.arraycopy(failedSpawnAttemptsData, 0, chunkAccess.failedSpawnAttempts, 0, failedSpawnAttemptsData.length); -+ } ++ System.arraycopy(failedSpawnAttemptsData, 0, chunkAccess.failedSpawnAttempts, 0, failedSpawnAttemptsData.length); + } + // Paper PR end - throttle failed spawn attempts + if (chunkType == ChunkType.LEVELCHUNK) { return this.loadStarlightLightData(level, new ImposterProtoChunk((LevelChunk)chunkAccess, false)); // Paper - starlight } else { -@@ -556,6 +580,7 @@ public record SerializableChunkData( +@@ -556,6 +578,7 @@ public record SerializableChunkData( persistentDataContainer = chunk.persistentDataContainer.toTagCompound(); } // CraftBukkit end @@ -238,7 +236,7 @@ index e04d3479383cd480cf35ed7ac3c82e7f6fb69e28..2c10d216929fbc7f00385e4baac3aa60 return new SerializableChunkData( level.registryAccess().lookupOrThrow(Registries.BIOME), pos, -@@ -576,6 +601,7 @@ public record SerializableChunkData( +@@ -576,6 +599,7 @@ public record SerializableChunkData( list1, compoundTag , persistentDataContainer // CraftBukkit - persistentDataContainer @@ -246,7 +244,7 @@ index e04d3479383cd480cf35ed7ac3c82e7f6fb69e28..2c10d216929fbc7f00385e4baac3aa60 ); } } -@@ -660,6 +686,21 @@ public record SerializableChunkData( +@@ -660,6 +684,21 @@ public record SerializableChunkData( compoundTag.put("ChunkBukkitValues", this.persistentDataContainer); } // CraftBukkit end @@ -268,7 +266,7 @@ index e04d3479383cd480cf35ed7ac3c82e7f6fb69e28..2c10d216929fbc7f00385e4baac3aa60 // Paper start - starlight if (this.lightCorrect && !this.chunkStatus.isBefore(net.minecraft.world.level.chunk.status.ChunkStatus.LIGHT)) { // clobber vanilla value to force vanilla to relight -@@ -875,4 +916,50 @@ public record SerializableChunkData( +@@ -875,4 +914,50 @@ public record SerializableChunkData( } // Paper end - starlight - convert from record } diff --git a/leaf-server/minecraft-patches/features/0225-Optimise-chunkUnloads.patch b/leaf-server/minecraft-patches/features/0225-Optimise-chunkUnloads.patch index 9a15fc3b..d73ae425 100644 --- a/leaf-server/minecraft-patches/features/0225-Optimise-chunkUnloads.patch +++ b/leaf-server/minecraft-patches/features/0225-Optimise-chunkUnloads.patch @@ -159,10 +159,10 @@ index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..bed3a64388bb43e47c2ba4e67f7dde5b public static final class SaveState { diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989a2b3627b 100644 +index 08b98e60518027a6d0aa99d03ba02982355ffa76..bbb871f011e947e426f8be32f0ab71aded4e0980 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -495,14 +495,16 @@ public record SerializableChunkData( +@@ -493,14 +493,16 @@ public record SerializableChunkData( throw new IllegalArgumentException("Chunk can't be serialized: " + chunk); } else { ChunkPos pos = chunk.getPos(); @@ -182,7 +182,7 @@ index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989 final LevelChunkSection[] chunkSections = chunk.getSections(); final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles = ((ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk)chunk).starlight$getBlockNibbles(); -@@ -520,10 +522,20 @@ public record SerializableChunkData( +@@ -518,10 +520,20 @@ public record SerializableChunkData( continue; } @@ -206,7 +206,7 @@ index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989 ); if (blockNibble != null) { -@@ -534,12 +546,16 @@ public record SerializableChunkData( +@@ -532,12 +544,16 @@ public record SerializableChunkData( ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)sectionData).starlight$setSkyLightState(skyNibble.state); } @@ -225,7 +225,7 @@ index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989 for (BlockPos blockPos : chunk.getBlockEntitiesPos()) { CompoundTag blockEntityNbtForSaving = chunk.getBlockEntityNbtForSaving(blockPos, level.registryAccess()); if (blockEntityNbtForSaving != null) { -@@ -547,15 +563,27 @@ public record SerializableChunkData( +@@ -545,15 +561,27 @@ public record SerializableChunkData( } } @@ -255,7 +255,7 @@ index 2c10d216929fbc7f00385e4baac3aa60c203b799..0ef9e974bc848b5273f002751628a989 } Map map = new EnumMap<>(Heightmap.Types.class); -@@ -563,14 +591,26 @@ public record SerializableChunkData( +@@ -561,14 +589,26 @@ public record SerializableChunkData( for (Entry entry : chunk.getHeightmaps()) { if (chunk.getPersistedStatus().heightmapsAfter().contains(entry.getKey())) { long[] rawData = entry.getValue().getRawData();