Search in sources :

Example 1 with Path

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;
}
Also used : Path(net.minecraft.pathfinding.Path) Vec3d(net.minecraft.util.math.Vec3d)

Example 2 with Path

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;
        }
    }
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) BlockPos(net.minecraft.util.math.BlockPos) PathPoint(net.minecraft.pathfinding.PathPoint) PathNavigateGround(net.minecraft.pathfinding.PathNavigateGround)

Example 3 with Path

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());
}
Also used : Path(net.minecraft.pathfinding.Path) EntitySilverfish(net.minecraft.entity.monster.EntitySilverfish)

Example 4 with Path

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);
}
Also used : Path(net.minecraft.pathfinding.Path) NotNull(org.jetbrains.annotations.NotNull) PathNavigateGround(net.minecraft.pathfinding.PathNavigateGround)

Example 5 with 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);
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) BlockPos(net.minecraft.util.math.BlockPos) NotNull(org.jetbrains.annotations.NotNull) PathPoint(net.minecraft.pathfinding.PathPoint) Nullable(org.jetbrains.annotations.Nullable) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Path (net.minecraft.pathfinding.Path)15 PathPoint (net.minecraft.pathfinding.PathPoint)8 BlockPos (net.minecraft.util.math.BlockPos)4 Vec3d (net.minecraft.util.math.Vec3d)4 Nullable (javax.annotation.Nullable)3 NotNull (org.jetbrains.annotations.NotNull)3 PathNavigateGround (net.minecraft.pathfinding.PathNavigateGround)2 Nullable (org.jetbrains.annotations.Nullable)2 EntityAspectedDemonBase (WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntitySilverfish (net.minecraft.entity.monster.EntitySilverfish)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 World (net.minecraft.world.World)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1