java-topology/defects/minecraft/patch/minecraft-0004-village-goal-visited-hashset.patch

21 lines
922 B
Diff

# UNDF: UNDF-2026-000000393
--- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.java
@@ -18,6 +18,7 @@ public class MoveThroughVillageGoal extends Goal {
private final List<BlockPos> visited = Lists.newArrayList();
+ private final Set<BlockPos> visitedSet = new HashSet<>();
@@ -42,7 +43,7 @@ public class MoveThroughVillageGoal extends Goal {
private boolean hasNotVisited(BlockPos pos) {
- return !this.visited.contains(pos);
+ return !this.visitedSet.contains(pos);
}
@@ -52,6 +53,7 @@ public class MoveThroughVillageGoal extends Goal {
if (this.visited.size() > 15) {
this.visited.remove(0);
+ this.visitedSet.remove(this.visited.get(0)); // keep in sync
}
this.visited.add(pos);
+ this.visitedSet.add(pos);
}