use of net.minecraft.pathfinding.Path in project NetherEx by LogicTechCorp.
the class EntityEmber method updateAITasks.
@Override
public void updateAITasks() {
if (isWet()) {
attackEntityFrom(DamageSource.DROWN, 1.0F);
}
if (currentMoveTypeDuration > 0) {
--currentMoveTypeDuration;
}
if (onGround) {
if (!wasOnGround) {
setJumping(false);
checkLandingDelay();
}
JumpHelper helper = (JumpHelper) jumpHelper;
if (!helper.getIsJumping()) {
if (moveHelper.isUpdating() && currentMoveTypeDuration == 0) {
Path path = navigator.getPath();
Vec3d vec3d = new Vec3d(moveHelper.getX(), moveHelper.getY(), moveHelper.getZ());
if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) {
vec3d = path.getPosition(this);
}
calculateRotationYaw(vec3d.xCoord, vec3d.zCoord);
startJumping();
}
} else if (!helper.canJump()) {
enableJumpControl();
}
}
wasOnGround = onGround;
}
use of net.minecraft.pathfinding.Path in project NetherEx by LogicTechCorp.
the class EntityAIFenceGateInteract method shouldExecute.
@Override
public boolean shouldExecute() {
if (!theEntity.isCollidedHorizontally) {
return false;
} else {
PathNavigateGround pathnavigateground = (PathNavigateGround) theEntity.getNavigator();
Path path = pathnavigateground.getPath();
if (path != null && !path.isFinished() && pathnavigateground.getEnterDoors()) {
for (int i = 0; i < Math.min(path.getCurrentPathIndex() + 2, path.getCurrentPathLength()); ++i) {
PathPoint pathpoint = path.getPathPointFromIndex(i);
fenceGatePos = new BlockPos(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord);
if (theEntity.getDistanceSq((double) fenceGatePos.getX(), theEntity.posY, (double) fenceGatePos.getZ()) <= 2.25D) {
fenceGate = getFenceGate(fenceGatePos);
if (fenceGate != null) {
return true;
}
}
}
fenceGatePos = (new BlockPos(theEntity));
fenceGate = getFenceGate(fenceGatePos);
return fenceGate != null;
} else {
return false;
}
}
}
use of net.minecraft.pathfinding.Path in project EnderIO by SleepyTrousers.
the class SilverfishAttractorHandler method tick.
@Override
public void tick(TileAttractor attractor, EntityLiving entity) {
EntitySilverfish sf = (EntitySilverfish) entity;
Path pathentity = getPathEntityToEntity(entity, attractor.getTarget(), attractor.getRange() * 2);
sf.getNavigator().setPath(pathentity, sf.getAIMoveSpeed());
}
use of net.minecraft.pathfinding.Path in project minecolonies by Minecolonies.
the class EntityAIGateInteract method checkPath.
/**
* Checks if there exists a path.
*
* @return true if the fence gate can be passed.
*/
private boolean checkPath() {
@NotNull final PathNavigateGround pathnavigateground = (PathNavigateGround) this.theEntity.getNavigator();
final Path path = pathnavigateground.getPath();
return path != null && !path.isFinished() && pathnavigateground.getEnterDoors() && checkFenceGate(path);
}
use of net.minecraft.pathfinding.Path in project minecolonies by Minecolonies.
the class AbstractPathJob method finalizePath.
/**
* Generate the path to the target node.
*
* @param targetNode the node to path to.
* @return the path.
*/
@NotNull
private Path finalizePath(final Node targetNode) {
// Compute length of path, since we need to allocate an array. This is cheaper/faster than building a List
// and converting it. Yes, we have targetNode.steps, but I do not want to rely on that being accurate (I might
// fudge that value later on for cutoff purposes
int pathLength = 0;
@Nullable Node node = targetNode;
while (node.parent != null) {
++pathLength;
node = node.parent;
}
@NotNull final PathPoint[] points = new PathPoint[pathLength];
@Nullable Node nextInPath = null;
node = targetNode;
while (node.parent != null) {
if (debugDrawEnabled) {
addPathNodeToDebug(node);
}
--pathLength;
@NotNull final BlockPos pos = node.pos;
if (node.isSwimming()) {
// Not truly necessary but helps prevent them spinning in place at swimming nodes
pos.add(BLOCKPOS_DOWN);
}
@NotNull final PathPointExtended p = new PathPointExtended(pos);
// Climbing on a ladder?
if (nextInPath != null && onALadder(node, nextInPath, pos)) {
p.setOnLadder(true);
if (nextInPath.pos.getY() > pos.getY()) {
// We only care about facing if going up
// In the case of BlockVines (Which does not have EnumFacing) we have to check the metadata of the vines... bitwise...
setLadderFacing(world, pos, p);
}
} else if (onALadder(node.parent, node.parent, pos)) {
p.setOnLadder(true);
}
points[pathLength] = p;
nextInPath = node;
node = node.parent;
}
doDebugPrinting(points);
return new Path(points);
}
Aggregations