Search in sources :

Example 41 with PathEntity

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);
}
Also used : PathPoint(net.minecraft.server.v1_16_R3.PathPoint) PathEntity(net.minecraft.server.v1_16_R3.PathEntity)

Example 42 with PathEntity

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;
}
Also used : Pathfinder(net.minecraft.server.v1_16_R3.Pathfinder) ImmutableSet(com.google.common.collect.ImmutableSet) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) ChunkCache(net.minecraft.server.v1_16_R3.ChunkCache) Sets(com.google.common.collect.Sets) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) PathPoint(net.minecraft.server.v1_16_R3.PathPoint) Map(java.util.Map) Optional(java.util.Optional) Path(net.minecraft.server.v1_16_R3.Path) Comparator(java.util.Comparator) PathDestination(net.minecraft.server.v1_16_R3.PathDestination) PathPoint(net.minecraft.server.v1_16_R3.PathPoint) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Map(java.util.Map)

Example 43 with PathEntity

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();
    }
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) Entity(net.minecraft.server.v1_13_R2.Entity) PathEntity(net.minecraft.server.v1_13_R2.PathEntity) PathEntity(net.minecraft.server.v1_13_R2.PathEntity) Location(org.bukkit.Location)

Example 44 with PathEntity

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();
        }
    });
}
Also used : PathEntity(net.minecraft.server.v1_15_R1.PathEntity) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_15_R1.Entity) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) Location(org.bukkit.Location)

Example 45 with PathEntity

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);
    }
}
Also used : PathEntity(net.minecraft.server.v1_8_R3.PathEntity) Location(org.bukkit.Location)

Aggregations

List (java.util.List)10 Optional (java.util.Optional)9 Lists (com.google.common.collect.Lists)8 Sets (com.google.common.collect.Sets)8 Comparator (java.util.Comparator)8 Map (java.util.Map)8 Set (java.util.Set)8 Function (java.util.function.Function)8 Collectors (java.util.stream.Collectors)8 Stream (java.util.stream.Stream)8 Setting (net.citizensnpcs.Settings.Setting)8 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)7 Location (org.bukkit.Location)7 Iterator (java.util.Iterator)6 PathEntity (net.minecraft.server.v1_14_R1.PathEntity)6 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)6 PathPoint (net.minecraft.server.v1_16_R3.PathPoint)6 PathEntity (net.minecraft.server.v1_8_R3.PathEntity)6 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)5 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)5