Search in sources :

Example 1 with PathNavigationRegion

use of net.minecraft.world.level.PathNavigationRegion in project Citizens2 by CitizensDev.

the class PlayerPathfinder method findPath.

public Path findPath(PathNavigationRegion var0, EntityHumanNPC var1, Set<BlockPos> var2, float var3, int var4, float var5) {
    this.openSet.clear();
    this.nodeEvaluator.prepare(var0, var1);
    Node var6 = this.nodeEvaluator.getStart();
    Map<Target, BlockPos> var7 = var2.stream().collect(Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity()));
    Path var8 = findPath(var0.getProfiler(), var6, var7, var3, var4, var5);
    this.nodeEvaluator.done();
    return var8;
}
Also used : EntityHumanNPC(net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC) Path(net.minecraft.world.level.pathfinder.Path) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) BinaryHeap(net.minecraft.world.level.pathfinder.BinaryHeap) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) BlockPos(net.minecraft.core.BlockPos) Target(net.minecraft.world.level.pathfinder.Target) Map(java.util.Map) MetricCategory(net.minecraft.util.profiling.metrics.MetricCategory) PathFinder(net.minecraft.world.level.pathfinder.PathFinder) Optional(java.util.Optional) Comparator(java.util.Comparator) Mob(net.minecraft.world.entity.Mob) PathNavigationRegion(net.minecraft.world.level.PathNavigationRegion) Node(net.minecraft.world.level.pathfinder.Node) Path(net.minecraft.world.level.pathfinder.Path) Target(net.minecraft.world.level.pathfinder.Target) Node(net.minecraft.world.level.pathfinder.Node) BlockPos(net.minecraft.core.BlockPos)

Example 2 with PathNavigationRegion

use of net.minecraft.world.level.PathNavigationRegion in project Citizens2 by CitizensDev.

the class PlayerNavigation method createPath.

@Override
protected Path createPath(Set<BlockPos> var0, int var1, boolean var2, int var3, float var4) {
    if (var0.isEmpty() || (this.mob.getY() < this.level.getMinBuildHeight()) || !canUpdatePath())
        return null;
    if (this.path != null && !this.path.isDone() && var0.contains(this.targetPos))
        return this.path;
    this.level.getProfiler().push("pathfind");
    BlockPos var5 = var2 ? this.mob.blockPosition().up() : this.mob.blockPosition();
    int var6 = (int) (var4 + var1);
    PathNavigationRegion var7 = new PathNavigationRegion(this.level, var5.c(-var6, -var6, -var6), var5.c(var6, var6, var6));
    Path var8 = this.pathFinder.findPath(var7, this.mob, var0, var4, var3, this.maxVisitedNodesMultiplier);
    this.level.getProfiler().pop();
    if (var8 != null && var8.getTarget() != null) {
        this.targetPos = var8.getTarget();
        this.reachRange = var3;
        resetStuckTimeout();
    }
    return var8;
}
Also used : Path(net.minecraft.world.level.pathfinder.Path) BlockPos(net.minecraft.core.BlockPos) PathNavigationRegion(net.minecraft.world.level.PathNavigationRegion)

Example 3 with PathNavigationRegion

use of net.minecraft.world.level.PathNavigationRegion in project Citizens2 by CitizensDev.

the class PlayerPathfinder method findPath.

@Override
public Path findPath(PathNavigationRegion var0, Mob var1, Set<BlockPos> var2, float var3, int var4, float var5) {
    this.openSet.clear();
    this.nodeEvaluator.prepare(var0, var1);
    Node var6 = this.nodeEvaluator.getStart();
    Map<Target, BlockPos> var7 = var2.stream().collect(Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity()));
    Path var8 = findPath(var0.getProfiler(), var6, var7, var3, var4, var5);
    this.nodeEvaluator.done();
    return var8;
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Path(net.minecraft.world.level.pathfinder.Path) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) BinaryHeap(net.minecraft.world.level.pathfinder.BinaryHeap) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) EntityHumanNPC(net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC) BlockPos(net.minecraft.core.BlockPos) Target(net.minecraft.world.level.pathfinder.Target) Map(java.util.Map) MetricCategory(net.minecraft.util.profiling.metrics.MetricCategory) PathFinder(net.minecraft.world.level.pathfinder.PathFinder) Optional(java.util.Optional) Comparator(java.util.Comparator) Mob(net.minecraft.world.entity.Mob) PathNavigationRegion(net.minecraft.world.level.PathNavigationRegion) Node(net.minecraft.world.level.pathfinder.Node) Path(net.minecraft.world.level.pathfinder.Path) Target(net.minecraft.world.level.pathfinder.Target) Node(net.minecraft.world.level.pathfinder.Node) BlockPos(net.minecraft.core.BlockPos)

Example 4 with PathNavigationRegion

use of net.minecraft.world.level.PathNavigationRegion in project Citizens2 by CitizensDev.

the class PlayerPathfinder method findPath.

public Path findPath(PathNavigationRegion var0, EntityHumanNPC var1, Set<BlockPos> var2, float var3, int var4, float var5) {
    this.openSet.clear();
    this.nodeEvaluator.prepare(var0, var1);
    Node var6 = this.nodeEvaluator.getStart();
    Map<Target, BlockPos> var7 = var2.stream().collect(Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity()));
    Path var8 = findPath(var0.getProfiler(), var6, var7, var3, var4, var5);
    this.nodeEvaluator.done();
    return var8;
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Path(net.minecraft.world.level.pathfinder.Path) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) BinaryHeap(net.minecraft.world.level.pathfinder.BinaryHeap) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) EntityHumanNPC(net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC) BlockPos(net.minecraft.core.BlockPos) Target(net.minecraft.world.level.pathfinder.Target) Map(java.util.Map) MetricCategory(net.minecraft.util.profiling.metrics.MetricCategory) PathFinder(net.minecraft.world.level.pathfinder.PathFinder) Optional(java.util.Optional) Comparator(java.util.Comparator) Mob(net.minecraft.world.entity.Mob) PathNavigationRegion(net.minecraft.world.level.PathNavigationRegion) Node(net.minecraft.world.level.pathfinder.Node) Path(net.minecraft.world.level.pathfinder.Path) Target(net.minecraft.world.level.pathfinder.Target) Node(net.minecraft.world.level.pathfinder.Node) BlockPos(net.minecraft.core.BlockPos)

Example 5 with PathNavigationRegion

use of net.minecraft.world.level.PathNavigationRegion in project Citizens2 by CitizensDev.

the class PlayerPathfinder method findPath.

@Override
public Path findPath(PathNavigationRegion var0, Mob var1, Set<BlockPos> var2, float var3, int var4, float var5) {
    this.openSet.clear();
    this.nodeEvaluator.prepare(var0, var1);
    Node var6 = this.nodeEvaluator.getStart();
    Map<Target, BlockPos> var7 = var2.stream().collect(Collectors.toMap(p -> this.nodeEvaluator.getGoal(p.getX(), p.getY(), p.getZ()), Function.identity()));
    Path var8 = findPath(var0.getProfiler(), var6, var7, var3, var4, var5);
    this.nodeEvaluator.done();
    return var8;
}
Also used : EntityHumanNPC(net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC) Path(net.minecraft.world.level.pathfinder.Path) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) BinaryHeap(net.minecraft.world.level.pathfinder.BinaryHeap) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) BlockPos(net.minecraft.core.BlockPos) Target(net.minecraft.world.level.pathfinder.Target) Map(java.util.Map) MetricCategory(net.minecraft.util.profiling.metrics.MetricCategory) PathFinder(net.minecraft.world.level.pathfinder.PathFinder) Optional(java.util.Optional) Comparator(java.util.Comparator) Mob(net.minecraft.world.entity.Mob) PathNavigationRegion(net.minecraft.world.level.PathNavigationRegion) Node(net.minecraft.world.level.pathfinder.Node) Path(net.minecraft.world.level.pathfinder.Path) Target(net.minecraft.world.level.pathfinder.Target) Node(net.minecraft.world.level.pathfinder.Node) BlockPos(net.minecraft.core.BlockPos)

Aggregations

BlockPos (net.minecraft.core.BlockPos)6 PathNavigationRegion (net.minecraft.world.level.PathNavigationRegion)6 Path (net.minecraft.world.level.pathfinder.Path)6 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 Optional (java.util.Optional)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 ProfilerFiller (net.minecraft.util.profiling.ProfilerFiller)4 MetricCategory (net.minecraft.util.profiling.metrics.MetricCategory)4 Mob (net.minecraft.world.entity.Mob)4 BinaryHeap (net.minecraft.world.level.pathfinder.BinaryHeap)4 Node (net.minecraft.world.level.pathfinder.Node)4 PathFinder (net.minecraft.world.level.pathfinder.PathFinder)4