use of net.minecraft.server.v1_11_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerNavigation method a.
@Override
public boolean a(PathEntity paramPathEntity, double paramDouble) {
if (paramPathEntity == null) {
this.c = null;
return false;
}
if (!paramPathEntity.a(this.c)) {
this.c = paramPathEntity;
}
d();
if (this.c.d() == 0) {
return false;
}
this.d = paramDouble;
Vec3D localVec3D = c();
this.h = this.g;
this.i = localVec3D;
return true;
}
use of net.minecraft.server.v1_11_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;
}
use of net.minecraft.server.v1_11_R1.PathEntity in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
private PathEntity a(PathPoint paramPathPoint1, PathPoint paramPathPoint2) {
int i = 1;
PathPoint localPathPoint = paramPathPoint2;
while (localPathPoint.h != null) {
i++;
localPathPoint = localPathPoint.h;
}
PathPoint[] arrayOfPathPoint = new PathPoint[i];
localPathPoint = paramPathPoint2;
arrayOfPathPoint[(--i)] = localPathPoint;
while (localPathPoint.h != null) {
localPathPoint = localPathPoint.h;
arrayOfPathPoint[(--i)] = localPathPoint;
}
return new PathEntity(arrayOfPathPoint);
}
use of net.minecraft.server.v1_11_R1.PathEntity in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelper_v1_11_R1 method follow.
@Override
public void follow(final Entity target, final Entity follower, final double speed, final double lead, final double maxRange, final boolean allowWander) {
if (target == null || follower == null) {
return;
}
final net.minecraft.server.v1_11_R1.Entity nmsEntityFollower = ((CraftEntity) follower).getHandle();
if (!(nmsEntityFollower instanceof EntityInsentient)) {
return;
}
final EntityInsentient nmsFollower = (EntityInsentient) nmsEntityFollower;
final NavigationAbstract followerNavigation = nmsFollower.getNavigation();
UUID uuid = follower.getUniqueId();
if (followTasks.containsKey(uuid)) {
followTasks.get(uuid).cancel();
}
final int locationNearInt = (int) Math.floor(lead);
final boolean hasMax = maxRange > lead;
followTasks.put(follower.getUniqueId(), new BukkitRunnable() {
private boolean inRadius = false;
public void run() {
if (!target.isValid() || !follower.isValid()) {
this.cancel();
}
followerNavigation.a(2F);
Location targetLocation = target.getLocation();
PathEntity path;
if (hasMax && !Utilities.checkLocation(targetLocation, follower.getLocation(), maxRange) && !target.isDead() && target.isOnGround()) {
if (!inRadius) {
follower.teleport(Utilities.getWalkableLocationNear(targetLocation, locationNearInt));
} else {
inRadius = false;
path = followerNavigation.a(targetLocation.getX(), targetLocation.getY(), targetLocation.getZ());
if (path != null) {
followerNavigation.a(path, 1D);
followerNavigation.a(2D);
}
}
} else if (!inRadius && !Utilities.checkLocation(targetLocation, follower.getLocation(), lead)) {
path = followerNavigation.a(targetLocation.getX(), targetLocation.getY(), targetLocation.getZ());
if (path != null) {
followerNavigation.a(path, 1D);
followerNavigation.a(2D);
}
} else {
inRadius = true;
}
if (inRadius && !allowWander) {
followerNavigation.o();
}
nmsFollower.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(speed);
}
}.runTaskTimer(NMSHandler.getJavaPlugin(), 0, 10));
}
use of net.minecraft.server.v1_11_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.r))) {
return this.c;
}
this.r = 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.s.a(localChunkCache, this.a, this.r, f1);
this.b.methodProfiler.b();
return localPathEntity;
}
Aggregations