Package com.sk89q.worldedit.blocks

Examples of com.sk89q.worldedit.blocks.BaseBlock


     *
     * @return a pattern that places flora
     */
    public static Pattern getTemperatePattern() {
        RandomPattern pattern = new RandomPattern();
        pattern.add(new BlockPattern(new BaseBlock(BlockID.LONG_GRASS, 1)), 300);
        pattern.add(new BlockPattern(new BaseBlock(BlockID.RED_FLOWER)), 5);
        pattern.add(new BlockPattern(new BaseBlock(BlockID.YELLOW_FLOWER)), 5);
        return pattern;
    }
View Full Code Here


        return pattern;
    }

    @Override
    public boolean apply(Vector position) throws WorldEditException {
        BaseBlock block = editSession.getBlock(position);

        if (block.getType() == BlockID.GRASS) {
            editSession.setBlock(position.add(0, 1, 0), temperatePattern.apply(position));
            return true;
        } else if (block.getType() == BlockID.SAND) {
            editSession.setBlock(position.add(0, 1, 0), desertPattern.apply(position));
            return true;
        }

        return false;
View Full Code Here

            } else {
                break;
            }
        }

        editSession.setBlockIfAir(pos, new BaseBlock(BlockID.LEAVES));
        affected++;

        int t = random.nextInt(4);
        int h = random.nextInt(3) - 1;
        Vector p;

        BaseBlock log = new BaseBlock(BlockID.LOG);

        switch (t) {
            case 0:
                if (random.nextBoolean()) {
                    placeVine(basePos, pos.add(1, 0, 0));
View Full Code Here

        if (editSession.getBlock(position.add(0, -1, 0)).getType() != BlockID.GRASS) {
            return false;
        }

        BaseBlock leavesBlock = new BaseBlock(BlockID.LEAVES);

        editSession.setBlockIfAir(position, leavesBlock);

        placeVine(position, position.add(0, 0, 1));
        placeVine(position, position.add(0, 0, -1));
View Full Code Here

     * @return a pumpkin pattern
     */
    public static Pattern getPumpkinPattern() {
        RandomPattern pattern = new RandomPattern();
        for (int i = 0; i < 4; i++) {
            pattern.add(new BlockPattern(new BaseBlock(BlockID.PUMPKIN, i)), 100);
        }
        return pattern;
    }
View Full Code Here

     * Get a pattern that creates melons.
     *
     * @return a melon pattern
     */
    public static Pattern getMelonPattern() {
        return new BlockPattern(new BaseBlock(BlockID.MELON_BLOCK));
    }
View Full Code Here

        this.treeGenerator = treeGenerator;
    }

    @Override
    public boolean apply(Vector position) throws WorldEditException {
        BaseBlock block = editSession.getBlock(position);
        int t = block.getType();

        if (t == BlockID.GRASS || t == BlockID.DIRT) {
            treeGenerator.generate(editSession, position.add(0, 1, 0));
            return true;
        } else if (t == BlockID.SNOW) {
            editSession.setBlock(position, new BaseBlock(BlockID.AIR));
            return false;
        } else { // Trees won't grow on this!
            return false;
        }
    }
View Full Code Here

            for (int z = 0; z < length; ++z) {
                final Vector2D v = new Vector2D(x, z).transform2D(angle, 0, 0, shiftX, shiftZ);
                final int newX = v.getBlockX();
                final int newZ = v.getBlockZ();
                for (int y = 0; y < height; ++y) {
                    final BaseBlock block = data[x][y][z];
                    newData[newX][y][newZ] = block;

                    if (block == null) {
                        continue;
                    }

                    if (reverse) {
                        for (int i = 0; i < numRotations; ++i) {
                            block.rotate90Reverse();
                        }
                    } else {
                        for (int i = 0; i < numRotations; ++i) {
                            block.rotate90();
                        }
                    }
                }
            }
        }
View Full Code Here

        case WEST_EAST:
            final int wid = (int) Math.ceil(width / 2.0f);
            for (int xs = 0; xs < wid; ++xs) {
                for (int z = 0; z < length; ++z) {
                    for (int y = 0; y < height; ++y) {
                        final BaseBlock block1 = data[xs][y][z];
                        if (block1 != null) {
                            block1.flip(dir);
                        }

                        // Skip the center plane
                        if (xs == width - xs - 1) {
                            continue;
                        }

                        final BaseBlock block2 = data[width - xs - 1][y][z];
                        if (block2 != null) {
                            block2.flip(dir);
                        }

                        data[xs][y][z] = block2;
                        data[width - xs - 1][y][z] = block1;
                    }
                }
            }

            if (aroundPlayer) {
                offset = offset.setX(1 - offset.getX() - width);
            }

            break;

        case NORTH_SOUTH:
            final int len = (int) Math.ceil(length / 2.0f);
            for (int zs = 0; zs < len; ++zs) {
                for (int x = 0; x < width; ++x) {
                    for (int y = 0; y < height; ++y) {
                        final BaseBlock block1 = data[x][y][zs];
                        if (block1 != null) {
                            block1.flip(dir);
                        }

                        // Skip the center plane
                        if (zs == length - zs - 1) {
                            continue;
                        }

                        final BaseBlock block2 = data[x][y][length - zs - 1];
                        if (block2 != null) {
                            block2.flip(dir);
                        }

                        data[x][y][zs] = block2;
                        data[x][y][length - zs - 1] = block1;
                    }
                }
            }

            if (aroundPlayer) {
                offset = offset.setZ(1 - offset.getZ() - length);
            }

            break;

        case UP_DOWN:
            final int hei = (int) Math.ceil(height / 2.0f);
            for (int ys = 0; ys < hei; ++ys) {
                for (int x = 0; x < width; ++x) {
                    for (int z = 0; z < length; ++z) {
                        final BaseBlock block1 = data[x][ys][z];
                        if (block1 != null) {
                            block1.flip(dir);
                        }

                        // Skip the center plane
                        if (ys == height - ys - 1) {
                            continue;
                        }

                        final BaseBlock block2 = data[x][height - ys - 1][z];
                        if (block2 != null) {
                            block2.flip(dir);
                        }

                        data[x][ys][z] = block2;
                        data[x][height - ys - 1][z] = block1;
                    }
View Full Code Here

    }

    @Override
    public boolean setRawTypeId(int x, int y, int z, int typeId) {
        try {
            return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId));
        } catch (MaxChangedBlocksException ex) {
            return false;
        }
    }
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.