use of net.minecraft.world.level.pathfinder.Node in project Citizens2 by CitizensDev.
the class PlayerNodeEvaluator method getStart.
@Override
public Node getStart() {
BlockPos.MutableBlockPos var1 = new BlockPos.MutableBlockPos();
int var0 = this.mob.getBlockY();
BlockState var2 = this.level.getBlockState(var1.set(this.mob.getX(), var0, this.mob.getZ()));
if (this.mob.canStandOnFluid(var2.getFluidState().getType())) {
while (this.mob.canStandOnFluid(var2.getFluidState().getType())) {
var0++;
var2 = this.level.getBlockState(var1.set(this.mob.getX(), var0, this.mob.getZ()));
}
var0--;
} else if (canFloat() && this.mob.isInWater()) {
while (var2.is(Blocks.WATER) || var2.getFluidState() == Fluids.WATER.getSource(false)) {
var0++;
var2 = this.level.getBlockState(var1.set(this.mob.getX(), var0, this.mob.getZ()));
}
var0--;
} else if (this.mob.isOnGround()) {
var0 = Mth.floor(this.mob.getY() + 0.5D);
} else {
BlockPos blockPos = this.mob.blockPosition();
while ((this.level.getBlockState(blockPos).isAir() || this.level.getBlockState(blockPos).isPathfindable(this.level, blockPos, PathComputationType.LAND)) && blockPos.getY() > this.mob.level.getMinBuildHeight()) blockPos = blockPos.down();
var0 = blockPos.up().getY();
}
BlockPos var3 = this.mob.blockPosition();
BlockPathTypes var4 = getCachedBlockType(this.mob, var3.getX(), var0, var3.getZ());
if (this.mob.getPathfindingMalus(var4) < 0.0F) {
AABB aABB = this.mob.getBoundingBox();
if (hasPositiveMalus(var1.set(aABB.minX, var0, aABB.minZ)) || hasPositiveMalus(var1.set(aABB.minX, var0, aABB.maxZ)) || hasPositiveMalus(var1.set(aABB.maxX, var0, aABB.minZ)) || hasPositiveMalus(var1.set(aABB.maxX, var0, aABB.maxZ))) {
Node var6 = getNode(var1);
var6.type = getBlockPathType(this.mob, var6.asBlockPos());
var6.costMalus = this.mob.getPathfindingMalus(var6.type);
return var6;
}
}
Node var5 = getNode(var3.getX(), var0, var3.getZ());
var5.type = getBlockPathType(this.mob, var5.asBlockPos());
var5.costMalus = this.mob.getPathfindingMalus(var5.type);
return var5;
}
use of net.minecraft.world.level.pathfinder.Node in project AlexsMobs by Alex-the-666.
the class BoneSerpentNodeProcessor method getNode.
/**
* Returns a mapped point or creates and adds one
*/
@Nullable
protected Node getNode(int x, int y, int z) {
Node pathpoint = null;
BlockPathTypes pathnodetype = this.getBlockPathType(this.mob.level, x, y, z);
float f = this.mob.getPathfindingMalus(pathnodetype);
if (f >= 0.0F) {
pathpoint = super.getNode(x, y, z);
pathpoint.type = pathnodetype;
pathpoint.costMalus = Math.max(pathpoint.costMalus, f);
if (this.level.getFluidState(new BlockPos(x, y, z)).isEmpty()) {
pathpoint.costMalus += 8.0F;
}
}
return pathnodetype == BlockPathTypes.OPEN ? pathpoint : pathpoint;
}
use of net.minecraft.world.level.pathfinder.Node in project AlexsMobs by Alex-the-666.
the class CapuchinAITargetBalloons method canEasilyReach.
/**
* Checks to see if this entity can find a short path to the given target.
*/
private boolean canEasilyReach(LivingEntity target) {
this.targetSearchDelay = 10 + this.monkey.getRandom().nextInt(5);
Path path = this.monkey.getNavigation().createPath(target, 0);
if (path == null) {
return false;
} else {
Node pathpoint = path.getEndNode();
if (pathpoint == null) {
return false;
} else {
int i = pathpoint.x - Mth.floor(target.getX());
int j = pathpoint.z - Mth.floor(target.getZ());
return (double) (i * i + j * j) <= 2.25D;
}
}
}
use of net.minecraft.world.level.pathfinder.Node in project Atum2 by TeamMetallurgy.
the class OpenAnyDoorGoal method canUse.
@Override
public boolean canUse() {
if (!this.mob.horizontalCollision) {
return false;
} else {
PathNavigation pathNavigator = this.mob.getNavigation();
Path path = pathNavigator.getPath();
if (path != null && !path.isDone()) {
for (int i = 0; i < Math.min(path.getNextNodeIndex() + 2, path.getNodeCount()); ++i) {
Node pathPoint = path.getNode(i);
this.doorPos = new BlockPos(pathPoint.x, pathPoint.y + 1, pathPoint.z);
if (!(this.mob.distanceToSqr(this.doorPos.getX(), this.mob.getY(), this.doorPos.getZ()) > 2.25D)) {
this.hasDoor = canOpen(this.mob.level, this.doorPos);
if (this.hasDoor) {
return true;
}
}
}
this.doorPos = this.mob.blockPosition().above();
this.hasDoor = canOpen(this.mob.level, this.doorPos);
return this.hasDoor;
} else {
return false;
}
}
}
Aggregations