From 0f4cd873af99d397064b322f769d4ab4ec842296 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 16 Jun 2023 15:33:25 +0200 Subject: [PATCH] Fix sniffer removeExploredLocation and javadoc (#9311) --- patches/api/Fix-upstream-javadocs.patch | 23 +++++++++++++++ .../Fix-sniffer-removeExploredLocation.patch | 29 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 patches/server/Fix-sniffer-removeExploredLocation.patch diff --git a/patches/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch index 94ba8ba47e..4c9061bca9 100644 --- a/patches/api/Fix-upstream-javadocs.patch +++ b/patches/api/Fix-upstream-javadocs.patch @@ -494,6 +494,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @param sz The new size of the slime. */ public void setSize(int sz); +diff --git a/src/main/java/org/bukkit/entity/Sniffer.java b/src/main/java/org/bukkit/entity/Sniffer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Sniffer.java ++++ b/src/main/java/org/bukkit/entity/Sniffer.java +@@ -0,0 +0,0 @@ public interface Sniffer extends Animals { + + /** + * Gets the locations explored by the sniffer. +- *
+- * Note: the returned locations use sniffer's current world. + * + * @return a collection of locations + */ +@@ -0,0 +0,0 @@ public interface Sniffer extends Animals { + + /** + * Remove a location of the explored locations. +- *
+- * Note: the location must be in the sniffer's current world for this +- * method to have any effect. + * + * @param location the location to remove + * @see #getExploredLocations() diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Villager.java diff --git a/patches/server/Fix-sniffer-removeExploredLocation.patch b/patches/server/Fix-sniffer-removeExploredLocation.patch new file mode 100644 index 0000000000..1940a43859 --- /dev/null +++ b/patches/server/Fix-sniffer-removeExploredLocation.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> +Date: Sun, 11 Jun 2023 19:02:46 +0200 +Subject: [PATCH] Fix sniffer removeExploredLocation + +Add support to remove explored location in different world + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +@@ -0,0 +0,0 @@ public class CraftSniffer extends CraftAnimals implements Sniffer { + @Override + public void removeExploredLocation(Location location) { + Preconditions.checkArgument(location != null, "location cannot be null"); +- if (location.getWorld() != getWorld()) { +- return; +- } + + BlockPos blockPosition = CraftLocation.toBlockPosition(location); +- this.getHandle().getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, this.getHandle().getExploredPositions().filter(blockPositionExplored -> !blockPositionExplored.equals(blockPosition)).collect(Collectors.toList())); ++ // Paper start ++ net.minecraft.world.level.Level level = location.getWorld() != null ? ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle() : this.getHandle().level(); ++ net.minecraft.core.GlobalPos globalPos = net.minecraft.core.GlobalPos.of(level.dimension(), blockPosition); ++ this.getHandle().getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, this.getHandle().getExploredPositions().filter(blockPositionExplored -> !blockPositionExplored.equals(globalPos)).collect(Collectors.toList())); ++ // Paper end + } + + @Override