Search in sources :

Example 6 with PathEntity

use of net.minecraft.server.v1_15_R1.PathEntity 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)

Example 7 with PathEntity

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

the class PlayerNavigation method a.

@Override
protected PathEntity a(Set<BlockPosition> var0, int var1, boolean var2, int var3) {
    if (var0.isEmpty())
        return null;
    if (this.a.locY() < 0.0D)
        return null;
    if (!a())
        return null;
    if (this.c != null && !this.c.c() && var0.contains(this.p))
        return this.c;
    this.b.getMethodProfiler().enter("pathfind");
    float var4 = (float) this.a.b(GenericAttributes.FOLLOW_RANGE);
    BlockPosition var5 = var2 ? this.a.getChunkCoordinates().up() : this.a.getChunkCoordinates();
    int var6 = (int) (var4 + var1);
    ChunkCache var7 = new ChunkCache(this.b, var5.b(-var6, -var6, -var6), var5.b(var6, var6, var6));
    PathEntity var8 = this.s.a(var7, this.a, var0, var4, var3, this.r);
    this.b.getMethodProfiler().exit();
    if (var8 != null && var8.m() != null) {
        this.p = var8.m();
        this.q = var3;
        e();
    }
    return var8;
}
Also used : ChunkCache(net.minecraft.server.v1_16_R3.ChunkCache) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) BaseBlockPosition(net.minecraft.server.v1_16_R3.BaseBlockPosition) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) PathPoint(net.minecraft.server.v1_16_R3.PathPoint)

Example 8 with PathEntity

use of net.minecraft.server.v1_15_R1.PathEntity 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 9 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.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 10 with PathEntity

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

the class PlayerNavigation method a2.

public PathEntity a2(BlockPosition paramBlockPosition) {
    if (!b()) {
        return null;
    }
    if ((this.c != null) && (!this.c.b()) && (paramBlockPosition.equals(this.q))) {
        return this.c;
    }
    this.q = paramBlockPosition;
    float f1 = h();
    this.b.methodProfiler.a("pathfind");
    BlockPosition localBlockPosition = new BlockPosition(this.a);
    int i1 = (int) (f1 + 8.0F);
    ChunkCache localChunkCache = new ChunkCache(this.b, localBlockPosition.a(-i1, -i1, -i1), localBlockPosition.a(i1, i1, i1), 0);
    PathEntity localPathEntity = this.r.a(localChunkCache, this.a, this.q, f1);
    this.b.methodProfiler.b();
    return localPathEntity;
}
Also used : ChunkCache(net.minecraft.server.v1_11_R1.ChunkCache) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) PathEntity(net.minecraft.server.v1_11_R1.PathEntity) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

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