Package com.sk89q.worldedit.blocks

Examples of com.sk89q.worldedit.blocks.BaseBlock


        blocks.addAll(blocks);
    }

    @Override
    public boolean matches(EditSession editSession, Vector position) {
        BaseBlock block = editSession.getBlock(position);
        return blocks.contains(block)
                || blocks.contains(new BaseBlock(block.getType(), -1));
    }
View Full Code Here


        return null;
    }

    @Override
    public BaseBlock getBlock(Vector position) {
        return new BaseBlock(0);
    }
View Full Code Here

        return new BaseBlock(0);
    }

    @Override
    public BaseBlock getLazyBlock(Vector position) {
        return new BaseBlock(0);
    }
View Full Code Here

        this.world = world;
    }

    @Override
    public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
        BaseBlock lazyBlock = getExtent().getLazyBlock(position);
        int existing = lazyBlock.getType();

        if (BlockType.isContainerBlock(existing)) {
            world.clearContainerBlockContents(position); // Clear the container block so that it doesn't drop items
        } else if (existing == BlockID.ICE) {
            world.setBlock(position, new BaseBlock(BlockID.AIR)); // Ice turns until water so this has to be done first
        }

        return super.setBlock(position, block);
    }
View Full Code Here

        int originX = minY.getBlockX();
        int originY = minY.getBlockY();
        int originZ = minY.getBlockZ();

        int maxY = region.getMaximumPoint().getBlockY();
        BaseBlock fillerAir = new BaseBlock(BlockID.AIR);

        int blocksChanged = 0;

        // Apply heightmap
        for (int z = 0; z < height; ++z) {
            for (int x = 0; x < width; ++x) {
                int index = z * width + x;
                int curHeight = this.data[index];

                // Clamp newHeight within the selection area
                int newHeight = Math.min(maxY, data[index]);

                // Offset x,z to be 'real' coordinates
                int xr = x + originX;
                int zr = z + originZ;

                // We are keeping the topmost blocks so take that in account for the scale
                double scale = (double) (curHeight - originY) / (double) (newHeight - originY);

                // Depending on growing or shrinking we need to start at the bottom or top
                if (newHeight > curHeight) {
                    // Set the top block of the column to be the same type (this might go wrong with rounding)
                    BaseBlock existing = session.getBlock(new Vector(xr, curHeight, zr));

                    // Skip water/lava
                    if (existing.getType() != BlockID.WATER && existing.getType() != BlockID.STATIONARY_WATER
                            && existing.getType() != BlockID.LAVA && existing.getType() != BlockID.STATIONARY_LAVA) {
                        session.setBlock(new Vector(xr, newHeight, zr), existing);
                        ++blocksChanged;

                        // Grow -- start from 1 below top replacing airblocks
                        for (int y = newHeight - 1 - originY; y >= 0; --y) {
View Full Code Here

        switch (typeId) {
            case ItemID.INK_SACK:
                final Dye materialData = (Dye) itemStack.getData();
                if (materialData.getColor() == DyeColor.BROWN) {
                    return new BaseBlock(BlockID.COCOA_PLANT, -1);
                }
                break;

            case ItemID.HEAD:
                return new SkullBlock(0, (byte) itemStack.getDurability());

            default:
                final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
                if (baseBlock != null) {
                    return baseBlock;
                }
                break;
        }

        if (world.isValidBlockType(typeId)) {
            return new BaseBlock(typeId, -1);
        }

        throw new NotABlockException(typeId);
    }
View Full Code Here

    @Override
    public BaseBlock getBlock(Vector position) {
        if (region.contains(position)) {
            Vector v = position.subtract(region.getMinimumPoint());
            BaseBlock block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
            if (block != null) {
                return new BaseBlock(block);
            }
        }

        return new BaseBlock(BlockID.AIR);
    }
View Full Code Here

    @Override
    public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
        if (region.contains(position)) {
            Vector v = position.subtract(region.getMinimumPoint());
            blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = new BaseBlock(block);
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

        TileEntity tile = getWorld().getTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ());

        if (tile != null) {
            return new TileEntityBaseBlock(id, data, tile);
        } else {
            return new BaseBlock(id, data);
        }
    }
View Full Code Here

        this();
        add(type);
    }

    public void add(int type) {
        add(new BaseBlock(type));
    }
View Full Code Here

TOP

Related Classes of com.sk89q.worldedit.blocks.BaseBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.