From 9ab6893183cd221fd9754ba2f75b897731d94d36 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 8 Jun 2022 07:46:01 -0700 Subject: [PATCH] Add back Fix locateNearestStructure patch --- ...56-Fix-World-locateNearestStructure.patch} | 34 +++++++++---------- ...57-Force-close-world-loading-screen.patch} | 0 ...858-Fix-falling-block-spawn-methods.patch} | 2 +- ...Expose-furnace-minecart-push-values.patch} | 0 ...ojectileHitEvent-for-piercing-arrow.patch} | 0 ... 0861-Fix-save-problems-on-shutdown.patch} | 4 +-- ...I.patch => 0862-More-Projectile-API.patch} | 0 ...le-movement-from-players-while-tele.patch} | 0 ...0864-Implement-getComputedBiome-API.patch} | 0 ...> 0865-Make-some-itemstacks-nonnull.patch} | 0 ...alid-GameProfiles-on-skull-blocks-i.patch} | 0 ...867-Implement-enchantWithLevels-API.patch} | 0 ...h => 0868-Fix-saving-in-unloadWorld.patch} | 0 ...h => 0869-Buffer-OOB-setBlock-calls.patch} | 0 ... 0870-Add-TameableDeathMessageEvent.patch} | 0 ...a-for-EntityChangeBlockEvent-when-s.patch} | 0 ...bles-running-when-mob-loot-gamerule.patch} | 0 ...ssenger-world-matches-ridden-entity.patch} | 0 ...rd-against-invalid-entity-positions.patch} | 0 ...s.patch => 0875-cache-resource-keys.patch} | 0 ...ange-the-podium-for-the-EnderDragon.patch} | 0 ...erriding-a-block-entity-during-worl.patch} | 0 ...eGrowEvent-species-for-RED_MUSHROOM.patch} | 0 ...t-tile-entity-copies-loading-chunks.patch} | 0 ...ead-of-display-name-in-PlayerList-g.patch} | 0 ...s-not-spawning-outside-slime-chunks.patch} | 0 ...-ServerLevel-for-gamerule-callbacks.patch} | 2 +- ...ing-amount-to-PlayerItemDamageEvent.patch} | 0 ...> 0884-WorldCreator-keepSpawnLoaded.patch} | 0 ...-NPE-for-BlockDataMeta-getBlockData.patch} | 0 ...destroyed-trigger-in-the-correct-pl.patch} | 0 ...Event-and-CollarColorable-interface.patch} | 0 ...CauldronLevelChange-on-initial-fill.patch} | 0 ...snow-cauldrons-not-turning-to-water.patch} | 0 ...atch => 0890-Sign-cleanup-filtering.patch} | 0 ...> 0891-Add-PlayerStopUsingItemEvent.patch} | 0 ...92-FallingBlock-auto-expire-setting.patch} | 0 ...rs.patch => 0893-Don-t-tick-markers.patch} | 4 +-- ...-not-accept-invalid-client-settings.patch} | 0 ...0895-Add-support-for-Proxy-Protocol.patch} | 0 ...x-OfflinePlayer-getBedSpawnLocation.patch} | 0 ...tory-for-smokers-and-blast-furnaces.patch} | 0 ... 0898-Sanitize-Sent-BlockEntity-NBT.patch} | 0 ...ntity-loading-causing-async-lookups.patch} | 0 ...-selector-resolving-in-books-by-def.patch} | 0 ...-on-world-create-while-being-ticked.patch} | 2 +- 46 files changed, 24 insertions(+), 24 deletions(-) rename patches/{removed/1.19/0865-Fix-World-locateNearestStructure.patch => server/0856-Fix-World-locateNearestStructure.patch} (60%) rename patches/server/{0856-Force-close-world-loading-screen.patch => 0857-Force-close-world-loading-screen.patch} (100%) rename patches/server/{0857-Fix-falling-block-spawn-methods.patch => 0858-Fix-falling-block-spawn-methods.patch} (97%) rename patches/server/{0858-Expose-furnace-minecart-push-values.patch => 0859-Expose-furnace-minecart-push-values.patch} (100%) rename patches/server/{0859-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch => 0860-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch} (100%) rename patches/server/{0860-Fix-save-problems-on-shutdown.patch => 0861-Fix-save-problems-on-shutdown.patch} (94%) rename patches/server/{0861-More-Projectile-API.patch => 0862-More-Projectile-API.patch} (100%) rename patches/server/{0862-Don-t-allow-vehicle-movement-from-players-while-tele.patch => 0863-Don-t-allow-vehicle-movement-from-players-while-tele.patch} (100%) rename patches/server/{0863-Implement-getComputedBiome-API.patch => 0864-Implement-getComputedBiome-API.patch} (100%) rename patches/server/{0864-Make-some-itemstacks-nonnull.patch => 0865-Make-some-itemstacks-nonnull.patch} (100%) rename patches/server/{0865-Add-debug-for-invalid-GameProfiles-on-skull-blocks-i.patch => 0866-Add-debug-for-invalid-GameProfiles-on-skull-blocks-i.patch} (100%) rename patches/server/{0866-Implement-enchantWithLevels-API.patch => 0867-Implement-enchantWithLevels-API.patch} (100%) rename patches/server/{0867-Fix-saving-in-unloadWorld.patch => 0868-Fix-saving-in-unloadWorld.patch} (100%) rename patches/server/{0868-Buffer-OOB-setBlock-calls.patch => 0869-Buffer-OOB-setBlock-calls.patch} (100%) rename patches/server/{0869-Add-TameableDeathMessageEvent.patch => 0870-Add-TameableDeathMessageEvent.patch} (100%) rename patches/server/{0870-Fix-new-block-data-for-EntityChangeBlockEvent-when-s.patch => 0871-Fix-new-block-data-for-EntityChangeBlockEvent-when-s.patch} (100%) rename patches/server/{0871-fix-player-loottables-running-when-mob-loot-gamerule.patch => 0872-fix-player-loottables-running-when-mob-loot-gamerule.patch} (100%) rename patches/server/{0872-Ensure-entity-passenger-world-matches-ridden-entity.patch => 0873-Ensure-entity-passenger-world-matches-ridden-entity.patch} (100%) rename patches/server/{0873-Guard-against-invalid-entity-positions.patch => 0874-Guard-against-invalid-entity-positions.patch} (100%) rename patches/server/{0874-cache-resource-keys.patch => 0875-cache-resource-keys.patch} (100%) rename patches/server/{0875-Allow-to-change-the-podium-for-the-EnderDragon.patch => 0876-Allow-to-change-the-podium-for-the-EnderDragon.patch} (100%) rename patches/server/{0876-Fix-NBT-pieces-overriding-a-block-entity-during-worl.patch => 0877-Fix-NBT-pieces-overriding-a-block-entity-during-worl.patch} (100%) rename patches/server/{0877-Fix-StructureGrowEvent-species-for-RED_MUSHROOM.patch => 0878-Fix-StructureGrowEvent-species-for-RED_MUSHROOM.patch} (100%) rename patches/server/{0878-Prevent-tile-entity-copies-loading-chunks.patch => 0879-Prevent-tile-entity-copies-loading-chunks.patch} (100%) rename patches/server/{0879-Use-username-instead-of-display-name-in-PlayerList-g.patch => 0880-Use-username-instead-of-display-name-in-PlayerList-g.patch} (100%) rename patches/server/{0880-Fix-slime-spawners-not-spawning-outside-slime-chunks.patch => 0881-Fix-slime-spawners-not-spawning-outside-slime-chunks.patch} (100%) rename patches/server/{0881-Pass-ServerLevel-for-gamerule-callbacks.patch => 0882-Pass-ServerLevel-for-gamerule-callbacks.patch} (99%) rename patches/server/{0882-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch => 0883-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch} (100%) rename patches/server/{0883-WorldCreator-keepSpawnLoaded.patch => 0884-WorldCreator-keepSpawnLoaded.patch} (100%) rename patches/server/{0884-Fix-NPE-for-BlockDataMeta-getBlockData.patch => 0885-Fix-NPE-for-BlockDataMeta-getBlockData.patch} (100%) rename patches/server/{0885-Trigger-bee_nest_destroyed-trigger-in-the-correct-pl.patch => 0886-Trigger-bee_nest_destroyed-trigger-in-the-correct-pl.patch} (100%) rename patches/server/{0886-Add-EntityDyeEvent-and-CollarColorable-interface.patch => 0887-Add-EntityDyeEvent-and-CollarColorable-interface.patch} (100%) rename patches/server/{0887-Fire-CauldronLevelChange-on-initial-fill.patch => 0888-Fire-CauldronLevelChange-on-initial-fill.patch} (100%) rename patches/server/{0888-fix-powder-snow-cauldrons-not-turning-to-water.patch => 0889-fix-powder-snow-cauldrons-not-turning-to-water.patch} (100%) rename patches/server/{0889-Sign-cleanup-filtering.patch => 0890-Sign-cleanup-filtering.patch} (100%) rename patches/server/{0890-Add-PlayerStopUsingItemEvent.patch => 0891-Add-PlayerStopUsingItemEvent.patch} (100%) rename patches/server/{0891-FallingBlock-auto-expire-setting.patch => 0892-FallingBlock-auto-expire-setting.patch} (100%) rename patches/server/{0892-Don-t-tick-markers.patch => 0893-Don-t-tick-markers.patch} (94%) rename patches/server/{0893-Do-not-accept-invalid-client-settings.patch => 0894-Do-not-accept-invalid-client-settings.patch} (100%) rename patches/server/{0894-Add-support-for-Proxy-Protocol.patch => 0895-Add-support-for-Proxy-Protocol.patch} (100%) rename patches/server/{0895-Fix-OfflinePlayer-getBedSpawnLocation.patch => 0896-Fix-OfflinePlayer-getBedSpawnLocation.patch} (100%) rename patches/server/{0896-Fix-FurnaceInventory-for-smokers-and-blast-furnaces.patch => 0897-Fix-FurnaceInventory-for-smokers-and-blast-furnaces.patch} (100%) rename patches/server/{0897-Sanitize-Sent-BlockEntity-NBT.patch => 0898-Sanitize-Sent-BlockEntity-NBT.patch} (100%) rename patches/server/{0898-Prevent-entity-loading-causing-async-lookups.patch => 0899-Prevent-entity-loading-causing-async-lookups.patch} (100%) rename patches/server/{0899-Disable-component-selector-resolving-in-books-by-def.patch => 0900-Disable-component-selector-resolving-in-books-by-def.patch} (100%) rename patches/server/{0900-Throw-exception-on-world-create-while-being-ticked.patch => 0901-Throw-exception-on-world-create-while-being-ticked.patch} (96%) diff --git a/patches/removed/1.19/0865-Fix-World-locateNearestStructure.patch b/patches/server/0856-Fix-World-locateNearestStructure.patch similarity index 60% rename from patches/removed/1.19/0865-Fix-World-locateNearestStructure.patch rename to patches/server/0856-Fix-World-locateNearestStructure.patch index 61bc242b34..6add754c8e 100644 --- a/patches/removed/1.19/0865-Fix-World-locateNearestStructure.patch +++ b/patches/server/0856-Fix-World-locateNearestStructure.patch @@ -7,10 +7,10 @@ Subject: [PATCH] Fix World#locateNearestStructure impl needs to be changed to reflect that diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index b079677723ff65f64adec044e7d89656ecc49e4d..583d2deffa819c1aa25e1937a7f709d0d6bab294 100644 +index 33953cc7afc2616577b768a23a7d4ce0230cf480..b37c8c5801b87a24cd26675c3bf4bd2c83c9ba2c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2056,6 +2056,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop>> pair = this.getChunkSource().getGenerator().findNearestMapFeature(this, (HolderSet) optional.get(), pos, radius, skipExistingChunks); +- Pair> pair = this.getChunkSource().getGenerator().findNearestMapStructure(this, (HolderSet) optional.get(), pos, radius, skipReferencedStructures); + // Paper start -+ return this.findNearestMapFeature(optional.get(), pos, radius, skipExistingChunks); ++ return this.findNearestMapFeature(optional.get(), pos, radius, skipReferencedStructures); + } + } + } -+ public @Nullable BlockPos findNearestMapFeature(HolderSet> holderSet, BlockPos pos, int radius, boolean skipExistingChunks) { ++ public @Nullable BlockPos findNearestMapFeature(HolderSet holderSet, BlockPos pos, int radius, boolean skipReferencedStructures) { + { + { -+ Pair>> pair = this.getChunkSource().getGenerator().findNearestMapFeature(this, holderSet, pos, radius, skipExistingChunks); ++ Pair> pair = this.getChunkSource().getGenerator().findNearestMapStructure(this, holderSet, pos, radius, skipReferencedStructures); + // Paper end return pair != null ? (BlockPos) pair.getFirst() : null; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index dd3aac2b8058f09fdd6dce9c1c683725b3594cfd..1a07887345f46582949090b685dae507aaba84f4 100644 +index 2e9b782e34ae25e982b45011a36c3b08ab298648..7cdeaeed4fa2d830ef03b26baf6d17ddc3d5e521 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2060,10 +2060,22 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2059,10 +2059,22 @@ public class CraftWorld extends CraftRegionAccessor implements World { } -+ public final Map>>> structureCache = new java.util.HashMap<>(); // Paper ++ public final Map>> structureCache = new java.util.HashMap<>(); // Paper @Override public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { BlockPos originPos = new BlockPos(origin.getX(), origin.getY(), origin.getZ()); -- BlockPos nearest = this.getHandle().findNearestMapFeature(TagKey.create(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, CraftNamespacedKey.toMinecraft(structureType.getKey())), originPos, radius, findUnexplored); +- BlockPos nearest = this.getHandle().findNearestMapStructure(TagKey.create(Registry.STRUCTURE_REGISTRY, CraftNamespacedKey.toMinecraft(structureType.getKey())), originPos, radius, findUnexplored); + // Paper start - fix because you can't just create random TagKeys -+ if (!this.getHandle().serverLevelData.worldGenSettings().generateFeatures()) { // from ServerLevel#findNearestMapFeature ++ if (!this.getHandle().serverLevelData.worldGenSettings().generateStructures()) { // from ServerLevel#findNearestMapStructure + return null; + } -+ final List>> features = this.structureCache.computeIfAbsent(structureType, (type) -> { -+ final Registry> structureFeatureRegistry = this.getHandle().registryAccess().registryOrThrow(Registry.STRUCTURE_FEATURE_REGISTRY); -+ return this.getHandle().registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).holders().filter(holder -> { -+ return structureType.getKey().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(Objects.requireNonNull(structureFeatureRegistry.getKey(holder.value().feature)))); ++ final List> features = this.structureCache.computeIfAbsent(structureType, (type) -> { ++ final Registry> structureFeatureRegistry = this.getHandle().registryAccess().registryOrThrow(Registry.STRUCTURE_TYPE_REGISTRY); ++ return this.getHandle().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).holders().filter(holder -> { ++ return structureType.getKey().equals(CraftNamespacedKey.fromMinecraft(Objects.requireNonNull(structureFeatureRegistry.getKey(holder.value().type())))); + }).toList(); + }); + BlockPos nearest = this.getHandle().findNearestMapFeature(net.minecraft.core.HolderSet.direct(features), originPos, radius, findUnexplored); diff --git a/patches/server/0856-Force-close-world-loading-screen.patch b/patches/server/0857-Force-close-world-loading-screen.patch similarity index 100% rename from patches/server/0856-Force-close-world-loading-screen.patch rename to patches/server/0857-Force-close-world-loading-screen.patch diff --git a/patches/server/0857-Fix-falling-block-spawn-methods.patch b/patches/server/0858-Fix-falling-block-spawn-methods.patch similarity index 97% rename from patches/server/0857-Fix-falling-block-spawn-methods.patch rename to patches/server/0858-Fix-falling-block-spawn-methods.patch index e0fa906c8a..ff73c72339 100644 --- a/patches/server/0857-Fix-falling-block-spawn-methods.patch +++ b/patches/server/0858-Fix-falling-block-spawn-methods.patch @@ -21,7 +21,7 @@ index d1fca0e3227b5f37c11367548be362f5a49b6a71..5628940cd3c3566c5db2beda506d4f20 if (Snowball.class.isAssignableFrom(clazz)) { entity = new net.minecraft.world.entity.projectile.Snowball(world, x, y, z); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 2e9b782e34ae25e982b45011a36c3b08ab298648..e30cd412f30e26aa4c59f367b3cc26ba47e1b21c 100644 +index 7cdeaeed4fa2d830ef03b26baf6d17ddc3d5e521..cd852fa92d2fec20966a9ebf56484ce94584d74a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1410,7 +1410,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0858-Expose-furnace-minecart-push-values.patch b/patches/server/0859-Expose-furnace-minecart-push-values.patch similarity index 100% rename from patches/server/0858-Expose-furnace-minecart-push-values.patch rename to patches/server/0859-Expose-furnace-minecart-push-values.patch diff --git a/patches/server/0859-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch b/patches/server/0860-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch similarity index 100% rename from patches/server/0859-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch rename to patches/server/0860-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch diff --git a/patches/server/0860-Fix-save-problems-on-shutdown.patch b/patches/server/0861-Fix-save-problems-on-shutdown.patch similarity index 94% rename from patches/server/0860-Fix-save-problems-on-shutdown.patch rename to patches/server/0861-Fix-save-problems-on-shutdown.patch index 321e572a1b..99ab72022f 100644 --- a/patches/server/0860-Fix-save-problems-on-shutdown.patch +++ b/patches/server/0861-Fix-save-problems-on-shutdown.patch @@ -12,7 +12,7 @@ Subject: [PATCH] Fix save problems on shutdown processed so that the main process queue can be drained diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 33953cc7afc2616577b768a23a7d4ce0230cf480..869e0b6c8588d751a9b38b713119f888778d3387 100644 +index b37c8c5801b87a24cd26675c3bf4bd2c83c9ba2c..19640c290eb16c9e5afc842ec8ccac5a6a2ea4c7 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -953,6 +953,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop