use of net.minecraft.server.v1_15_R1.PathEntity in project UltraCosmetics by iSach.
the class PlayerFollower method follow.
@Override
public void follow(Player player) {
if (player == null) {
return;
}
if (UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer(player).getCurrentTreasureChest() != null) {
return;
}
Entity petEntity;
if (pet.isCustomEntity()) {
petEntity = ((CustomEntityPet) pet).getCustomEntity();
} else {
petEntity = ((CraftEntity) pet.getEntity()).getHandle();
}
if (petEntity == null) {
return;
}
// Run in sync... To enhance :S
Bukkit.getScheduler().runTask(UltraCosmeticsData.get().getPlugin(), () -> {
if (!player.isOnline())
return;
if (!player.getWorld().equals(petEntity.getBukkitEntity().getWorld())) {
petEntity.getBukkitEntity().teleport(player.getLocation());
return;
}
((EntityInsentient) petEntity).getNavigation().a(2d);
Location targetLocation = player.getLocation();
PathEntity path = ((EntityInsentient) petEntity).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1, 1);
try {
int distance = (int) Bukkit.getPlayer(player.getName()).getLocation().distance(petEntity.getBukkitEntity().getLocation());
if (distance > 10 && petEntity.valid && player.isOnGround()) {
petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
}
if (path != null && distance > 1.3) {
double speed = 1.15d;
if (pet.getType().getEntityType() == EntityType.ZOMBIE) {
speed *= 1.3;
}
((EntityInsentient) petEntity).getNavigation().a(path, speed);
((EntityInsentient) petEntity).getNavigation().a(speed);
}
} catch (IllegalArgumentException exception) {
petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
// exception.printStackTrace();
}
});
}
use of net.minecraft.server.v1_15_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
private PathEntity a(IBlockAccess paramIBlockAccess, Entity paramEntity, double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat) {
this.a.a();
this.c.a(paramIBlockAccess, paramEntity);
PathPoint localPathPoint1 = this.c.a(paramEntity);
PathPoint localPathPoint2 = this.c.a(paramEntity, paramDouble1, paramDouble2, paramDouble3);
PathEntity localPathEntity = a(paramEntity, localPathPoint1, localPathPoint2, paramFloat);
this.c.a();
return localPathEntity;
}
use of net.minecraft.server.v1_15_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
private PathEntity a(PathPoint paramPathPoint1, PathPoint paramPathPoint2) {
int i = 1;
PathPoint localPathPoint = paramPathPoint2;
try {
while (H.get(localPathPoint) != null) {
i++;
localPathPoint = (PathPoint) H.get(localPathPoint);
}
} catch (IllegalArgumentException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e1) {
e1.printStackTrace();
}
PathPoint[] arrayOfPathPoint = new PathPoint[i];
localPathPoint = paramPathPoint2;
arrayOfPathPoint[(--i)] = localPathPoint;
try {
while (H.get(localPathPoint) != null) {
localPathPoint = (PathPoint) H.get(localPathPoint);
arrayOfPathPoint[(--i)] = localPathPoint;
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return new PathEntity(arrayOfPathPoint);
}
use of net.minecraft.server.v1_15_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerNavigation method a.
@Override
public PathEntity a(BlockPosition paramBlockPosition) {
if (!b()) {
return null;
}
float f1 = i();
this.c.methodProfiler.a("pathfind");
BlockPosition localBlockPosition = new BlockPosition(this.b);
int k = (int) (f1 + 8.0F);
ChunkCache localChunkCache = new ChunkCache(this.c, localBlockPosition.a(-k, -k, -k), localBlockPosition.a(k, k, k), 0);
PathEntity localPathEntity = this.j.a(localChunkCache, this.b, paramBlockPosition, f1);
this.c.methodProfiler.b();
return localPathEntity;
}
use of net.minecraft.server.v1_15_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
private PathEntity a(PathPoint paramPathPoint1, PathPoint paramPathPoint2, float paramFloat) {
paramPathPoint1.e = 0.0F;
paramPathPoint1.f = paramPathPoint1.c(paramPathPoint2);
paramPathPoint1.g = paramPathPoint1.f;
this.a.a();
this.b.clear();
this.a.a(paramPathPoint1);
Object localObject1 = paramPathPoint1;
int i = 0;
while (!this.a.e()) {
i++;
if (i >= 2000) {
break;
}
PathPoint localObject2 = this.a.c();
if (localObject2.equals(paramPathPoint2)) {
localObject1 = paramPathPoint2;
break;
}
if (localObject2.c(paramPathPoint2) < ((PathPoint) localObject1).c(paramPathPoint2)) {
localObject1 = localObject2;
}
localObject2.i = true;
int j = this.d.a(this.c, localObject2, paramPathPoint2, paramFloat);
for (int k = 0; k < j; k++) {
PathPoint localPathPoint = this.c[k];
float f1 = localObject2.c(localPathPoint);
localPathPoint.j = (localObject2.j + f1);
localPathPoint.k = (f1 + localPathPoint.l);
float f2 = localObject2.e + localPathPoint.k;
if ((localPathPoint.j < paramFloat) && ((!localPathPoint.a()) || (f2 < localPathPoint.e))) {
localPathPoint.h = (localObject2);
localPathPoint.e = f2;
localPathPoint.f = (localPathPoint.c(paramPathPoint2) + localPathPoint.l);
if (localPathPoint.a()) {
this.a.a(localPathPoint, localPathPoint.e + localPathPoint.f);
} else {
localPathPoint.g = (localPathPoint.e + localPathPoint.f);
this.a.a(localPathPoint);
}
}
}
}
if (localObject1 == paramPathPoint1) {
return null;
}
Object localObject2 = a(paramPathPoint1, (PathPoint) localObject1);
return (PathEntity) localObject2;
}
Aggregations