From 1b5b2d8d45a3dec67364c5970f27a05975247528 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 14 Dec 2024 18:43:42 -0800 Subject: [PATCH] net.minecraft.world.level.chunk.status --- .../chunk/status/ChunkStatusTasks.java.patch | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch (58%) diff --git a/paper-server/patches/unapplied/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch similarity index 58% rename from paper-server/patches/unapplied/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch rename to paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch index 9f0303442..30e279c28 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch @@ -1,46 +1,38 @@ --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -@@ -36,7 +36,7 @@ - static CompletableFuture generateStructureStarts(WorldGenContext context, ChunkStep step, StaticCache2D chunks, ChunkAccess chunk) { - ServerLevel worldserver = context.level(); - -- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) { -+ if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit - context.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), chunk, context.structureManager(), worldserver.dimension()); - } - -@@ -151,7 +151,7 @@ - if (protochunk instanceof ImposterProtoChunk protochunkextension) { - chunk1 = protochunkextension.getWrapped(); - } else { -- chunk1 = new LevelChunk(worldserver, protochunk, (chunk1) -> { -+ chunk1 = new LevelChunk(worldserver, protochunk, ($) -> { // Paper - decompile fix - ChunkStatusTasks.postLoadProtoChunk(worldserver, protochunk.getEntities()); - }); - generationchunkholder.replaceProtoChunk(new ImposterProtoChunk(chunk1, false)); -@@ -168,10 +168,61 @@ - }, context.mainThreadExecutor()); +@@ -35,7 +_,7 @@ + WorldGenContext worldGenContext, ChunkStep step, StaticCache2D cache, ChunkAccess chunk + ) { + ServerLevel serverLevel = worldGenContext.level(); +- if (serverLevel.getServer().getWorldData().worldGenOptions().generateStructures()) { ++ if (serverLevel.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit + worldGenContext.generator() + .createStructures( + serverLevel.registryAccess(), +@@ -196,9 +_,60 @@ + }, worldGenContext.mainThreadExecutor()); } -- private static void postLoadProtoChunk(ServerLevel world, List entities) { -+ public static void postLoadProtoChunk(ServerLevel world, List entities) { // Paper - public - if (!entities.isEmpty()) { -- world.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entities, world, EntitySpawnReason.LOAD)); +- private static void postLoadProtoChunk(ServerLevel level, List entityTags) { ++ public static void postLoadProtoChunk(ServerLevel level, List entityTags) { // Paper - public + if (!entityTags.isEmpty()) { +- level.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entityTags, level, EntitySpawnReason.LOAD)); +- } +- } + // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities -+ world.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entities, world, EntitySpawnReason.LOAD).filter((entity) -> { ++ level.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entityTags, level, EntitySpawnReason.LOAD).filter((entity) -> { + boolean needsRemoval = false; -+ net.minecraft.server.dedicated.DedicatedServer server = world.getCraftServer().getServer(); -+ if (!world.getChunkSource().spawnFriendlies && (entity instanceof net.minecraft.world.entity.animal.Animal || entity instanceof net.minecraft.world.entity.animal.WaterAnimal)) { ++ net.minecraft.server.dedicated.DedicatedServer server = level.getCraftServer().getServer(); ++ if (!level.getChunkSource().spawnFriendlies && (entity instanceof net.minecraft.world.entity.animal.Animal || entity instanceof net.minecraft.world.entity.animal.WaterAnimal)) { + entity.discard(null); // CraftBukkit - add Bukkit remove cause + needsRemoval = true; + } -+ checkDupeUUID(world, entity); // Paper - duplicate uuid resolving ++ checkDupeUUID(level, entity); // Paper - duplicate uuid resolving + return !needsRemoval; + })); + // CraftBukkit end - } - - } ++ } ++ } + + // Paper start - duplicate uuid resolving + // rets true if to prevent the entity from being added @@ -58,7 +50,7 @@ + } + + if (mode == io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.SAFE_REGEN && other != null && !other.isRemoved() -+ && Objects.equals(other.getEncodeId(), entity.getEncodeId()) ++ && java.util.Objects.equals(other.getEncodeId(), entity.getEncodeId()) + && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < level.paperConfig().entities.spawning.duplicateUuid.safeRegenDeleteRange + ) { + entity.discard(null);