Search in sources :

Example 6 with Path

use of net.minecraft.pathfinding.Path in project takumicraft by TNTModders.

the class EntityRabbitCreeper method updateAITasks.

@Override
public void updateAITasks() {
    if (this.currentMoveTypeDuration > 0) {
        --this.currentMoveTypeDuration;
    }
    if (this.carrotTicks > 0) {
        this.carrotTicks -= this.rand.nextInt(3);
        if (this.carrotTicks < 0) {
            this.carrotTicks = 0;
        }
    }
    if (this.onGround) {
        if (!this.wasOnGround) {
            this.setJumping(false);
            this.checkLandingDelay();
        }
        if (this.currentMoveTypeDuration == 0) {
            EntityLivingBase lvt_1_1_ = this.getAttackTarget();
            if (lvt_1_1_ != null && this.getDistanceSqToEntity(lvt_1_1_) < 16.0D) {
                this.calculateRotationYaw(lvt_1_1_.posX, lvt_1_1_.posZ);
                this.moveHelper.setMoveTo(lvt_1_1_.posX, lvt_1_1_.posY, lvt_1_1_.posZ, this.moveHelper.getSpeed());
                this.startJumping();
                this.wasOnGround = true;
            }
        }
        RabbitJumpHelper lvt_1_2_ = (RabbitJumpHelper) this.jumpHelper;
        if (!lvt_1_2_.getIsJumping()) {
            if (this.moveHelper.isUpdating() && this.currentMoveTypeDuration == 0) {
                Path lvt_2_1_ = this.navigator.getPath();
                Vec3d lvt_3_1_ = new Vec3d(this.moveHelper.getX(), this.moveHelper.getY(), this.moveHelper.getZ());
                if (lvt_2_1_ != null && lvt_2_1_.getCurrentPathIndex() < lvt_2_1_.getCurrentPathLength()) {
                    lvt_3_1_ = lvt_2_1_.getPosition(this);
                }
                this.calculateRotationYaw(lvt_3_1_.x, lvt_3_1_.z);
                this.startJumping();
            }
        } else if (!lvt_1_2_.canJump()) {
            this.enableJumpControl();
        }
    }
    this.wasOnGround = this.onGround;
}
Also used : Path(net.minecraft.pathfinding.Path) Vec3d(net.minecraft.util.math.Vec3d)

Example 7 with Path

use of net.minecraft.pathfinding.Path in project pnc-repressurized by TeamPneumatic.

the class CoordTrackUpgradeHandler method navigateToSurface.

@SideOnly(Side.CLIENT)
public EnumNavigationResult navigateToSurface(EntityPlayer player) {
    World world = player.world;
    BlockPos navigatingPos = world.getHeight(new BlockPos(player));
    Path path = PneumaticCraftUtils.getPathFinder().findPath(world, PneumaticCraftUtils.createDummyEntity(player), navigatingPos, (float) SEARCH_RANGE);
    if (path != null) {
        for (int i = 0; i < path.getCurrentPathLength(); i++) {
            PathPoint pathPoint = path.getPathPointFromIndex(i);
            BlockPos pathPos = new BlockPos(pathPoint.x, pathPoint.y, pathPoint.z);
            if (world.canSeeSky(pathPos)) {
                coordTracker = new RenderCoordWireframe(world, pathPos);
                navigator = new RenderNavigator(world, pathPos);
                return EnumNavigationResult.EASY_PATH;
            }
        }
    }
    path = getDronePath(player, navigatingPos);
    if (path != null) {
        for (int i = 0; i < path.getCurrentPathLength(); i++) {
            PathPoint pathPoint = path.getPathPointFromIndex(i);
            BlockPos pathPos = new BlockPos(pathPoint.x, pathPoint.y, pathPoint.z);
            if (world.canSeeSky(pathPos)) {
                coordTracker = new RenderCoordWireframe(world, pathPos);
                navigator = new RenderNavigator(world, pathPos);
                return EnumNavigationResult.DRONE_PATH;
            }
        }
    }
    return EnumNavigationResult.NO_PATH;
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) PathPoint(net.minecraft.pathfinding.PathPoint) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Path

use of net.minecraft.pathfinding.Path in project pnc-repressurized by TeamPneumatic.

the class EntityPathNavigateDrone method getPathToPos.

@Nullable
@Override
public Path getPathToPos(BlockPos pos) {
    // When the destination is not a valid block, we can stop right away
    if (!pathfindingEntity.isBlockValidPathfindBlock(pos) || pathfindingEntity.getDistanceSqToCenter(pos) < 0.3)
        return null;
    // Store the potential teleport destination
    telPos = pos;
    // If we are forced to teleport, trigger right away
    if (forceTeleport) {
        teleportCounter = 0;
        return null;
    }
    pathfindingEntity.setStandby(false);
    teleportCounter = -1;
    Path path = super.getPathToPos(pos);
    // Only paths that actually end up where we want to are valid, not just halfway.
    if (path != null) {
        PathPoint lastPoint = path.getFinalPathPoint();
        if (lastPoint != null && (lastPoint.x != pos.getX() || lastPoint.y != pos.getY() || lastPoint.z != pos.getZ())) {
            path = null;
        }
    }
    // If no valid flight path, teleport instead.
    if (path == null) {
        teleportCounter = 0;
    }
    return path;
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) Nullable(javax.annotation.Nullable)

Example 9 with Path

use of net.minecraft.pathfinding.Path in project pnc-repressurized by TeamPneumatic.

the class PathfinderDrone method findPath.

@Nullable
private Path findPath(IBlockAccess worldIn, EntityLiving entitylivingIn, double x, double y, double z, float maxDistance) {
    this.path.clearPath();
    this.nodeProcessor.init(worldIn, entitylivingIn);
    PathPoint pathpoint = this.nodeProcessor.getStart();
    PathPoint pathpoint1 = this.nodeProcessor.getPathPointToCoords(x, y, z);
    Path path = this.findPath(pathpoint, pathpoint1, maxDistance);
    this.nodeProcessor.postProcess();
    return path;
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) Nullable(javax.annotation.Nullable)

Example 10 with Path

use of net.minecraft.pathfinding.Path in project pnc-repressurized by TeamPneumatic.

the class PathfinderDrone method createPath.

/**
 * Returns a new PathEntity for a given start and end point
 */
private Path createPath(PathPoint start, PathPoint end) {
    int i = 1;
    for (PathPoint pathpoint = end; pathpoint.previous != null; pathpoint = pathpoint.previous) {
        ++i;
    }
    PathPoint[] apathpoint = new PathPoint[i];
    PathPoint pathpoint1 = end;
    --i;
    for (apathpoint[i] = end; pathpoint1.previous != null; apathpoint[i] = pathpoint1) {
        pathpoint1 = pathpoint1.previous;
        --i;
    }
    return new Path(apathpoint);
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) PathPoint(net.minecraft.pathfinding.PathPoint)

Aggregations

Path (net.minecraft.pathfinding.Path)16 PathPoint (net.minecraft.pathfinding.PathPoint)8 Vec3d (net.minecraft.util.math.Vec3d)5 BlockPos (net.minecraft.util.math.BlockPos)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