Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
1cfd363d32
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: fc460d1b PR-735: Add Villager#zombify c8c8331e PR-690: Add method to read ItemStack input 62845f2f SPIGOT-6829: Add per-player world border API CraftBukkit Changes: a459f4d4 PR-1033: Add Villager#zombify d65d1430 PR-975: Add method to read ItemStack input b5559f8c SPIGOT-6990: Fix setRepairCost(0) in Anvil 6c308e1b SPIGOT-6829: Add per-player world border API Spigot Changes: 42b61526 SPIGOT-7000: Generation and /locate issues when using custom structure seeds
75 Zeilen
5.2 KiB
Diff
75 Zeilen
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
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 b079677723ff65f64adec044e7d89656ecc49e4d..583d2deffa819c1aa25e1937a7f709d0d6bab294 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<TickTa
|
|
this.resources.managers.updateRegistryTags(this.registryAccess());
|
|
io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper
|
|
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 344c5bafe291a2542c4940e4d80232644de7b877..00e6f60e13f50c727530de37ab9692ad3683c11b 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1793,7 +1793,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 f807ee757488f05be626643e009eac95245b3af1..4d0c2b29d43c420bb603298adc6c35941724ff53 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());
|
|
}
|
|
|