@Nullable @Override public Path getPath() { return super.getPath(); }
private void manageMovingToLastKnowMoveLocation(double distanceToTargetSq) { if (distanceToTargetSq <= (double) this.maxChaseDistanceSq && this.pathRetryTimer >= 20) { if (this.entityHost.getNavigator().getPath() != null && this.entityHost.getNavigator().getPath().equals(lastChasePath)) { this.entityHost.getNavigator().clearPath(); } } else if (this.entityHost.getNavigator().noPath()) { lastChasePath = this.entityHost.getNavigator().getPathToEntityLiving(attackTarget); this.entityHost.getNavigator().setPath(lastChasePath, this.entityMoveSpeed); } }
@Override public void updateTask() { Path currentPath = this.entity.getNavigator().getPath(); if (this.shore != null && !this.path.isSamePath(currentPath)) { Path path = this.entity.getNavigator().getPathToPos(this.shore); if (path != null && !path.isSamePath(currentPath)) { this.path = path; this.entity.getNavigator().setPath(path, 1.5); } } } }
@Override public void updateTask() { Path currentPath = this.dinosaur.getNavigator().getPath(); if (this.path != null) { PathPoint finalPathPoint = this.path.getFinalPathPoint(); if (currentPath == null || !currentPath.getFinalPathPoint().equals(finalPathPoint)) { Path path = this.dinosaur.getNavigator().getPathToXYZ(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z); this.dinosaur.getNavigator().setPath(path, 1.0); this.path = path; } } if (this.giveUpTime <= 0 || (this.dinosaur.getStayAwakeTime() <= 0 && (this.path == null || this.path.isFinished()))) { this.dinosaur.setSleeping(true); } this.giveUpTime--; }
text.println("No path: " + nav.noPath()); Path path = nav.getPath();
private void addDoorCloseOnThePath() { Path path = this.theEntity.getNavigator().getPath(); if (path == null) { return; } addDoorCloseOnThePath(path); }
@Override public boolean shouldContinueExecuting() { Path currentPath = this.entity.getNavigator().getPath(); return this.shore != null && this.path != null && (currentPath == null || !currentPath.isFinished()); }
private boolean isPathOnHighGround() { if (this.navigator != null && this.navigator.getPath() != null && this.navigator.getPath().getFinalPathPoint() != null) { BlockPos target = new BlockPos(this.navigator.getPath().getFinalPathPoint().x, this.navigator.getPath().getFinalPathPoint().y, this.navigator.getPath().getFinalPathPoint().z); BlockPos siren = new BlockPos(this); if (world.isAirBlock(siren.up()) && world.isAirBlock(target.up()) && target.getY() >= siren.getY()) { return true; } } return false; }
private boolean isStuck() { return !this.isTamed() && (!this.getNavigator().noPath() && (this.getNavigator().getPath() == null || this.getNavigator().getPath().getFinalPathPoint() != null && this.getDistanceSq(new BlockPos(this.getNavigator().getPath().getFinalPathPoint().x, this.getNavigator().getPath().getFinalPathPoint().y, this.getNavigator().getPath().getFinalPathPoint().z)) > 15) || this.airTarget != null) && ticksStill > 80 && !this.isHovering() && canMove(); }
private boolean isRunningAway() { if (runningAwayTo == null) { return false; } if (getNavigator().noPath()) { runningAwayTo = null; return false; } final Path path = getNavigator().getPath(); PathPoint dest = path != null ? path.getFinalPathPoint() : null; return dest != null && dest.equals(runningAwayTo); }
protected float getJumpUpwardsMotion() { if (!collidedHorizontally && (!moveHelper.isUpdating() || moveHelper.getY() <= posY + 0.5D)) { Path path = navigator.getPath(); if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) { Vec3d vec3d = path.getPosition(this); if (vec3d.y > posY + 0.5D) return 0.5F; } return moveHelper.getSpeed() <= 0.6D ? 0.5F : 0.5F; } else { return 0.5F; } }
@Override public boolean shouldContinueExecuting() { if (this.path == null || (this.world.collidesWithAnyBlock(this.entity.getEntityBoundingBox()) && !this.isBlockLeaves(this.entity.getPosition()))) { return false; } if (!this.reachedTarget) { if (!this.path.isFinished() && !this.path.isSamePath(this.entity.getNavigator().getPath())) { return false; } } return this.active && !this.gliding; }
private boolean runAway() { if (!useRunAwayTactic.get()) { return false; } runAwayTimer = 40; Vec3d targetDir = new Vec3d(attackTarget.posX, attackTarget.getEntityBoundingBox().minY, attackTarget.posZ); Vec3d entityPos = EntityUtil.getEntityPosition(entityHost); targetDir = entityPos.subtract(targetDir).normalize().scale(attackRange.get() * 0.9).add(entityPos); BlockPos probePoint = new BlockPos((int) Math.round(targetDir.x), (int) Math.round(entityHost.posY), (int) Math.round(targetDir.z)); World world = entityHost.getEntityWorld(); BlockPos clearGround = SpawnUtil.findClearGround(world, probePoint); if (clearGround == null) { return false; } boolean res = getNavigator().tryMoveToXYZ(clearGround.getX() + .5, clearGround.getY(), clearGround.getZ() + .5, mountedEntityMoveSpeed.get()); if (getNavigator().noPath()) { runningAwayTo = null; } else { final Path path = getNavigator().getPath(); runningAwayTo = path != null ? path.getFinalPathPoint() : null; } return res; }
@Override public boolean shouldExecute() { if (!this.mob.isInWater()) { return false; } if (this.mob.getRNG().nextFloat() < 0.5F) { Path path = this.mob.getNavigator().getPath(); if (path != null && path.getFinalPathPoint() != null || !this.mob.getNavigator().noPath() && !this.mob.isDirectPathBetweenPoints(this.mob.getPositionVector(), new Vec3d(path.getFinalPathPoint().x, path.getFinalPathPoint().y, path.getFinalPathPoint().z))) { this.mob.getNavigator().clearPath(); } if (this.mob.getNavigator().noPath()) { Vec3d vec3 = this.findWaterTarget(); if (vec3 != null) { this.mob.getNavigator().tryMoveToXYZ(vec3.x, vec3.y, vec3.z, 1.0); return true; } } } return false; }
@Override public String toString() { String result; if (noPath()) result = "No Path " + (getPath() != null ? getPath().getCurrentPathLength() : ""); else result = "Path to " + getPath().getPathPointFromIndex(getPath().getCurrentPathIndex()).toString(); if (hasMount() && !((EntityLiving) entity.getRidingEntity()).getNavigator().noPath()) { Path path = ((EntityLiving) entity.getRidingEntity()).getNavigator().getPath(); result += "AND Mount path to " + path.getPathPointFromIndex(path.getCurrentPathIndex()).toString(); } return result; } }
@Override public boolean shouldExecute() { if (!this.mob.isInSand() || this.mob.isRiding() || this.mob.isBeingRidden()) { return false; } if (this.mob.getRNG().nextFloat() < 0.5F) { Path path = this.mob.getNavigator().getPath(); if (path != null || !this.mob.getNavigator().noPath() && !isDirectPathBetweenPoints(this.mob, this.mob.getPositionVector(), new Vec3d(path.getFinalPathPoint().x, path.getFinalPathPoint().y, path.getFinalPathPoint().z))) { this.mob.getNavigator().clearPath(); } if (this.mob.getNavigator().noPath()) { BlockPos vec3 = this.findSandTarget(); if (vec3 != null) { this.mob.getNavigator().tryMoveToXYZ(vec3.getX(), vec3.getY(), vec3.getZ(), 1.0); return true; } } } return false; }
@Override public void updateAITasks() { if (currentMoveTypeDuration > 0) { --currentMoveTypeDuration; } if (onGround) { if (!wasOnGround) { setJumping(false); checkLandingDelay(); } EntityGrasshopper.GrasshopperJumpHelper grasshopperjumphelper = (EntityGrasshopper.GrasshopperJumpHelper) jumpHelper; if (!grasshopperjumphelper.getIsJumping()) { if (moveHelper.isUpdating() && currentMoveTypeDuration == 0) { Path path = navigator.getPath(); Vec3d vec3d = new Vec3d(moveHelper.getX(), moveHelper.getY(), moveHelper.getZ()); if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) vec3d = path.getPosition(this); calculateRotationYaw(vec3d.x, vec3d.z); startJumping(); } } else if (!grasshopperjumphelper.canJump()) enableJumpControl(); } wasOnGround = onGround; }
@Override public boolean shouldExecute() { if (!this.mob.isInWater() || this.mob.isRiding() || this.mob.isBeingRidden()) { return false; } Path path = this.mob.getNavigator().getPath(); if (this.mob.getRNG().nextFloat() < 0.15F ||path != null && path.getFinalPathPoint() != null && this.mob.getDistanceSq((double)path.getFinalPathPoint().x, (double)path.getFinalPathPoint().y, (double)path.getFinalPathPoint().z) < 3) { if (path != null && path.getFinalPathPoint() != null || !this.mob.getNavigator().noPath() && !isDirectPathBetweenPoints(this.mob, this.mob.getPositionVector(), new Vec3d(path.getFinalPathPoint().x, path.getFinalPathPoint().y, path.getFinalPathPoint().z))) { this.mob.getNavigator().clearPath(); } if (this.mob.getNavigator().noPath()) { BlockPos vec3 = this.findWaterTarget(); if (vec3 != null) { this.mob.getNavigator().tryMoveToXYZ(vec3.getX(), vec3.getY(), vec3.getZ(), 1.0); return true; } } } return false; }
private void knockFromDamage(float val, Material material) { BlockPos pos = new BlockPos(this.posX, this.getEntityBoundingBox().minY + 0.5, this.posZ); if (world.getBlockState(pos.west()).getMaterial() == material) { knockBack(null, val, pos.getX() - 1 - this.posX, 0); } else if (world.getBlockState(pos.north()).getMaterial() == material) { knockBack(null, val, 0, pos.getZ() - 1 - this.posZ); } else if (world.getBlockState(pos.east()).getMaterial() == material) { knockBack(null, val, pos.getX() + 1 - this.posX, 0); } else if (world.getBlockState(pos.south()).getMaterial() == material) { knockBack(null, val, 0, pos.getZ() + 1 - this.posZ); } else if (world.getBlockState(pos.add(-1, 0, -1)).getMaterial() == material) { knockBack(null, val, pos.getX() - 1 - this.posX, pos.getZ() - 1 - this.posZ); } else if (world.getBlockState(pos.add(1, 0, -1)).getMaterial() == material) { knockBack(null, val, pos.getX() + 1 - this.posX, pos.getZ() - 1 - this.posZ); } else if (world.getBlockState(pos.add(-1, 0, 1)).getMaterial() == material) { knockBack(null, val, pos.getX() - 1 - this.posX, pos.getZ() + 1 - this.posZ); } else if (world.getBlockState(pos.add(1, 0, 1)).getMaterial() == material) { knockBack(null, val, pos.getX() + 1 - this.posX, pos.getZ() + 1 - this.posZ); } else if (world.getBlockState(pos.down()).getMaterial() == material) { knockBack(null, val, 2 * getRNG().nextFloat() - 1, 2 * getRNG().nextFloat() - 1); } if (world.isRemote || getNavigator().noPath()) return; PathPoint point = getNavigator().getPath().getPathPointFromIndex(getNavigator().getPath().getCurrentPathIndex()); if (world.getBlockState(new BlockPos(point.x, point.y, point.z)).getMaterial() == material) { getNavigator().clearPath(); } else if (world.getBlockState(new BlockPos(point.x, point.y - 1, point.z)).getMaterial() == material) { getNavigator().clearPath(); } }