aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2022-03-01 14:40:34 -0800
committerGitHub <[email protected]>2022-03-01 14:40:34 -0800
commit178802ab94714d68c0833f53fbc9de0764ab0f8b (patch)
tree1955b2896194928c768c94cd809f32a6bfc11832
parent14add2b04979800dff8f6cff601bd85fb462ce78 (diff)
downloadPaper-178802ab94714d68c0833f53fbc9de0764ab0f8b.tar.gz
Paper-178802ab94714d68c0833f53fbc9de0764ab0f8b.zip
Fix various 1.18.2 update issues (#7523)
-rw-r--r--patches/server/0774-Optimise-WorldServer-notify.patch2
-rw-r--r--patches/server/0875-Fix-Fluid-tags-isTagged-method.patch32
-rw-r--r--patches/server/0876-Fix-World-locateNearestStructure.patch74
3 files changed, 107 insertions, 1 deletions
diff --git a/patches/server/0774-Optimise-WorldServer-notify.patch b/patches/server/0774-Optimise-WorldServer-notify.patch
index 54f133235c..6cfd3dac52 100644
--- a/patches/server/0774-Optimise-WorldServer-notify.patch
+++ b/patches/server/0774-Optimise-WorldServer-notify.patch
@@ -8,7 +8,7 @@ Instead, only iterate over navigators in the current region that are
eligible for repathing.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
-index 6c7a9ad153eb5c08852602ca73a630aa61a58e0c..5ba598c136bca2be1badd41e9cfba39ee5f02994 100644
+index 9a269f0ab59b4ea2ce01957f89677d2f304ebf02..b6a17bb19a45ccd4bfc4be5f177a792a9a3727f5 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -301,15 +301,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
diff --git a/patches/server/0875-Fix-Fluid-tags-isTagged-method.patch b/patches/server/0875-Fix-Fluid-tags-isTagged-method.patch
new file mode 100644
index 0000000000..51e7ed638e
--- /dev/null
+++ b/patches/server/0875-Fix-Fluid-tags-isTagged-method.patch
@@ -0,0 +1,32 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Tue, 1 Mar 2022 12:45:50 -0800
+Subject: [PATCH] Fix Fluid tags isTagged method
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java
+index f0fa928a66140293166dddc37eee50a2041560ed..eb29131934370ea2865f8feee93ec3cb5490c4b1 100644
+--- a/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java
++++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftFluidTag.java
+@@ -16,7 +16,7 @@ public class CraftFluidTag extends CraftTag<net.minecraft.world.level.material.F
+
+ @Override
+ public boolean isTagged(Fluid fluid) {
+- return CraftMagicNumbers.getFluid(fluid).is(tag);
++ return registry.getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.Registry.FLUID_REGISTRY, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(fluid.getKey()))).is(tag); // Paper
+ }
+
+ @Override
+diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+index d8f4d351a66c6d1e60e1a470ce64f538c7718232..88c58676e6d2eb618596cd118257cbf7973396a9 100644
+--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+@@ -198,7 +198,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
+ return CraftMagicNumbers.MATERIAL_BLOCK.get(material);
+ }
+
+- public static net.minecraft.world.level.material.Fluid getFluid(Fluid fluid) {
++ public static net.minecraft.world.level.material.Fluid getFluid(Material fluid) { // Paper - wrong type
+ return CraftMagicNumbers.MATERIAL_FLUID.get(fluid);
+ }
+
diff --git a/patches/server/0876-Fix-World-locateNearestStructure.patch b/patches/server/0876-Fix-World-locateNearestStructure.patch
new file mode 100644
index 0000000000..0006208930
--- /dev/null
+++ b/patches/server/0876-Fix-World-locateNearestStructure.patch
@@ -0,0 +1,74 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Tue, 1 Mar 2022 14:12:17 -0800
+Subject: [PATCH] Fix World#locateNearestStructure
+
+1.18.2 switched to TagKeys to reference tags of objects, and this method
+ 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 0a0bc8c45cb70073cb94dee25b5e54fb98bf9c8e..3a9c27ece0ad18b2c4686164766794c56fcea268 100644
+--- a/src/main/java/net/minecraft/server/MinecraftServer.java
++++ b/src/main/java/net/minecraft/server/MinecraftServer.java
+@@ -2061,6 +2061,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
+ this.resources.managers.updateRegistryTags(this.registryAccess());
+ net.minecraft.world.item.alchemy.PotionBrewing.reload(); // Paper
++ // Paper start - clear cache cause datapacks can add more configured structures
++ for (ServerLevel level : this.levels.values()) {
++ level.getWorld().structureCache.clear();
++ }
++ // Paper end
+ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
+ if (Thread.currentThread() != this.serverThread) return; // Paper
+ //this.getPlayerList().saveAll(); // Paper - we don't need to do this
+diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
+index 8e87aca16879d7dd1dc0bd17d3215fca40b547cd..b5b56d4549e97abbbe9e91d881b9bca8428f1eec 100644
+--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
+@@ -1790,7 +1790,16 @@ public class ServerLevel extends Level implements WorldGenLevel {
+ if (optional.isEmpty()) {
+ return null;
+ } else {
+- Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> pair = this.getChunkSource().getGenerator().findNearestMapFeature(this, (HolderSet) optional.get(), pos, radius, skipExistingChunks);
++ // Paper start
++ return this.findNearestMapFeature(optional.get(), pos, radius, skipExistingChunks);
++ }
++ }
++ }
++ public @Nullable BlockPos findNearestMapFeature(HolderSet<ConfiguredStructureFeature<?, ?>> holderSet, BlockPos pos, int radius, boolean skipExistingChunks) {
++ {
++ {
++ Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> pair = this.getChunkSource().getGenerator().findNearestMapFeature(this, holderSet, pos, radius, skipExistingChunks);
++ // 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 a3ddeb9862bc87294c215dc906cd8cca8f699b62..b2c5fbfcb64f3056d7975db43b2db45bfd5e9890 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+@@ -2071,10 +2071,22 @@ public class CraftWorld extends CraftRegionAccessor implements World {
+
+ }
+
++ public final Map<StructureType, List<Holder.Reference<net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature<?, ?>>>> 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);
++ // Paper start - fix because you can't just create random TagKeys
++ if (!this.getHandle().serverLevelData.worldGenSettings().generateFeatures()) { // from ServerLevel#findNearestMapFeature
++ return null;
++ }
++ final List<Holder.Reference<net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature<?, ?>>> features = this.structureCache.computeIfAbsent(structureType, (type) -> {
++ final Registry<net.minecraft.world.level.levelgen.feature.StructureFeature<?>> 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))));
++ }).toList();
++ });
++ BlockPos nearest = this.getHandle().findNearestMapFeature(net.minecraft.core.HolderSet.direct(features), originPos, radius, findUnexplored);
++ // Paper end
+ return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
+ }
+