Greenadine

PathfinderGoalPanic.java

Sep 17th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. package net.minecraft.server.v1_12_R1;
  2.  
  3. import javax.annotation.Nullable;
  4.  
  5. public class PathfinderGoalPanic extends PathfinderGoal
  6. {
  7.   protected final EntityCreature a;
  8.   protected double b;
  9.   protected double c;
  10.   protected double d;
  11.   protected double e;
  12.  
  13.   public PathfinderGoalPanic(EntityCreature entitycreature, double d0) {
  14.     a = entitycreature;
  15.     b = d0;
  16.     a(1);
  17.   }
  18.  
  19.   public boolean a() {
  20.     if ((a.getLastDamager() == null) && (!a.isBurning())) {
  21.       return false;
  22.     }
  23.     if (a.isBurning()) {
  24.       BlockPosition blockposition = a(a.world, a, 5, 4);
  25.      
  26.       if (blockposition != null) {
  27.         c = blockposition.getX();
  28.         d = blockposition.getY();
  29.         e = blockposition.getZ();
  30.         return true;
  31.       }
  32.     }
  33.    
  34.     return f();
  35.   }
  36.  
  37.   protected boolean f()
  38.   {
  39.     Vec3D vec3d = RandomPositionGenerator.a(a, 5, 4);
  40.    
  41.     if (vec3d == null) {
  42.       return false;
  43.     }
  44.     c = x;
  45.     d = y;
  46.     e = z;
  47.     return true;
  48.   }
  49.  
  50.   public void c()
  51.   {
  52.     a.getNavigation().a(c, d, e, b);
  53.   }
  54.  
  55.   public boolean b()
  56.   {
  57.     if (a.ticksLived - a.hurtTimestamp > 100) {
  58.       a.b(null);
  59.       return false;
  60.     }
  61.    
  62.     return !a.getNavigation().o();
  63.   }
  64.  
  65.   @Nullable
  66.   private BlockPosition a(World world, Entity entity, int i, int j) {
  67.     BlockPosition blockposition = new BlockPosition(entity);
  68.     int k = blockposition.getX();
  69.     int l = blockposition.getY();
  70.     int i1 = blockposition.getZ();
  71.     float f = i * i * j * 2;
  72.     BlockPosition blockposition1 = null;
  73.     BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
  74.    
  75.     for (int j1 = k - i; j1 <= k + i; j1++) {
  76.       for (int k1 = l - j; k1 <= l + j; k1++) {
  77.         for (int l1 = i1 - i; l1 <= i1 + i; l1++) {
  78.           blockposition_mutableblockposition.c(j1, k1, l1);
  79.           IBlockData iblockdata = world.getType(blockposition_mutableblockposition);
  80.          
  81.           if (iblockdata.getMaterial() == Material.WATER) {
  82.             float f1 = (j1 - k) * (j1 - k) + (k1 - l) * (k1 - l) + (l1 - i1) * (l1 - i1);
  83.            
  84.             if (f1 < f) {
  85.               f = f1;
  86.               blockposition1 = new BlockPosition(blockposition_mutableblockposition);
  87.             }
  88.           }
  89.         }
  90.       }
  91.     }
  92.    
  93.     return blockposition1;
  94.   }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment