Search in sources :

Example 11 with PathPoint

use of net.minecraft.server.v1_16_R3.PathPoint in project Citizens2 by CitizensDev.

the class PlayerPathfinder method a.

private PathEntity a(PathPoint var0, Map var1, float var2, int var3, float var4) {
    Set<PathDestination> var5 = var1.keySet();
    var0.e = 0.0F;
    var0.f = a(var0, var5);
    var0.g = var0.f;
    this.d.a();
    this.d.a(var0);
    ImmutableSet immutableSet = ImmutableSet.of();
    int var7 = 0;
    Set<PathDestination> var8 = Sets.newHashSetWithExpectedSize(var5.size());
    int var9 = (int) (this.b * var4);
    while (!this.d.e() && ++var7 < var9) {
        PathPoint pathPoint = this.d.c();
        pathPoint.i = true;
        for (PathDestination pathDestination : var5) {
            if (pathPoint.c(pathDestination) <= var3) {
                pathDestination.e();
                var8.add(pathDestination);
            }
        }
        if (!var8.isEmpty())
            break;
        if (pathPoint.a(var0) >= var2)
            continue;
        int i = this.c.a(this.a, pathPoint);
        for (int var12 = 0; var12 < i; var12++) {
            PathPoint var13 = this.a[var12];
            float var14 = pathPoint.a(var13);
            pathPoint.j += var14;
            float var15 = pathPoint.e + var14 + var13.k;
            if (var13.j < var2 && (!var13.c() || var15 < var13.e)) {
                var13.h = pathPoint;
                var13.e = var15;
                var13.f = a(var13, var5) * 1.5F;
                if (var13.c()) {
                    this.d.a(var13, var13.e + var13.f);
                } else {
                    var13.g = var13.e + var13.f;
                    this.d.a(var13);
                }
            }
        }
    }
    Optional var10 = !var8.isEmpty() ? var8.stream().map((var1x) -> {
        return this.a(var1x.d(), (BlockPosition) var1.get(var1x), true);
    }).min(Comparator.comparingInt(PathEntity::e)) : getFallbackDestinations(var1, var5).findFirst();
    if (!var10.isPresent()) {
        return null;
    } else {
        PathEntity var11 = (PathEntity) var10.get();
        return var11;
    }
}
Also used : PathPoint(net.minecraft.server.v1_16_R3.PathPoint) ImmutableSet(com.google.common.collect.ImmutableSet) Optional(java.util.Optional) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) PathDestination(net.minecraft.server.v1_16_R3.PathDestination) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Example 12 with PathPoint

use of net.minecraft.server.v1_16_R3.PathPoint in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

@Override
public PathPoint b() {
    BlockPosition.MutableBlockPosition var1 = new BlockPosition.MutableBlockPosition();
    int var0 = MathHelper.floor(this.b.locY());
    IBlockData var2 = this.a.getType(var1.c(this.b.locX(), var0, this.b.locZ()));
    if (this.b.a(var2.getFluid().getType())) {
        while (this.b.a(var2.getFluid().getType())) {
            var0++;
            var2 = this.a.getType(var1.c(this.b.locX(), var0, this.b.locZ()));
        }
        var0--;
    } else if (e() && this.b.isInWater()) {
        while (var2.getBlock() == Blocks.WATER || var2.getFluid() == FluidTypes.WATER.a(false)) {
            var0++;
            var2 = this.a.getType(var1.c(this.b.locX(), var0, this.b.locZ()));
        }
        var0--;
    } else if (this.b.isOnGround()) {
        var0 = MathHelper.floor(this.b.locY() + 0.5D);
    } else {
        BlockPosition blockPosition = this.b.getChunkCoordinates();
        while ((this.a.getType(blockPosition).isAir() || this.a.getType(blockPosition).a(this.a, blockPosition, PathMode.LAND)) && blockPosition.getY() > 0) blockPosition = blockPosition.down();
        var0 = blockPosition.up().getY();
    }
    BlockPosition var3 = this.b.getChunkCoordinates();
    PathType var4 = a(this.b, var3.getX(), var0, var3.getZ());
    if (this.b.a(var4) < 0.0F) {
        AxisAlignedBB axisAlignedBB = this.b.getBoundingBox();
        if (b(var1.c(axisAlignedBB.minX, var0, axisAlignedBB.minZ)) || b(var1.c(axisAlignedBB.minX, var0, axisAlignedBB.maxZ)) || b(var1.c(axisAlignedBB.maxX, var0, axisAlignedBB.minZ)) || b(var1.c(axisAlignedBB.maxX, var0, axisAlignedBB.maxZ))) {
            PathPoint var6 = a(var1);
            var6.l = a(this.b, var6.a());
            var6.k = this.b.a(var6.l);
            return var6;
        }
    }
    PathPoint var5 = a(var3.getX(), var0, var3.getZ());
    var5.l = a(this.b, var5.a());
    var5.k = this.b.a(var5.l);
    return var5;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) PathType(net.minecraft.server.v1_16_R3.PathType) PathPoint(net.minecraft.server.v1_16_R3.PathPoint) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Example 13 with PathPoint

use of net.minecraft.server.v1_16_R3.PathPoint in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

private boolean a(PathPoint var0) {
    Vec3D var1 = new Vec3D(var0.a - this.b.locX(), var0.b - this.b.locY(), var0.c - this.b.locZ());
    AxisAlignedBB var2 = this.b.getBoundingBox();
    int var3 = MathHelper.f(var1.f() / var2.a());
    var1 = var1.a((1.0F / var3));
    for (int var4 = 1; var4 <= var3; var4++) {
        var2 = var2.c(var1);
        if (a(var2))
            return false;
    }
    return true;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) Vec3D(net.minecraft.server.v1_16_R3.Vec3D) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Example 14 with PathPoint

use of net.minecraft.server.v1_16_R3.PathPoint in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

@Override
public PathPoint b() {
    int i;
    BlockPosition localObject1;
    if ((e()) && (this.b.isInWater())) {
        i = (int) this.b.getBoundingBox().b;
        localObject1 = new BlockPosition.MutableBlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ));
        Block localObject2 = this.a.getType(localObject1).getBlock();
        while ((localObject2 == Blocks.FLOWING_WATER) || (localObject2 == Blocks.WATER)) {
            i++;
            ((MutableBlockPosition) localObject1).c(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ));
            localObject2 = this.a.getType(localObject1).getBlock();
        }
    } else if (this.b.onGround) {
        i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
    } else {
        localObject1 = new BlockPosition(this.b);
        while (((this.a.getType(localObject1).getMaterial() == Material.AIR) || (this.a.getType(localObject1).getBlock().b(this.a, localObject1))) && (localObject1.getY() > 0)) {
            localObject1 = localObject1.down();
        }
        i = localObject1.up().getY();
    }
    localObject1 = new BlockPosition(this.b);
    Object localObject2 = a(this.b, localObject1.getX(), i, localObject1.getZ());
    if (this.b.a((PathType) localObject2) < 0.0F) {
        HashSet<BlockPosition> localHashSet = Sets.newHashSet();
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().c));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().f));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().c));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().f));
        for (BlockPosition localBlockPosition : localHashSet) {
            PathType localPathType = a(this.b, localBlockPosition);
            if (this.b.a(localPathType) >= 0.0F) {
                return a(localBlockPosition.getX(), localBlockPosition.getY(), localBlockPosition.getZ());
            }
        }
    }
    return a(localObject1.getX(), i, localObject1.getZ());
}
Also used : PathType(net.minecraft.server.v1_12_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) Block(net.minecraft.server.v1_12_R1.Block) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 15 with PathPoint

use of net.minecraft.server.v1_16_R3.PathPoint in project Citizens2 by CitizensDev.

the class NMSImpl method getTargetNavigator.

@Override
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest, final NavigatorParameters params) {
    List<PathPoint> list = Lists.<PathPoint>newArrayList(Iterables.<Vector, PathPoint>transform(dest, new Function<Vector, PathPoint>() {

        @Override
        public PathPoint apply(Vector input) {
            return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
        }
    }));
    PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
    final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null, true);
    return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {

        @Override
        public Boolean apply(NavigationAbstract input) {
            return input.a(path, params.speed());
        }
    });
}
Also used : PathPoint(net.minecraft.server.v1_16_R3.PathPoint) Function(com.google.common.base.Function) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) NavigationAbstract(net.minecraft.server.v1_16_R3.NavigationAbstract) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Vector(org.bukkit.util.Vector)

Aggregations

PathPoint (net.minecraft.server.v1_16_R3.PathPoint)12 PathPoint (net.minecraft.server.v1_14_R1.PathPoint)11 PathPoint (net.minecraft.server.v1_15_R1.PathPoint)11 List (java.util.List)10 Optional (java.util.Optional)9 Set (java.util.Set)9 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)9 PathPoint (net.minecraft.server.v1_13_R2.PathPoint)9 Vector (org.bukkit.util.Vector)9 Lists (com.google.common.collect.Lists)8 Sets (com.google.common.collect.Sets)8 Comparator (java.util.Comparator)8 Iterator (java.util.Iterator)8 Map (java.util.Map)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 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)8 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)8