Search in sources :

Example 1 with PathNavigateGround

use of net.minecraft.pathfinding.PathNavigateGround 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 2 with PathNavigateGround

use of net.minecraft.pathfinding.PathNavigateGround 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)

Aggregations

Path (net.minecraft.pathfinding.Path)2 PathNavigateGround (net.minecraft.pathfinding.PathNavigateGround)2 PathPoint (net.minecraft.pathfinding.PathPoint)1 BlockPos (net.minecraft.util.math.BlockPos)1 NotNull (org.jetbrains.annotations.NotNull)1