Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. public class PathFinder extends PathfinderGoal {
  2.  
  3. private final EntityCreature entity;
  4. private double targetX, targetY, targetZ;
  5. private final double speed = 2D; //???
  6.  
  7. public PathFinder(EntityCreature entity) {
  8. this.entity = entity;
  9. }
  10.  
  11. @Override
  12. public boolean a() {
  13. if (isGoodPosition(entity.locX, (int)entity.locY, (int)entity.locZ))
  14. return false;
  15. Vec3D target = getTargetLoc();
  16. if (target == null)
  17. return false;
  18. this.targetX = target.a;
  19. this.targetY = target.b;
  20. this.targetZ = target.c;
  21. return true;
  22. }
  23. @Override
  24. public boolean b() {
  25. return !this.entity.getNavigation().m(); //das Ziel erreicht wurde...?
  26. }
  27.  
  28. @Override
  29. public void c() {
  30. this.entity.getNavigation().a(targetX, targetY, targetZ, speed);
  31. }
  32.  
  33. private Vec3D getTargetLoc() {
  34. Random localRandom = this.entity.bc();
  35. BlockPosition localBlockPosition1 = new BlockPosition(this.entity.locX, this.entity.locY, this.entity.locZ);
  36. for (int i = 0; i < 10; i++) {
  37. BlockPosition bpos2 = localBlockPosition1.a(localRandom.nextInt(20) - 10, localRandom.nextInt(6) - 3, localRandom.nextInt(20) - 10);
  38. // if ((!this.entity.world.i(localBlockPosition2))) {
  39. if (isGoodPosition(bpos2.getX(), bpos2.getY(), bpos2.getZ()))
  40. return new Vec3D(bpos2.getX(), bpos2.getY(), bpos2.getZ());
  41. }
  42. return null;
  43. }
  44. private boolean isGoodPosition(double x, double y, double z) {
  45.  
  46. return x > 588 && x < 607 && y >= 50 && y < 60 && z < -800 && z > - 820;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement