@Nullable @Override public Path getPathToPos(BlockPos pos) { return super.getPathToPos(pos); }
@Nullable private Path getPathToTarget(EntityAgeable npc) { Path path = npc.getNavigator().getPathToPos(pos); if (path != null) return path; else { //Grab a random block towards the target Vec3d vec = RandomPositionGenerator.findRandomTargetBlockTowards(npc, 10, 7, new Vec3d((double) pos.getX() + 0.5D, (double) pos.getY() + 1D, (double) pos.getZ() + 0.5D)); if (vec != null) { return npc.getNavigator().getPathToPos(new BlockPos(vec)); } else return null; } }
@Nullable private Path getPathToTarget() { Path path = npc.getNavigator().getPathToPos(blockTarget); if (path != null) return path; else { //Grab a random block towards the target Vec3d vec = RandomPositionGenerator.findRandomTargetBlockTowards(npc, 16, 7, new Vec3d((double) blockTarget.getX() + 0.5D, (double) blockTarget.getY(), (double) blockTarget.getZ() + 0.5D)); if (vec != null) { return npc.getNavigator().getPathToPos(new BlockPos(vec)); } else return null; } }
private void setPathTo(EntityLivingBase target) { Vec3d targPos = target.getPositionVector(); AxisAlignedBB targBB = target.getEntityBoundingBox(); entityPathEntity = attacker.getNavigator().getPathToPos(new BlockPos(targPos.x, targBB.maxY + 1, targPos.z)); }
public Path getPathToEntityLiving(EntityAnimal entityIn, EntityCyclops cyclops) { PathNavigate navi = entityIn.getNavigator(); Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(entityIn, 2, 7, new Vec3d(cyclops.posX, cyclops.posY, cyclops.posZ)); if(vec3d != null){ BlockPos blockpos = new BlockPos(vec3d); return navi.getPathToPos(blockpos); } return null; } }
protected final void setPath(BlockPos pos) { Path path = trimPath(npc.getNavigator().getPathToPos(pos)); npc.getNavigator().setPath(path, moveSpeed); }
@Nullable private Path getPathAwayFromTarget() { Vec3d vec = RandomPositionGenerator.findRandomTargetBlockAwayFrom(npc, (int) distanceRequired / 2, 3, new Vec3d((double) blockTarget.getX() + 0.5D, (double) blockTarget.getY(), (double) blockTarget.getZ() + 0.5D)); if (vec != null) { blockTarget = new BlockPos(vec); //Update the target, so we don't teleport back return npc.getNavigator().getPathToPos(blockTarget); } else return null; }
@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 startExecuting() { BlockPos surface = AIUtils.findSurface(this.entity); if (surface != null) { this.shore = AIUtils.findShore(this.entity.getEntityWorld(), surface.down()); if (this.shore != null) { this.path = this.entity.getNavigator().getPathToPos(this.shore.up()); if (!this.entity.getNavigator().setPath(this.path, 1.5)) { this.shore = null; } } } }
@Override public boolean shouldExecute() { if (!this.dinosaur.isCarcass() && !this.dinosaur.isMovementBlocked() && GameRuleHandler.DINO_METABOLISM.getBoolean(this.dinosaur.world)) { if (this.dinosaur.getMetabolism().isHungry()) { BlockPos feeder = this.dinosaur.getClosestFeeder(); if (feeder != null) { this.feederPosition = feeder; this.path = this.dinosaur.getNavigator().getPathToPos(this.feederPosition); if (this.path != null) { return this.dinosaur.getNavigator().setPath(this.path, 1.0); } } } } return false; }
public void updateTask(){ if(first){ hive.setWorld(this.myrmex.world); nextEntrance = MyrmexHive.getGroundedPos(this.myrmex.world, hive.getClosestEntranceToEntity(this.myrmex, this.myrmex.getRNG(), false)); } this.path = this.myrmex.getNavigator().getPathToPos(nextEntrance); this.myrmex.getNavigator().setPath(this.path, this.movementSpeed); if(this.myrmex.getDistanceSq(nextEntrance) < 9 && first){ if(hive != null){ nextEntrance = hive.getClosestEntranceBottomToEntity(this.myrmex, this.myrmex.getRNG()); first = false; this.myrmex.getNavigator().clearPath(); this.path = this.myrmex.getNavigator().getPathToPos(nextEntrance); this.myrmex.getNavigator().setPath(this.path, this.movementSpeed); } } if(this.myrmex.getDistanceSq(nextEntrance) < 15 && !first){ this.myrmex.isEnteringHive = false; }else{ this.myrmex.isEnteringHive = true; } }
/** * Returns path to given BlockPos */ public Path getPathToPos(BlockPos pos) { if (this.world.getBlockState(pos).getMaterial() == Material.AIR) { BlockPos blockpos; for (blockpos = pos.down(); blockpos.getY() > 0 && this.world.getBlockState(blockpos).getMaterial() == Material.AIR; blockpos = blockpos.down()) { ; } if (blockpos.getY() > 0) { return super.getPathToPos(blockpos.up()); } while (blockpos.getY() < this.world.getHeight() && this.world.getBlockState(blockpos).getMaterial() == Material.AIR) { blockpos = blockpos.up(); } pos = blockpos; } if (!this.world.getBlockState(pos).getMaterial().isSolid()) { return super.getPathToPos(pos); } else { BlockPos blockpos1; for (blockpos1 = pos.up(); blockpos1.getY() < this.world.getHeight() && this.world.getBlockState(blockpos1).getMaterial().isSolid(); blockpos1 = blockpos1.up()) { ; } return super.getPathToPos(blockpos1); } }
/** * Returns path to given BlockPos */ public Path getPathToPos(BlockPos pos) { if (this.world.getBlockState(pos).getMaterial() == Material.AIR) { BlockPos blockpos; for (blockpos = pos.down(); blockpos.getY() > 0 && this.world.getBlockState(blockpos).getMaterial() == Material.AIR; blockpos = blockpos.down()) { ; } if (blockpos.getY() > 0) { return super.getPathToPos(blockpos.up()); } while (blockpos.getY() < this.world.getHeight() && this.world.getBlockState(blockpos).getMaterial() == Material.AIR) { blockpos = blockpos.up(); } pos = blockpos; } if (!this.world.getBlockState(pos).getMaterial().isSolid()) { return super.getPathToPos(pos); } else { BlockPos blockpos1; for (blockpos1 = pos.up(); blockpos1.getY() < this.world.getHeight() && this.world.getBlockState(blockpos1).getMaterial().isSolid(); blockpos1 = blockpos1.up()) { ; } return super.getPathToPos(blockpos1); } }
public BlockPos getClosestFeeder() { if (this.ticksExisted - this.feederSearchTick > 200) { this.feederSearchTick = this.ticksExisted; OnionTraverser traverser = new OnionTraverser(this.getPosition(), 32); for (BlockPos pos : traverser) { IBlockState state = this.world.getBlockState(pos); if (state.getBlock() instanceof FeederBlock) { TileEntity tile = this.world.getTileEntity(pos); if (tile instanceof FeederBlockEntity) { FeederBlockEntity feeder = (FeederBlockEntity) tile; if (feeder.canFeedDinosaur(this) && feeder.getFeeding() == null && feeder.openAnimation == 0) { Path path = this.getNavigator().getPathToPos(pos); if (path != null && path.getCurrentPathLength() != 0) { return this.closestFeeder = pos; } } } } } } return this.closestFeeder; }
public boolean shouldExecute() { if(!this.myrmex.canMove() || this.myrmex.shouldLeaveHive() || !this.myrmex.canSeeSky() || !first){ return false; } MyrmexHive village = this.myrmex.getHive(); if (village == null) { village = MyrmexWorldData.get(this.myrmex.world).getNearestHive(new BlockPos(this.myrmex), 500); } if (village == null) { return false; } else { this.hive = village; nextEntrance = MyrmexHive.getGroundedPos(this.myrmex.world, hive.getClosestEntranceToEntity(this.myrmex, this.myrmex.getRNG(), false)); this.path = this.myrmex.getNavigator().getPathToPos(nextEntrance); first = true; return this.path != null; } }
public boolean shouldExecute() { if(!this.myrmex.canMove() || !this.myrmex.shouldEnterHive() && !this.myrmex.getNavigator().noPath() || this.myrmex.canSeeSky()){ return false; } MyrmexHive village = MyrmexWorldData.get(this.myrmex.world).getNearestHive(new BlockPos(this.myrmex), 300); if (village == null) { village = this.myrmex.getHive(); } if (village == null) { return false; } else { target = getNearPos(MyrmexHive.getGroundedPos(this.myrmex.world, village.getCenter())); this.path = this.myrmex.getNavigator().getPathToPos(target); return this.path != null; } }
public boolean shouldExecute() { if(this.myrmex instanceof EntityMyrmexQueen){ return false; } if(!this.myrmex.canMove() || !this.myrmex.canMove() || !this.myrmex.shouldLeaveHive() || this.myrmex.canSeeSky() || !this.myrmex.getHeldItem(EnumHand.MAIN_HAND).isEmpty() || this.myrmex instanceof EntityMyrmexWorker && ((EntityMyrmexWorker)this.myrmex).holdingBaby() || this.myrmex.isEnteringHive){ return false; } MyrmexHive village = MyrmexWorldData.get(this.myrmex.world).getNearestHive(new BlockPos(this.myrmex), 100); if (village == null) { return false; } else { nextEntrance = MyrmexHive.getGroundedPos(this.myrmex.world, village.getClosestEntranceToEntity(this.myrmex, this.myrmex.getRNG(), true)); this.path = this.myrmex.getNavigator().getPathToPos(nextEntrance); return this.path != null; } }
public boolean shouldExecute() { if (!this.myrmex.canMove() || this.myrmex instanceof EntityMyrmexWorker && ((EntityMyrmexWorker)this.myrmex).holdingBaby() || !this.myrmex.shouldEnterHive() && !this.myrmex.getNavigator().noPath() || this.myrmex.canSeeSky() || this.myrmex.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) { return false; } MyrmexHive village = this.myrmex.getHive(); if (village == null) { return false; } else { nextRoom = MyrmexHive.getGroundedPos(this.myrmex.world, village.getRandomRoom(WorldGenMyrmexHive.RoomType.FOOD, this.myrmex.getRNG(), this.myrmex.getPosition())); nextCocoon = getNearbyCocoon(nextRoom); if (nextCocoon != null) { this.path = this.myrmex.getNavigator().getPathToPos(nextCocoon); return this.path != null; } else { return false; } } }
public boolean shouldExecute() { if(!this.myrmex.canMove() || this.myrmex instanceof EntityMyrmexWorker && ((EntityMyrmexWorker)this.myrmex).holdingBaby() || !this.myrmex.shouldMoveThroughHive() || !this.myrmex.shouldEnterHive() && !this.myrmex.getNavigator().noPath() || this.myrmex.canSeeSky() || !this.myrmex.getHeldItem(EnumHand.MAIN_HAND).isEmpty() && this.myrmex instanceof EntityMyrmexWorker){ return false; } MyrmexHive village = MyrmexWorldData.get(this.myrmex.world).getNearestHive(new BlockPos(this.myrmex), 300); if (village == null) { village = this.myrmex.getHive(); } if (village == null) { return false; } else { nextRoom = MyrmexHive.getGroundedPos(this.myrmex.world, village.getRandomRoom(this.myrmex.getRNG(), this.myrmex.getPosition())); this.path = this.myrmex.getNavigator().getPathToPos(nextRoom); return this.path != null; } }
IBlockState state = world.getBlockState(shore); if (state.isFullBlock()) { Path path = this.dinosaur.getNavigator().getPathToPos(shore); if (path != null && path.getCurrentPathLength() != 0) { this.path = path;