use of net.minecraft.server.v1_13_R2.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;
}
use of net.minecraft.server.v1_13_R2.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;
}
use of net.minecraft.server.v1_13_R2.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());
}
use of net.minecraft.server.v1_13_R2.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());
}
});
}
use of net.minecraft.server.v1_13_R2.PathPoint in project Citizens2 by CitizensDev.
the class PlayerNavigation method superD_.
protected void superD_() {
if (this.c == null)
return;
for (int var0 = 0; var0 < this.c.e(); var0++) {
PathPoint var1 = this.c.a(var0);
PathPoint var2 = (var0 + 1 < this.c.e()) ? this.c.a(var0 + 1) : null;
IBlockData var3 = this.b.getType(new BlockPosition(var1.a, var1.b, var1.c));
if (var3.a(Blocks.CAULDRON)) {
this.c.a(var0, var1.a(var1.a, var1.b + 1, var1.c));
if (var2 != null && var1.b >= var2.b)
this.c.a(var0 + 1, var1.a(var2.a, var1.b + 1, var2.c));
}
}
}
Aggregations