Java Code Examples for com.sk89q.worldedit.world.World#getMaxY()

The following examples show how to use com.sk89q.worldedit.world.World#getMaxY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerWrapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
    final Vector pos = getBlockIn();
    final int x = pos.getBlockX();
    final int initialY = Math.max(0, pos.getBlockY());
    int y = Math.max(0, pos.getBlockY() + 1);
    final int z = pos.getBlockZ();
    final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
    final World world = getPosition().getWorld();

    while (y <= world.getMaxY() + 2) {
        if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            break; // Hit something
        } else if (y > maxY + 1) {
            break;
        } else if (y == maxY + 1) {
            floatAt(x, y - 1, z, alwaysGlass);
            return true;
        }

        ++y;
    }

    return false;
}
 
Example 2
Source File: AbstractPlayerActor.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
    final Vector pos = getBlockIn();
    final int x = pos.getBlockX();
    final int initialY = Math.max(0, pos.getBlockY());
    int y = Math.max(0, pos.getBlockY() + 1);
    final int z = pos.getBlockZ();
    final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
    final World world = getPosition().getWorld();

    while (y <= world.getMaxY() + 2) {
        if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            break; // Hit something
        } else if (y > maxY + 1) {
            break;
        } else if (y == maxY + 1) {
            floatAt(x, y - 1, z, alwaysGlass);
            return true;
        }

        ++y;
    }

    return false;
}
 
Example 3
Source File: PlayerWrapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
    Vector pos = getBlockIn();
    int x = pos.getBlockX();
    int initialY = Math.max(0, pos.getBlockY());
    int y = Math.max(0, pos.getBlockY() + 2);
    int z = pos.getBlockZ();
    World world = getPosition().getWorld();

    // No free space above
    if (world.getBlockType(new Vector(x, y, z)) != 0) {
        return false;
    }

    while (y <= world.getMaxY()) {
        // Found a ceiling!
        if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            int platformY = Math.max(initialY, y - 3 - clearance);
            floatAt(x, platformY + 1, z, alwaysGlass);
            return true;
        }

        ++y;
    }

    return false;
}
 
Example 4
Source File: AbstractPlayerActor.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean ascendLevel() {
    final WorldVector pos = getBlockIn();
    final int x = pos.getBlockX();
    int y = Math.max(0, pos.getBlockY());
    final int z = pos.getBlockZ();
    final World world = pos.getWorld();

    byte free = 0;
    byte spots = 0;

    while (y <= world.getMaxY() + 2) {
        if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            ++free;
        } else {
            free = 0;
        }

        if (free == 2) {
            ++spots;
            if (spots == 2) {
                final Vector platform = new Vector(x, y - 2, z);
                final BaseBlock block = world.getBlock(platform);
                final int type = block.getId();

                // Don't get put in lava!
                if (type == BlockID.LAVA || type == BlockID.STATIONARY_LAVA) {
                    return false;
                }

                setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
                return true;
            }
        }

        ++y;
    }

    return false;
}
 
Example 5
Source File: AbstractPlayerActor.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
    Vector pos = getBlockIn();
    int x = pos.getBlockX();
    int initialY = Math.max(0, pos.getBlockY());
    int y = Math.max(0, pos.getBlockY() + 2);
    int z = pos.getBlockZ();
    World world = getPosition().getWorld();

    // No free space above
    if (world.getBlockType(new Vector(x, y, z)) != 0) {
        return false;
    }

    while (y <= world.getMaxY()) {
        // Found a ceiling!
        if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            int platformY = Math.max(initialY, y - 3 - clearance);
            floatAt(x, platformY + 1, z, alwaysGlass);
            return true;
        }

        ++y;
    }

    return false;
}
 
Example 6
Source File: NMSMappedFaweQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public NMSMappedFaweQueue(World world) {
    super(world);
    this.maxY = world.getMaxY();
}
 
Example 7
Source File: NMSMappedFaweQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public NMSMappedFaweQueue(World world, IFaweQueueMap map) {
    super(world, map);
    this.maxY = world.getMaxY();
}
 
Example 8
Source File: FastWorldEditExtent.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public FastWorldEditExtent(final World world, FaweQueue queue) {
    super(queue);
    this.world = world;
    this.queue = queue;
    this.maxY = world.getMaxY();
}
 
Example 9
Source File: FaweQueue.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
default int getMaxY() {
    World weWorld = getWEWorld();
    return weWorld == null ? 255 : weWorld.getMaxY();
}