diff --git a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch index 1afccac676..d6e612c7d3 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/PlayerChunkMap.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java -@@ -102,6 +102,11 @@ +@@ -102,6 +102,12 @@ import org.apache.commons.lang3.mutable.MutableObject; import org.slf4j.Logger; +// CraftBukkit start +import net.minecraft.world.level.levelgen.GeneratorSettings; ++import org.bukkit.craftbukkit.generator.CustomChunkGenerator; +import org.bukkit.entity.Player; +// CraftBukkit end + public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e { private static final byte CHUNK_TYPE_REPLACEABLE = -1; -@@ -144,6 +149,27 @@ +@@ -144,6 +150,27 @@ private final Queue unloadQueue; int viewDistance; @@ -40,7 +41,19 @@ public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier supplier, int i, boolean flag) { super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); this.visibleChunkMap = this.updatingChunkMap.clone(); -@@ -313,9 +339,12 @@ +@@ -162,6 +189,11 @@ + this.storageName = path.getFileName().toString(); + this.level = worldserver; + this.generator = chunkgenerator; ++ // CraftBukkit start - SPIGOT-7051: It's a rigged game! Use delegate for random state creation, otherwise it is not so random. ++ if (chunkgenerator instanceof CustomChunkGenerator) { ++ chunkgenerator = ((CustomChunkGenerator) chunkgenerator).getDelegate(); ++ } ++ // CraftBukkit end + if (chunkgenerator instanceof ChunkGeneratorAbstract) { + ChunkGeneratorAbstract chunkgeneratorabstract = (ChunkGeneratorAbstract) chunkgenerator; + +@@ -313,9 +345,12 @@ CompletableFuture>> completablefuture1 = SystemUtils.sequence(list); CompletableFuture, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> { List list3 = Lists.newArrayList(); @@ -55,7 +68,7 @@ final Either either = (Either) iterator.next(); if (either == null) { -@@ -520,7 +549,7 @@ +@@ -520,7 +555,7 @@ private void scheduleUnload(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkToSave(); @@ -64,7 +77,7 @@ CompletableFuture completablefuture1 = playerchunk.getChunkToSave(); if (completablefuture1 != completablefuture) { -@@ -609,9 +638,9 @@ +@@ -609,9 +644,9 @@ ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get()); this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType()); @@ -76,7 +89,7 @@ } }, this.mainThreadExecutor).exceptionallyAsync((throwable) -> { return this.handleChunkLoadFailure(throwable, chunkcoordintpair); -@@ -717,7 +746,21 @@ +@@ -717,7 +752,21 @@ private static void postLoadProtoChunk(WorldServer worldserver, List list) { if (!list.isEmpty()) { @@ -99,7 +112,7 @@ } } -@@ -816,7 +859,7 @@ +@@ -816,7 +865,7 @@ if (!playerchunk.wasAccessibleSinceLastSave()) { return false; } else { @@ -108,7 +121,7 @@ if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) { return false; -@@ -978,7 +1021,8 @@ +@@ -978,7 +1027,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -118,7 +131,7 @@ return chunk.getBlockEntities().size(); }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { return chunk.getBlockTicks().count(); -@@ -991,7 +1035,7 @@ +@@ -991,7 +1041,7 @@ private static String printFuture(CompletableFuture> completablefuture) { try { @@ -127,7 +140,7 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -1007,12 +1051,14 @@ +@@ -1007,12 +1057,14 @@ private CompletableFuture> readChunk(ChunkCoordIntPair chunkcoordintpair) { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { @@ -145,7 +158,7 @@ } boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { -@@ -1433,7 +1479,7 @@ +@@ -1433,7 +1485,7 @@ public final Set seenBy = Sets.newIdentityHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -154,7 +167,7 @@ this.entity = entity; this.range = i; this.lastSectionPos = SectionPosition.of((EntityAccess) entity); -@@ -1492,6 +1538,11 @@ +@@ -1492,6 +1544,11 @@ double d2 = d0 * d0; boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index d062f038e6..73c51a18b1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -92,6 +92,10 @@ public class CustomChunkGenerator extends InternalChunkGenerator { this.generator = generator; } + public net.minecraft.world.level.chunk.ChunkGenerator getDelegate() { + return delegate; + } + private static SeededRandom getSeededRandom() { return new SeededRandom(new LegacyRandomSource(0)); }