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

The following examples show how to use com.sk89q.worldedit.world.World#getBlockType() . 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: SinglePickaxe.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
    World world = (World) clicked.getExtent();
    final int blockType = world.getBlockType(clicked.toVector());
    if (blockType == BlockID.BEDROCK
            && !player.canDestroyBedrock()) {
        return true;
    }

    EditSession editSession = session.createEditSession(player);
    editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);

    try {
        if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) {
            world.playEffect(clicked.toVector(), 2001, blockType);
        }
    } finally {
        editSession.flushQueue();
        session.remember(editSession);
    }

    return true;
}
 
Example 2
Source File: FloodFillTool.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
    World world = (World) clicked.getExtent();

    int initialType = world.getBlockType(clicked.toVector());

    if (initialType == BlockID.AIR) {
        return true;
    }

    if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
        return true;
    }

    EditSession editSession = session.createEditSession(player);

    try {
        recurse(server, editSession, world, clicked.toVector().toBlockVector(),
                clicked.toVector(), range, initialType, new HashSet<BlockVector>());
    } catch (WorldEditException e) {
        throw new RuntimeException(e);
    }
    editSession.flushQueue();
    session.remember(editSession);
    return true;
}
 
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 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;
}