use of net.minecraft.server.v1_15_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
private PathEntity a(PathPoint var0, BlockPosition var1, boolean var2) {
List<PathPoint> var3 = Lists.newArrayList();
PathPoint var4 = var0;
var3.add(0, var4);
while (var4.h != null) {
var4 = var4.h;
var3.add(0, var4);
}
return new PathEntity(var3, var1, var2);
}
use of net.minecraft.server.v1_15_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
@Override
public PathEntity a(ChunkCache var0, EntityInsentient var1, Set<BlockPosition> var2, float var3, int var4, float var5) {
this.d.a();
this.c.a(var0, var1);
PathPoint var6 = this.c.b();
Map var7 = var2.stream().collect(Collectors.toMap((var0x) -> {
return this.c.a((double) var0x.getX(), (double) var0x.getY(), (double) var0x.getZ());
}, Function.identity()));
PathEntity var8 = this.a(var6, var7, var3, var4, var5);
this.c.a();
return var8;
}
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 (!player.getWorld().equals(petEntity.getBukkitEntity().getWorld())) {
petEntity.getBukkitEntity().teleport(player.getLocation());
return;
}
((EntityInsentient) petEntity).getNavigation().a(2);
Location targetLocation = player.getLocation();
PathEntity path = ((EntityInsentient) petEntity).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 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 > 3.3) {
double speed = 1.05d;
if (pet.getType().getEntityType() == EntityType.ZOMBIE) {
speed *= 1.5;
}
((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 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 UltraCosmetics by iSach.
the class EntityUtil method follow.
@Override
public void follow(Entity toFollow, Entity follower) {
net.minecraft.server.v1_8_R3.Entity pett = ((CraftEntity) follower).getHandle();
((EntityInsentient) pett).getNavigation().a(2);
Object petf = ((CraftEntity) follower).getHandle();
Location targetLocation = toFollow.getLocation();
PathEntity path = ((EntityInsentient) petf).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1);
if (path != null) {
((EntityInsentient) petf).getNavigation().a(path, 1.05D);
((EntityInsentient) petf).getNavigation().a(1.05D);
}
}
Aggregations