13
0
geforkt von Mirrors/Paper

Fix ground pathfinding (#7683)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-09-20 14:06:11 -07:00
Ursprung bb10a5d633
Commit 99640f47f1
2 geänderte Dateien mit 53 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
@@ -0,0 +0,0 @@ public class GroundPathNavigation extends PathNavigation {
}
@Override
- public Path createPath(BlockPos target, int distance) {
+ public Path createPath(BlockPos target, @javax.annotation.Nullable Entity entity, int distance) { // Paper
if (this.level.getBlockState(target).isAir()) {
BlockPos blockPos;
for(blockPos = target.below(); blockPos.getY() > this.level.getMinBuildHeight() && this.level.getBlockState(blockPos).isAir(); blockPos = blockPos.below()) {
}
if (blockPos.getY() > this.level.getMinBuildHeight()) {
- return super.createPath(blockPos.above(), distance);
+ return super.createPath(blockPos.above(), entity, distance); // Paper
}
while(blockPos.getY() < this.level.getMaxBuildHeight() && this.level.getBlockState(blockPos).isAir()) {
@@ -0,0 +0,0 @@ public class GroundPathNavigation extends PathNavigation {
}
if (!this.level.getBlockState(target).getMaterial().isSolid()) {
- return super.createPath(target, distance);
+ return super.createPath(target, entity, distance); // Paper
} else {
BlockPos blockPos2;
for(blockPos2 = target.above(); blockPos2.getY() < this.level.getMaxBuildHeight() && this.level.getBlockState(blockPos2).getMaterial().isSolid(); blockPos2 = blockPos2.above()) {
}
- return super.createPath(blockPos2, distance);
+ return super.createPath(blockPos2, entity, distance); // Paper
}
}
@Override
public Path createPath(Entity entity, int distance) {
@ -35,14 +66,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigati
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.tags.BlockTags;
+import net.minecraft.server.MCUtil;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
@Nullable
@ -52,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.createPath(target, null, distance);
+ }
+ @Nullable
+ public Path createPath(BlockPos target, Entity entity, int distance) {
+ public Path createPath(BlockPos target, @Nullable Entity entity, int distance) {
+ return this.createPath(ImmutableSet.of(target), entity, 8, false, distance);
+ // Paper end
}
@ -71,15 +94,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable
protected Path createPath(Set<BlockPos> positions, int range, boolean useHeadPos, int distance, float followRange) {
+ return this.createPath(positions, null, range, useHeadPos, distance, (float) this.mob.getAttributeValue(Attributes.FOLLOW_RANGE));
+ return this.createPath(positions, null, range, useHeadPos, distance, followRange);
+ }
+
+ @Nullable
+ protected Path createPath(Set<BlockPos> positions, Entity target, int range, boolean useHeadPos, int distance) {
+ protected Path createPath(Set<BlockPos> positions, @Nullable Entity target, int range, boolean useHeadPos, int distance) {
+ return this.createPath(positions, target, range, useHeadPos, distance, (float) this.mob.getAttributeValue(Attributes.FOLLOW_RANGE));
+ }
+
+ @Nullable protected Path createPath(Set<BlockPos> positions, Entity target, int range, boolean useHeadPos, int distance, float followRange) {
+ @Nullable protected Path createPath(Set<BlockPos> positions, @Nullable Entity target, int range, boolean useHeadPos, int distance, float followRange) {
+ // Paper end
if (positions.isEmpty()) {
return null;
@ -92,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ boolean copiedSet = false;
+ for (BlockPos possibleTarget : positions) {
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
+ MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
+ net.minecraft.server.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
+ if (!copiedSet) {
+ copiedSet = true;
+ positions = new java.util.HashSet<>(positions);
@ -108,3 +131,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.level.getProfiler().push("pathfind");
BlockPos blockPos = useHeadPos ? this.mob.blockPosition().above() : this.mob.blockPosition();
int i = (int)(followRange + (float)range);
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
@@ -0,0 +0,0 @@ public class WallClimberNavigation extends GroundPathNavigation {
}
@Override
- public Path createPath(BlockPos target, int distance) {
+ public Path createPath(BlockPos target, @Nullable Entity entity, int distance) { // Paper
this.pathToPosition = target;
- return super.createPath(target, distance);
+ return super.createPath(target, entity, distance); // Paper
}
@Override

Datei anzeigen

@ -22,6 +22,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
for (BlockPos possibleTarget : positions) {
- if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
+ if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
net.minecraft.server.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
if (!copiedSet) {
copiedSet = true;