Add back Fix locateNearestStructure patch

This commit is contained in:
Jake Potrebic 2022-06-08 07:46:01 -07:00
parent d5216d8588
commit 9ab6893183
No known key found for this signature in database
GPG Key ID: 27CC63F7CBC866C7
46 changed files with 24 additions and 24 deletions

View File

@ -7,10 +7,10 @@ Subject: [PATCH] Fix World#locateNearestStructure
impl needs to be changed to reflect that 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 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 --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/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 @@ -2022,6 +2022,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.resources.managers.updateRegistryTags(this.registryAccess()); this.resources.managers.updateRegistryTags(this.registryAccess());
io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper
net.minecraft.world.item.alchemy.PotionBrewing.reload(); // Paper net.minecraft.world.item.alchemy.PotionBrewing.reload(); // Paper
@ -23,48 +23,48 @@ index b079677723ff65f64adec044e7d89656ecc49e4d..583d2deffa819c1aa25e1937a7f709d0
if (Thread.currentThread() != this.serverThread) return; // Paper if (Thread.currentThread() != this.serverThread) return; // Paper
//this.getPlayerList().saveAll(); // Paper - we don't need to do this //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 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 index fb5c42755703ade855ab727c55c8d72456b59141..a127865e4aeaba4ab4d25b442f66497bd615a858 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/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 { @@ -1881,7 +1881,16 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (optional.isEmpty()) { if (optional.isEmpty()) {
return null; return null;
} else { } else {
- Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> pair = this.getChunkSource().getGenerator().findNearestMapFeature(this, (HolderSet) optional.get(), pos, radius, skipExistingChunks); - Pair<BlockPos, Holder<Structure>> pair = this.getChunkSource().getGenerator().findNearestMapStructure(this, (HolderSet) optional.get(), pos, radius, skipReferencedStructures);
+ // Paper start + // Paper start
+ return this.findNearestMapFeature(optional.get(), pos, radius, skipExistingChunks); + return this.findNearestMapFeature(optional.get(), pos, radius, skipReferencedStructures);
+ } + }
+ } + }
+ } + }
+ public @Nullable BlockPos findNearestMapFeature(HolderSet<ConfiguredStructureFeature<?, ?>> holderSet, BlockPos pos, int radius, boolean skipExistingChunks) { + public @Nullable BlockPos findNearestMapFeature(HolderSet<Structure> holderSet, BlockPos pos, int radius, boolean skipReferencedStructures) {
+ { + {
+ { + {
+ Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> pair = this.getChunkSource().getGenerator().findNearestMapFeature(this, holderSet, pos, radius, skipExistingChunks); + Pair<BlockPos, Holder<Structure>> pair = this.getChunkSource().getGenerator().findNearestMapStructure(this, holderSet, pos, radius, skipReferencedStructures);
+ // Paper end + // Paper end
return pair != null ? (BlockPos) pair.getFirst() : null; 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 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 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/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<StructureType, List<Holder.Reference<net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature<?, ?>>>> structureCache = new java.util.HashMap<>(); // Paper + public final Map<StructureType, List<Holder.Reference<net.minecraft.world.level.levelgen.structure.Structure>>> structureCache = new java.util.HashMap<>(); // Paper
@Override @Override
public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) {
BlockPos originPos = new BlockPos(origin.getX(), origin.getY(), origin.getZ()); 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 + // 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; + return null;
+ } + }
+ final List<Holder.Reference<net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature<?, ?>>> features = this.structureCache.computeIfAbsent(structureType, (type) -> { + final List<Holder.Reference<net.minecraft.world.level.levelgen.structure.Structure>> features = this.structureCache.computeIfAbsent(structureType, (type) -> {
+ final Registry<net.minecraft.world.level.levelgen.feature.StructureFeature<?>> structureFeatureRegistry = this.getHandle().registryAccess().registryOrThrow(Registry.STRUCTURE_FEATURE_REGISTRY); + final Registry<net.minecraft.world.level.levelgen.structure.StructureType<?>> structureFeatureRegistry = this.getHandle().registryAccess().registryOrThrow(Registry.STRUCTURE_TYPE_REGISTRY);
+ return this.getHandle().registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).holders().filter(holder -> { + return this.getHandle().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).holders().filter(holder -> {
+ return structureType.getKey().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(Objects.requireNonNull(structureFeatureRegistry.getKey(holder.value().feature)))); + return structureType.getKey().equals(CraftNamespacedKey.fromMinecraft(Objects.requireNonNull(structureFeatureRegistry.getKey(holder.value().type()))));
+ }).toList(); + }).toList();
+ }); + });
+ BlockPos nearest = this.getHandle().findNearestMapFeature(net.minecraft.core.HolderSet.direct(features), originPos, radius, findUnexplored); + BlockPos nearest = this.getHandle().findNearestMapFeature(net.minecraft.core.HolderSet.direct(features), originPos, radius, findUnexplored);

View File

@ -21,7 +21,7 @@ index d1fca0e3227b5f37c11367548be362f5a49b6a71..5628940cd3c3566c5db2beda506d4f20
if (Snowball.class.isAssignableFrom(clazz)) { if (Snowball.class.isAssignableFrom(clazz)) {
entity = new net.minecraft.world.entity.projectile.Snowball(world, x, y, z); 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 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 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/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 { @@ -1410,7 +1410,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {

View File

@ -12,7 +12,7 @@ Subject: [PATCH] Fix save problems on shutdown
processed so that the main process queue can be drained 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 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 --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/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<TickTa @@ -953,6 +953,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -55,7 +55,7 @@ index 33953cc7afc2616577b768a23a7d4ce0230cf480..869e0b6c8588d751a9b38b713119f888
if (isOversleep) return canOversleep();// Paper - because of our changes, this logic is broken if (isOversleep) return canOversleep();// Paper - because of our changes, this logic is broken
return this.forceTicks || this.runningTask() || Util.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime); return this.forceTicks || this.runningTask() || Util.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index fb5c42755703ade855ab727c55c8d72456b59141..b4daa19c5bc3c0555c393f17d6f5da7eb7d7bc35 100644 index a127865e4aeaba4ab4d25b442f66497bd615a858..852bd159f122826b8cc3f8c4e89f87eba399fffd 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1272,7 +1272,13 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1272,7 +1272,13 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -158,7 +158,7 @@ index 3c93bfeb94168f832904a8462ae23b06e81e080d..468c635d31cfa8051666bbefce8df4b4
this.onChanged(server); this.onChanged(server);
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index e30cd412f30e26aa4c59f367b3cc26ba47e1b21c..2211365ea3d6907c92d43d45ad61b66d7b57ad7b 100644 index cd852fa92d2fec20966a9ebf56484ce94584d74a..488c140fab2cad6d68d87ff0742a7a40ad81259e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1914,7 +1914,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -1914,7 +1914,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {

View File

@ -22,10 +22,10 @@ index 5f079cf06b0d1505bfb3fda5c326b2d7fd4f0e48..febb35091d32735ae2fe846170bd2c46
} }
}); });
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b4daa19c5bc3c0555c393f17d6f5da7eb7d7bc35..31fadaf364bf52018132df5ea721e0303ba5b65a 100644 index 852bd159f122826b8cc3f8c4e89f87eba399fffd..443ef9d81e769c26ebd5a7d72078ed0f43306a7e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2483,6 +2483,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2492,6 +2492,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
} }
public void onTickingStart(Entity entity) { public void onTickingStart(Entity entity) {

View File

@ -7,7 +7,7 @@ There are no plans to support creating worlds while worlds are
being ticked themselvess. being ticked themselvess.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 869e0b6c8588d751a9b38b713119f888778d3387..5a642dc7cd2fed59c3e5b6ff4ac9ea2f11b401da 100644 index 19640c290eb16c9e5afc842ec8ccac5a6a2ea4c7..74d2d8869beaabfb6c179455730df709c47c4447 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -294,6 +294,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -294,6 +294,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa