Skip to content

Commit

Permalink
Fix npe (#10384)
Browse files Browse the repository at this point in the history
Fix npe when the path gets removed during pathfollow/advance
  • Loading branch information
someaddons authored Oct 31, 2024
1 parent 7c184da commit 001f39a
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.minecolonies.core.util.WorkerUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
Expand Down Expand Up @@ -371,21 +370,22 @@ else if (this.path != null && !this.path.isDone())
}
}

DebugPackets.sendPathFindingPacket(this.level, this.mob, this.path, this.maxDistanceToWaypoint);

if ((wantedPosition == null || path != null && currentPathIndex != path.getNextNodeIndex() && path.getNextNodeIndex() < path.getNodeCount()))
if (this.path != null && !this.path.isDone())
{
Vec3 vector3d2 = path.getNextEntityPos(mob);
tempPos.set(Mth.floor(vector3d2.x), Mth.floor(vector3d2.y), Mth.floor(vector3d2.z));
if (wantedPosition == null || ChunkPos.asLong(tempPos) == mob.chunkPosition().toLong() || WorldUtil.isEntityBlockLoaded(level, tempPos))
if ((wantedPosition == null || currentPathIndex != path.getNextNodeIndex() && path.getNextNodeIndex() < path.getNodeCount()))
{
wantedPosition = new Vec3(vector3d2.x,
getSmartGroundY(this.level, tempPos, vector3d2.y),
vector3d2.z);
Vec3 vector3d2 = path.getNextEntityPos(mob);
tempPos.set(Mth.floor(vector3d2.x), Mth.floor(vector3d2.y), Mth.floor(vector3d2.z));
if (wantedPosition == null || ChunkPos.asLong(tempPos) == mob.chunkPosition().toLong() || WorldUtil.isEntityBlockLoaded(level, tempPos))
{
wantedPosition = new Vec3(vector3d2.x,
getSmartGroundY(this.level, tempPos, vector3d2.y),
vector3d2.z);
}
}
}

mob.getMoveControl().setWantedPosition(wantedPosition.x, wantedPosition.y, wantedPosition.z, speedModifier);
mob.getMoveControl().setWantedPosition(wantedPosition.x, wantedPosition.y, wantedPosition.z, speedModifier);
}
}
// End of super.tick.

Expand Down

0 comments on commit 001f39a

Please sign in to comment.