Search in sources :

Example 1 with PathDestination

use of net.minecraft.server.v1_15_R1.PathDestination in project Citizens2 by CitizensDev.

the class PlayerPathfinder method a.

private float a(PathPoint var0, Set<PathDestination> var1) {
    float var2 = Float.MAX_VALUE;
    for (PathDestination var4 : var1) {
        float var5 = var0.a(var4);
        var4.a(var5, var0);
        var2 = Math.min(var5, var2);
    }
    return var2;
}
Also used : PathDestination(net.minecraft.server.v1_16_R3.PathDestination)

Example 2 with PathDestination

use of net.minecraft.server.v1_15_R1.PathDestination 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 3 with PathDestination

use of net.minecraft.server.v1_15_R1.PathDestination in project Citizens2 by CitizensDev.

the class PlayerPathfinder method a.

private float a(PathPoint var0, Set var1) {
    float var2 = Float.MAX_VALUE;
    float var5;
    for (Iterator var4 = var1.iterator(); var4.hasNext(); var2 = Math.min(var5, var2)) {
        PathDestination var6 = (PathDestination) var4.next();
        var5 = var0.a(var6);
        var6.a(var5, var0);
    }
    return var2;
}
Also used : Iterator(java.util.Iterator) PathDestination(net.minecraft.server.v1_15_R1.PathDestination)

Example 4 with PathDestination

use of net.minecraft.server.v1_15_R1.PathDestination in project Citizens2 by CitizensDev.

the class PlayerPathfinder method a.

public PathEntity a(ChunkCache var0, EntityHumanNPC var1, Set<BlockPosition> var2, float var3, int var4, float var5) {
    this.a.a();
    this.e.a(var0, var1);
    PathPoint var6 = this.e.b();
    Map<PathDestination, BlockPosition> var7 = var2.stream().collect(Collectors.toMap((var0x) -> {
        return this.e.a((double) var0x.getX(), (double) var0x.getY(), (double) var0x.getZ());
    }, Function.identity()));
    PathEntity var8 = this.a(var6, var7, var3, var4, var5);
    this.e.a();
    return var8;
}
Also used : Pathfinder(net.minecraft.server.v1_15_R1.Pathfinder) EntityHumanNPC(net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC) Iterator(java.util.Iterator) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) ChunkCache(net.minecraft.server.v1_15_R1.ChunkCache) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Path(net.minecraft.server.v1_15_R1.Path) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) EntityInsentient(net.minecraft.server.v1_15_R1.EntityInsentient) PathDestination(net.minecraft.server.v1_15_R1.PathDestination) Map(java.util.Map) Optional(java.util.Optional) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) Comparator(java.util.Comparator) PathPoint(net.minecraft.server.v1_15_R1.PathPoint) PathPoint(net.minecraft.server.v1_15_R1.PathPoint) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) PathDestination(net.minecraft.server.v1_15_R1.PathDestination)

Example 5 with PathDestination

use of net.minecraft.server.v1_15_R1.PathDestination 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.a.a();
    this.e.a(var0, var1);
    PathPoint var6 = this.e.b();
    Map<PathDestination, BlockPosition> var7 = var2.stream().collect(Collectors.toMap((var0x) -> {
        return this.e.a((double) var0x.getX(), (double) var0x.getY(), (double) var0x.getZ());
    }, Function.identity()));
    PathEntity var8 = this.a(var6, var7, var3, var4, var5);
    this.e.a();
    return var8;
}
Also used : Pathfinder(net.minecraft.server.v1_15_R1.Pathfinder) EntityHumanNPC(net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC) Iterator(java.util.Iterator) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) ChunkCache(net.minecraft.server.v1_15_R1.ChunkCache) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Path(net.minecraft.server.v1_15_R1.Path) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) EntityInsentient(net.minecraft.server.v1_15_R1.EntityInsentient) PathDestination(net.minecraft.server.v1_15_R1.PathDestination) Map(java.util.Map) Optional(java.util.Optional) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) Comparator(java.util.Comparator) PathPoint(net.minecraft.server.v1_15_R1.PathPoint) PathPoint(net.minecraft.server.v1_15_R1.PathPoint) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) PathDestination(net.minecraft.server.v1_15_R1.PathDestination)

Aggregations

Iterator (java.util.Iterator)6 Optional (java.util.Optional)5 Lists (com.google.common.collect.Lists)4 Sets (com.google.common.collect.Sets)4 Comparator (java.util.Comparator)4 List (java.util.List)4 Map (java.util.Map)4 Set (java.util.Set)4 Function (java.util.function.Function)4 Collectors (java.util.stream.Collectors)4 Stream (java.util.stream.Stream)4 Setting (net.citizensnpcs.Settings.Setting)4 PathDestination (net.minecraft.server.v1_15_R1.PathDestination)4 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)3 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)3 ChunkCache (net.minecraft.server.v1_15_R1.ChunkCache)3 EntityInsentient (net.minecraft.server.v1_15_R1.EntityInsentient)3 Path (net.minecraft.server.v1_15_R1.Path)3 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)3 PathPoint (net.minecraft.server.v1_15_R1.PathPoint)3