protected void removeSunnyPath() { super.removeSunnyPath(); if (this.shouldAvoidSun) { if (this.world.canSeeSky(new BlockPos(MathHelper.floor(this.entity.posX), (int) (this.entity.getEntityBoundingBox().minY + 0.5D), MathHelper.floor(this.entity.posZ)))) { return; } for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) { PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i); if (this.world.canSeeSky(new BlockPos(pathpoint.x, pathpoint.y, pathpoint.z))) { this.currentPath.setCurrentPathLength(i - 1); return; } } } }
/** * Trims path data from the end to the first sun covered block */ protected void removeSunnyPath() { super.removeSunnyPath(); if (this.shouldAvoidSun) { if (this.world.canSeeSky(new BlockPos(MathHelper.floor(this.entity.posX), (int) (this.entity.getEntityBoundingBox().minY + 0.5D), MathHelper.floor(this.entity.posZ)))) { return; } for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) { PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i); if (this.world.canSeeSky(new BlockPos(pathpoint.x, pathpoint.y, pathpoint.z))) { this.currentPath.setCurrentPathLength(i - 1); return; } } } }
protected Path trimPath(Path path) { if (path != null) { int index = path.getCurrentPathIndex(); PathPoint pathpoint = path.getPathPointFromIndex(index); if (npc.getBlockPathWeight(new BlockPos(pathpoint.x, pathpoint.y, pathpoint.z)) >= 0) { for (int i = index + 1; i < path.getCurrentPathLength(); i++) { pathpoint = path.getPathPointFromIndex(i); if (npc.getBlockPathWeight(new BlockPos(pathpoint.x, pathpoint.y, pathpoint.z)) < 0) { path.setCurrentPathLength(i - 1); break; } } } else { Vec3d vec = RandomPositionGenerator.findRandomTargetBlockAwayFrom(npc, MIN_RANGE, MIN_RANGE, new Vec3d(npc.posX, npc.posY, npc.posZ)); if (vec != null) return npc.getNavigator().getPathToXYZ(vec.x, vec.y, vec.z); } } return path; } }
path.setCurrentPathLength(j - 1); return path.getCurrentPathLength() > 1;