Skip to content

Commit

Permalink
Fixed dragons struggling to walk down slopes
Browse files Browse the repository at this point in the history
Fixes #4766
  • Loading branch information
TheBv committed Mar 7, 2023
1 parent 46c0e29 commit dd00275
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,20 +759,21 @@ protected void pathFollow() {
boolean wentAhead = false;
boolean isTracking = AbstractPathJob.trackingMap.containsValue(ourEntity.getUniqueID());

// TODO: Figure out a better way to derive this value ideally from the pathfinding code
int maxDropHeight = 3;

final HashSet<BlockPos> reached = new HashSet<>();
// Look at multiple points, incase we're too fast
for (int i = this.currentPath.getCurrentPathIndex(); i < Math.min(this.currentPath.getCurrentPathLength(), this.currentPath.getCurrentPathIndex() + 4); i++)
{
for (int i = this.currentPath.getCurrentPathIndex(); i < Math.min(this.currentPath.getCurrentPathLength(), this.currentPath.getCurrentPathIndex() + 4); i++) {
Vector3d next = this.currentPath.getVectorFromIndex(this.entity, i);
if (Math.abs(this.entity.getPosX() - next.x) < (double) this.maxDistanceToWaypoint - Math.abs(this.entity.getPosY() - (next.y)) * 0.1
&& Math.abs(this.entity.getPosZ() - next.z) < (double) this.maxDistanceToWaypoint - Math.abs(this.entity.getPosY() - (next.y)) * 0.1 &&
Math.abs(this.entity.getPosY() - next.y) <= Math.min(1.0F, Math.ceil(this.entity.getHeight() / 2.0F)))
{
&& Math.abs(this.entity.getPosZ() - next.z) < (double) this.maxDistanceToWaypoint - Math.abs(this.entity.getPosY() - (next.y)) * 0.1 &&
(Math.abs(this.entity.getPosY() - next.y) <= Math.min(1.0F, Math.ceil(this.entity.getHeight() / 2.0F)) ||
Math.abs(this.entity.getPosY() - next.y) <= Math.ceil(this.entity.getWidth() / 2) * maxDropHeight)) {
this.currentPath.incrementPathIndex();
wentAhead = true;

if (isTracking)
{
if (isTracking) {
final PathPoint point = currentPath.getPathPointFromIndex(i);
reached.add(new BlockPos(point.x, point.y, point.z));
}
Expand Down

0 comments on commit dd00275

Please sign in to comment.