Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PathFinder extends PathfinderGoal {
- private final EntityCreature entity;
- private double targetX, targetY, targetZ;
- private final double speed = 2D; //???
- public PathFinder(EntityCreature entity) {
- this.entity = entity;
- }
- @Override
- public boolean a() {
- if (isGoodPosition(entity.locX, (int)entity.locY, (int)entity.locZ))
- return false;
- Vec3D target = getTargetLoc();
- if (target == null)
- return false;
- this.targetX = target.a;
- this.targetY = target.b;
- this.targetZ = target.c;
- return true;
- }
- @Override
- public boolean b() {
- return !this.entity.getNavigation().m(); //das Ziel erreicht wurde...?
- }
- @Override
- public void c() {
- this.entity.getNavigation().a(targetX, targetY, targetZ, speed);
- }
- private Vec3D getTargetLoc() {
- Random localRandom = this.entity.bc();
- BlockPosition localBlockPosition1 = new BlockPosition(this.entity.locX, this.entity.locY, this.entity.locZ);
- for (int i = 0; i < 10; i++) {
- BlockPosition bpos2 = localBlockPosition1.a(localRandom.nextInt(20) - 10, localRandom.nextInt(6) - 3, localRandom.nextInt(20) - 10);
- // if ((!this.entity.world.i(localBlockPosition2))) {
- if (isGoodPosition(bpos2.getX(), bpos2.getY(), bpos2.getZ()))
- return new Vec3D(bpos2.getX(), bpos2.getY(), bpos2.getZ());
- }
- return null;
- }
- private boolean isGoodPosition(double x, double y, double z) {
- return x > 588 && x < 607 && y >= 50 && y < 60 && z < -800 && z > - 820;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement