Search in sources :

Example 1 with RandomItemsContent

use of net.glowstone.generator.objects.RandomItemsContent in project Glowstone by GlowstoneMC.

the class GlowDungeon method generate.

@Override
public boolean generate(World world, Random random, StructureBoundingBox genBoundingBox, BlockStateDelegate delegate) {
    if (!super.generate(world, random, boundingBox, delegate)) {
        return false;
    }
    boundingBox.offset(new Vector(-radiusX, -1, -radiusZ));
    StructureBuilder builder = new StructureBuilder(world, this, genBoundingBox, delegate);
    if (!canPlace(builder)) {
        return false;
    }
    Map<StructureMaterial, Integer> stones = new HashMap<>();
    builder.addRandomMaterial(stones, 1, Material.COBBLESTONE, 0);
    builder.addRandomMaterial(stones, 3, Material.MOSSY_COBBLESTONE, 0);
    for (int x = 0; x < sizeX; x++) {
        for (int z = 0; z < sizeZ; z++) {
            for (int y = HEIGHT - 1; y >= 0; y--) {
                BlockState state = builder.getBlockState(new Vector(x, y, z));
                if (y > 0 && x > 0 && z > 0 && x < sizeX - 1 && y < HEIGHT - 1 && z < sizeZ - 1) {
                    // empty space inside
                    builder.setBlock(new Vector(x, y, z), Material.AIR);
                } else if (!builder.getBlockState(new Vector(x, y - 1, z)).getType().isSolid()) {
                    // cleaning walls from non solid materials (because of air gaps below)
                    builder.setBlock(new Vector(x, y, z), Material.AIR);
                } else if (state.getType().isSolid()) {
                    // preserve the air gaps
                    if (y == 0) {
                        builder.setBlockWithRandomMaterial(new Vector(x, y, z), random, stones);
                    } else {
                        builder.setBlock(new Vector(x, y, z), Material.COBBLESTONE);
                    }
                }
            }
        }
    }
    RandomItemsContent chestContent = new RandomItemsContent();
    chestContent.addItem(new RandomAmountItem(Material.SADDLE, 1, 1), 10);
    chestContent.addItem(new RandomAmountItem(Material.IRON_INGOT, 1, 4), 10);
    chestContent.addItem(new RandomAmountItem(Material.BREAD, 1, 1), 10);
    chestContent.addItem(new RandomAmountItem(Material.WHEAT, 1, 4), 10);
    chestContent.addItem(new RandomAmountItem(Material.GUNPOWDER, 1, 4), 10);
    chestContent.addItem(new RandomAmountItem(Material.STRING, 1, 4), 10);
    chestContent.addItem(new RandomAmountItem(Material.BUCKET, 1, 1), 10);
    chestContent.addItem(new RandomAmountItem(Material.GOLDEN_APPLE, 1, 1), 1);
    chestContent.addItem(new RandomAmountItem(Material.REDSTONE, 1, 4), 10);
    chestContent.addItem(new RandomAmountItem(Material.MUSIC_DISC_13, 1, 1), 4);
    chestContent.addItem(new RandomAmountItem(Material.MUSIC_DISC_CAT, 1, 1), 4);
    chestContent.addItem(new RandomAmountItem(Material.NAME_TAG, 1, 1), 10);
    chestContent.addItem(new RandomAmountItem(Material.GOLDEN_HORSE_ARMOR, 1, 1), 2);
    chestContent.addItem(new RandomAmountItem(Material.IRON_HORSE_ARMOR, 1, 1), 5);
    chestContent.addItem(new RandomAmountItem(Material.DIAMOND_HORSE_ARMOR, 1, 1), 1);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 3; j++) {
            int x = random.nextInt((radiusX << 1) - 1) + 1;
            int z = random.nextInt((radiusZ << 1) - 1) + 1;
            if (builder.getBlockState(new Vector(x, 1, z)).getType() == Material.AIR) {
                BlockFace face = null;
                int solidBlocksCount = 0;
                if (builder.getBlockState(new Vector(x - 1, 1, z)).getType() == Material.COBBLESTONE) {
                    solidBlocksCount++;
                    face = BlockFace.EAST;
                }
                if (builder.getBlockState(new Vector(x + 1, 1, z)).getType() == Material.COBBLESTONE) {
                    solidBlocksCount++;
                    face = BlockFace.WEST;
                }
                if (builder.getBlockState(new Vector(x, 1, z - 1)).getType() == Material.COBBLESTONE) {
                    solidBlocksCount++;
                    face = BlockFace.SOUTH;
                }
                if (builder.getBlockState(new Vector(x, 1, z + 1)).getType() == Material.COBBLESTONE) {
                    solidBlocksCount++;
                    face = BlockFace.NORTH;
                }
                if (solidBlocksCount == 1) {
                    builder.createRandomItemsContainer(new Vector(x, 1, z), random, chestContent, new Chest(face), 8);
                    break;
                }
            }
        }
    }
    builder.createMobSpawner(new Vector(radiusX, 1, radiusZ), mobTypes[random.nextInt(mobTypes.length)]);
    GlowServer.logger.finer("dungeon generated: " + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ());
    return true;
}
Also used : Chest(org.bukkit.material.Chest) BlockState(org.bukkit.block.BlockState) RandomAmountItem(net.glowstone.generator.objects.RandomItemsContent.RandomAmountItem) HashMap(java.util.HashMap) StructureBuilder(net.glowstone.generator.structures.util.StructureBuilder) BlockFace(org.bukkit.block.BlockFace) RandomItemsContent(net.glowstone.generator.objects.RandomItemsContent) StructureMaterial(net.glowstone.generator.structures.util.StructureBuilder.StructureMaterial) Vector(org.bukkit.util.Vector)

Example 2 with RandomItemsContent

use of net.glowstone.generator.objects.RandomItemsContent in project Glowstone by GlowstoneMC.

the class GlowTemplePiece method getChestContent.

protected RandomItemsContent getChestContent() {
    RandomItemsContent chestContent = new RandomItemsContent();
    chestContent.addItem(new RandomAmountItem(Material.DIAMOND, 1, 3), 3);
    chestContent.addItem(new RandomAmountItem(Material.IRON_INGOT, 1, 5), 10);
    chestContent.addItem(new RandomAmountItem(Material.GOLD_INGOT, 2, 7), 15);
    chestContent.addItem(new RandomAmountItem(Material.EMERALD, 1, 3), 2);
    chestContent.addItem(new RandomAmountItem(Material.BONE, 4, 6), 20);
    chestContent.addItem(new RandomAmountItem(Material.ROTTEN_FLESH, 3, 7), 16);
    chestContent.addItem(new RandomAmountItem(Material.SADDLE, 1, 1), 3);
    chestContent.addItem(new RandomAmountItem(Material.IRON_HORSE_ARMOR, 1, 1), 1);
    chestContent.addItem(new RandomAmountItem(Material.GOLDEN_HORSE_ARMOR, 1, 1), 1);
    chestContent.addItem(new RandomAmountItem(Material.DIAMOND_HORSE_ARMOR, 1, 1), 1);
    return chestContent;
}
Also used : RandomAmountItem(net.glowstone.generator.objects.RandomItemsContent.RandomAmountItem) RandomItemsContent(net.glowstone.generator.objects.RandomItemsContent)

Example 3 with RandomItemsContent

use of net.glowstone.generator.objects.RandomItemsContent in project Glowstone by GlowstoneMC.

the class GlowJungleTemple method generate.

@Override
public boolean generate(World world, Random random, StructureBoundingBox genBoundingBox, BlockStateDelegate delegate) {
    if (!super.generate(world, random, boundingBox, delegate)) {
        return false;
    }
    adjustHorizPos(world);
    boundingBox.offset(new Vector(0, -4, 0));
    StructureBuilder builder = new StructureBuilder(world, this, genBoundingBox, delegate);
    Map<StructureMaterial, Integer> stones = new HashMap<>();
    builder.addRandomMaterial(stones, 4, Material.COBBLESTONE, 0);
    builder.addRandomMaterial(stones, 6, Material.MOSSY_COBBLESTONE, 0);
    RandomItemsContent chestContent = getChestContent();
    RandomItemsContent dispenserContent = new RandomItemsContent();
    dispenserContent.addItem(new RandomAmountItem(Material.ARROW, 2, 7), 30);
    // 1st floor
    builder.fillWithRandomMaterial(new Vector(0, 0, 0), new Vector(11, 0, 14), random, stones);
    builder.fillWithRandomMaterial(new Vector(0, 1, 0), new Vector(11, 3, 0), random, stones);
    builder.fillWithRandomMaterial(new Vector(11, 1, 1), new Vector(11, 3, 13), random, stones);
    builder.fillWithRandomMaterial(new Vector(0, 1, 1), new Vector(0, 3, 13), random, stones);
    builder.fillWithRandomMaterial(new Vector(0, 1, 14), new Vector(11, 3, 14), random, stones);
    builder.fillWithRandomMaterial(new Vector(0, 4, 0), new Vector(11, 4, 14), random, stones);
    Stairs entranceStairs = new Stairs(Material.COBBLESTONE_STAIRS);
    entranceStairs.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
    builder.fill(new Vector(4, 4, 0), new Vector(7, 4, 0), entranceStairs.getItemType(), entranceStairs);
    builder.fill(new Vector(1, 1, 1), new Vector(10, 3, 13), Material.AIR);
    builder.fill(new Vector(5, 4, 7), new Vector(6, 4, 9), Material.AIR);
    // 2nd floor
    builder.fillWithRandomMaterial(new Vector(2, 5, 2), new Vector(9, 6, 2), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 5, 3), new Vector(9, 6, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(2, 5, 12), new Vector(9, 6, 12), random, stones);
    builder.fillWithRandomMaterial(new Vector(2, 5, 3), new Vector(2, 6, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(1, 7, 1), new Vector(10, 7, 13), random, stones);
    builder.fill(new Vector(3, 5, 3), new Vector(8, 6, 11), Material.AIR);
    builder.fill(new Vector(4, 7, 6), new Vector(7, 7, 9), Material.AIR);
    builder.fill(new Vector(5, 5, 2), new Vector(6, 6, 2), Material.AIR);
    builder.fill(new Vector(5, 6, 12), new Vector(6, 6, 12), Material.AIR);
    // 3rd floor
    builder.fillWithRandomMaterial(new Vector(1, 8, 1), new Vector(10, 9, 1), random, stones);
    builder.fillWithRandomMaterial(new Vector(10, 8, 2), new Vector(10, 9, 12), random, stones);
    builder.fillWithRandomMaterial(new Vector(1, 8, 13), new Vector(10, 9, 13), random, stones);
    builder.fillWithRandomMaterial(new Vector(1, 8, 2), new Vector(1, 9, 12), random, stones);
    builder.fill(new Vector(2, 8, 2), new Vector(9, 9, 12), Material.AIR);
    builder.fill(new Vector(5, 9, 1), new Vector(6, 9, 1), Material.AIR);
    builder.fill(new Vector(5, 9, 13), new Vector(6, 9, 13), Material.AIR);
    builder.setBlock(new Vector(10, 9, 5), Material.AIR);
    builder.setBlock(new Vector(10, 9, 9), Material.AIR);
    builder.setBlock(new Vector(1, 9, 5), Material.AIR);
    builder.setBlock(new Vector(1, 9, 9), Material.AIR);
    // roof
    builder.fillWithRandomMaterial(new Vector(1, 10, 1), new Vector(10, 10, 4), random, stones);
    builder.fillWithRandomMaterial(new Vector(8, 10, 5), new Vector(10, 10, 9), random, stones);
    builder.fillWithRandomMaterial(new Vector(1, 10, 5), new Vector(3, 10, 9), random, stones);
    builder.fillWithRandomMaterial(new Vector(1, 10, 10), new Vector(10, 10, 13), random, stones);
    builder.fillWithRandomMaterial(new Vector(3, 11, 3), new Vector(8, 11, 5), random, stones);
    builder.fillWithRandomMaterial(new Vector(7, 11, 6), new Vector(8, 11, 8), random, stones);
    builder.fillWithRandomMaterial(new Vector(3, 11, 6), new Vector(4, 11, 8), random, stones);
    builder.fillWithRandomMaterial(new Vector(3, 11, 9), new Vector(8, 11, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(4, 12, 4), new Vector(7, 12, 10), random, stones);
    builder.fill(new Vector(4, 10, 5), new Vector(7, 10, 9), Material.AIR);
    builder.fill(new Vector(5, 11, 6), new Vector(6, 11, 8), Material.AIR);
    // outside walls decorations
    builder.fillWithRandomMaterial(new Vector(2, 8, 0), new Vector(2, 9, 0), random, stones);
    builder.fillWithRandomMaterial(new Vector(4, 8, 0), new Vector(4, 9, 0), random, stones);
    builder.fillWithRandomMaterial(new Vector(7, 8, 0), new Vector(7, 9, 0), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 8, 0), new Vector(9, 9, 0), random, stones);
    builder.fillWithRandomMaterial(new Vector(5, 10, 0), new Vector(6, 10, 0), random, stones);
    for (int i = 0; i < 6; i++) {
        builder.fillWithRandomMaterial(new Vector(11, 8, 2 + (i << 1)), new Vector(11, 9, 2 + (i << 1)), random, stones);
        builder.fillWithRandomMaterial(new Vector(0, 8, 2 + (i << 1)), new Vector(0, 9, 2 + (i << 1)), random, stones);
    }
    builder.setBlockWithRandomMaterial(new Vector(11, 10, 5), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(11, 10, 9), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(0, 10, 5), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(0, 10, 9), random, stones);
    builder.fillWithRandomMaterial(new Vector(2, 8, 14), new Vector(2, 9, 14), random, stones);
    builder.fillWithRandomMaterial(new Vector(4, 8, 14), new Vector(4, 9, 14), random, stones);
    builder.fillWithRandomMaterial(new Vector(7, 8, 14), new Vector(7, 9, 14), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 8, 14), new Vector(9, 9, 14), random, stones);
    // roof decorations
    builder.fillWithRandomMaterial(new Vector(2, 11, 2), new Vector(2, 13, 2), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 11, 2), new Vector(9, 13, 2), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 11, 12), new Vector(9, 13, 12), random, stones);
    builder.fillWithRandomMaterial(new Vector(2, 11, 12), new Vector(2, 13, 12), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(4, 13, 4), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(7, 13, 4), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(7, 13, 10), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(4, 13, 10), random, stones);
    Stairs roofStairsN = new Stairs(Material.COBBLESTONE_STAIRS);
    roofStairsN.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
    builder.fill(new Vector(5, 13, 6), new Vector(6, 13, 6), roofStairsN.getItemType(), roofStairsN);
    builder.fillWithRandomMaterial(new Vector(5, 13, 7), new Vector(6, 13, 7), random, stones);
    Stairs roofStairsS = new Stairs(Material.COBBLESTONE_STAIRS);
    roofStairsS.setFacingDirection(getRelativeFacing(BlockFace.NORTH));
    builder.fill(new Vector(5, 13, 8), new Vector(6, 13, 8), roofStairsS.getItemType(), roofStairsS);
    // 1st floor inside
    for (int i = 0; i < 6; i++) {
        builder.fillWithRandomMaterial(new Vector(1, 3, 2 + (i << 1)), new Vector(3, 3, 2 + (i << 1)), random, stones);
    }
    for (int i = 0; i < 7; i++) {
        builder.fillWithRandomMaterial(new Vector(1, 1, 1 + (i << 1)), new Vector(1, 2, 1 + (i << 1)), random, stones);
    }
    builder.setBlockWithRandomMaterial(new Vector(2, 2, 1), random, stones);
    builder.setBlock(new Vector(3, 1, 1), Material.MOSSY_COBBLESTONE);
    builder.fillWithRandomMaterial(new Vector(4, 2, 1), new Vector(5, 2, 1), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(6, 1, 1), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(6, 3, 1), random, stones);
    builder.fillWithRandomMaterial(new Vector(7, 2, 1), new Vector(9, 2, 1), random, stones);
    builder.setBlock(new Vector(8, 1, 1), Material.MOSSY_COBBLESTONE);
    builder.fillWithRandomMaterial(new Vector(10, 1, 1), new Vector(10, 3, 7), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 3, 1), new Vector(9, 3, 7), random, stones);
    builder.setBlock(new Vector(9, 1, 2), Material.MOSSY_COBBLESTONE);
    builder.setBlock(new Vector(9, 1, 4), Material.MOSSY_COBBLESTONE);
    builder.setBlock(new Vector(8, 1, 5), Material.MOSSY_COBBLESTONE);
    builder.fill(new Vector(7, 2, 5), new Vector(7, 3, 5), Material.MOSSY_COBBLESTONE);
    builder.setBlock(new Vector(6, 1, 5), Material.MOSSY_COBBLESTONE);
    builder.setBlockWithRandomMaterial(new Vector(6, 2, 5), random, stones);
    builder.fill(new Vector(5, 2, 5), new Vector(5, 3, 5), Material.MOSSY_COBBLESTONE);
    builder.setBlock(new Vector(4, 1, 5), Material.MOSSY_COBBLESTONE);
    builder.fillWithRandomMaterial(new Vector(7, 1, 6), new Vector(7, 3, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(4, 1, 6), new Vector(4, 3, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(5, 3, 11), new Vector(6, 3, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(8, 3, 11), new Vector(10, 3, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(8, 1, 11), new Vector(10, 1, 11), random, stones);
    builder.fillWithRandomMaterial(new Vector(5, 1, 8), new Vector(6, 1, 8), random, stones);
    builder.fillWithRandomMaterial(new Vector(6, 1, 7), new Vector(6, 2, 7), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(5, 2, 7), random, stones);
    builder.fillWithRandomMaterial(new Vector(6, 1, 6), new Vector(6, 3, 6), random, stones);
    builder.fillWithRandomMaterial(new Vector(5, 2, 6), new Vector(5, 3, 6), random, stones);
    builder.fillWithRandomMaterial(new Vector(8, 2, 6), new Vector(9, 2, 6), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(8, 3, 6), random, stones);
    builder.fillWithRandomMaterial(new Vector(9, 1, 7), new Vector(9, 2, 7), random, stones);
    builder.fillWithRandomMaterial(new Vector(8, 1, 7), new Vector(8, 3, 7), random, stones);
    builder.fillWithRandomMaterial(new Vector(10, 1, 8), new Vector(10, 1, 10), random, stones);
    builder.setBlock(new Vector(10, 2, 9), Material.MOSSY_COBBLESTONE);
    builder.fillWithRandomMaterial(new Vector(8, 1, 8), new Vector(8, 1, 10), random, stones);
    builder.fill(new Vector(8, 2, 11), new Vector(10, 2, 11), Material.CHISELED_STONE_BRICKS);
    Lever lever = new Lever(Material.LEVER, // workaround for bukkit, can't set an attached BlockFace
    (byte) 4);
    lever.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
    builder.fill(new Vector(8, 2, 12), new Vector(10, 2, 12), lever.getItemType(), lever);
    if (!placedTrap1) {
        placedTrap1 = builder.createRandomItemsContainer(new Vector(3, 2, 1), random, dispenserContent, new Dispenser(getRelativeFacing(BlockFace.SOUTH)), 2);
    }
    if (!placedTrap2) {
        placedTrap2 = builder.createRandomItemsContainer(new Vector(9, 2, 3), random, dispenserContent, new Dispenser(getRelativeFacing(BlockFace.WEST)), 2);
    }
    Vine vine = new Vine(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
    builder.setBlock(new Vector(3, 2, 2), vine.getItemType(), vine);
    builder.fill(new Vector(8, 2, 3), new Vector(8, 3, 3), vine.getItemType(), vine);
    builder.fill(new Vector(2, 1, 8), new Vector(3, 1, 8), Material.TRIPWIRE);
    TripwireHook hookE = new TripwireHook(getRelativeFacing(BlockFace.WEST));
    hookE.setConnected(true);
    builder.setBlock(new Vector(4, 1, 8), hookE.getItemType(), hookE);
    TripwireHook hookW = new TripwireHook(getRelativeFacing(BlockFace.EAST));
    hookW.setConnected(true);
    builder.setBlock(new Vector(1, 1, 8), hookW.getItemType(), hookW);
    builder.fill(new Vector(5, 1, 1), new Vector(5, 1, 7), Material.REDSTONE_WIRE);
    builder.setBlock(new Vector(4, 1, 1), Material.REDSTONE_WIRE);
    builder.fill(new Vector(7, 1, 2), new Vector(7, 1, 4), Material.TRIPWIRE);
    TripwireHook hookN = new TripwireHook(getRelativeFacing(BlockFace.SOUTH));
    hookN.setConnected(true);
    builder.setBlock(new Vector(7, 1, 1), hookN.getItemType(), hookN);
    TripwireHook hookS = new TripwireHook(getRelativeFacing(BlockFace.NORTH));
    hookS.setConnected(true);
    builder.setBlock(new Vector(7, 1, 5), hookS.getItemType(), hookS);
    builder.fill(new Vector(8, 1, 6), new Vector(9, 1, 6), Material.REDSTONE_WIRE);
    builder.setBlock(new Vector(9, 1, 5), Material.REDSTONE_WIRE);
    builder.setBlock(new Vector(9, 2, 4), Material.REDSTONE_WIRE);
    PistonBaseMaterial pistonE = new PistonBaseMaterial(Material.PISTON);
    pistonE.setFacingDirection(getRelativeFacing(BlockFace.WEST));
    builder.fill(new Vector(10, 2, 8), new Vector(10, 3, 8), pistonE.getItemType(), pistonE);
    // TODO: 1.13 is this the right piston material??
    PistonBaseMaterial pistonUp = new PistonBaseMaterial(Material.STICKY_PISTON);
    pistonUp.setFacingDirection(BlockFace.UP);
    builder.setBlock(new Vector(9, 2, 8), pistonUp.getItemType(), pistonUp);
    builder.setBlock(new Vector(10, 3, 9), Material.REDSTONE_WIRE);
    builder.fill(new Vector(8, 2, 9), new Vector(8, 2, 10), Material.REDSTONE_WIRE);
    Diode repeater = new Diode(Material.REPEATER);
    repeater.setDelay(1);
    repeater.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
    builder.setBlock(new Vector(10, 2, 10), repeater.getItemType(), repeater);
    if (!placedMainChest) {
        placedMainChest = builder.createRandomItemsContainer(new Vector(8, 1, 3), random, chestContent, new Chest(getRelativeFacing(BlockFace.WEST)), random.nextInt(5) + 2);
    }
    if (!placedHiddenChest) {
        placedHiddenChest = builder.createRandomItemsContainer(new Vector(9, 1, 10), random, chestContent, new Chest(getRelativeFacing(BlockFace.NORTH)), random.nextInt(5) + 2);
    }
    // 2nd floor inside
    for (int i = 0; i < 4; i++) {
        Stairs stairsS = new Stairs(Material.COBBLESTONE_STAIRS);
        stairsS.setFacingDirection(getRelativeFacing(BlockFace.NORTH));
        builder.fill(new Vector(5, 4 - i, 6 + i), new Vector(6, 4 - i, 6 + i), stairsS.getItemType(), stairsS);
    }
    builder.fillWithRandomMaterial(new Vector(4, 5, 10), new Vector(7, 6, 10), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(4, 5, 9), random, stones);
    builder.setBlockWithRandomMaterial(new Vector(7, 5, 9), random, stones);
    for (int i = 0; i < 3; i++) {
        Stairs leftStairs = new Stairs(Material.COBBLESTONE_STAIRS);
        leftStairs.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
        builder.setBlock(new Vector(7, 5 + i, 8 + i), leftStairs.getItemType(), leftStairs);
        Stairs rightStairs = new Stairs(Material.COBBLESTONE_STAIRS);
        rightStairs.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
        builder.setBlock(new Vector(4, 5 + i, 8 + i), rightStairs.getItemType(), rightStairs);
    }
    // 3rd floor inside
    builder.fillWithRandomMaterial(new Vector(5, 8, 5), new Vector(6, 8, 5), random, stones);
    Stairs stairsE = new Stairs(Material.COBBLESTONE_STAIRS);
    stairsE.setFacingDirection(getRelativeFacing(BlockFace.WEST));
    builder.setBlock(new Vector(7, 8, 5), stairsE.getItemType(), stairsE);
    Stairs stairsW = new Stairs(Material.COBBLESTONE_STAIRS);
    stairsW.setFacingDirection(getRelativeFacing(BlockFace.EAST));
    builder.setBlock(new Vector(4, 8, 5), stairsW.getItemType(), stairsW);
    return true;
}
Also used : Chest(org.bukkit.material.Chest) Dispenser(org.bukkit.material.Dispenser) Vine(org.bukkit.material.Vine) Diode(org.bukkit.material.Diode) HashMap(java.util.HashMap) StructureBuilder(net.glowstone.generator.structures.util.StructureBuilder) StructureMaterial(net.glowstone.generator.structures.util.StructureBuilder.StructureMaterial) TripwireHook(org.bukkit.material.TripwireHook) RandomAmountItem(net.glowstone.generator.objects.RandomItemsContent.RandomAmountItem) Lever(org.bukkit.material.Lever) RandomItemsContent(net.glowstone.generator.objects.RandomItemsContent) Stairs(org.bukkit.material.Stairs) Vector(org.bukkit.util.Vector) PistonBaseMaterial(org.bukkit.material.PistonBaseMaterial)

Example 4 with RandomItemsContent

use of net.glowstone.generator.objects.RandomItemsContent in project Glowstone by GlowstoneMC.

the class GlowDesertTemple method generate.

@Override
public boolean generate(World world, Random random, StructureBoundingBox genBoundingBox, BlockStateDelegate delegate) {
    if (!super.generate(world, random, boundingBox, delegate)) {
        return false;
    }
    StructureBuilder builder = new StructureBuilder(world, this, genBoundingBox, delegate);
    for (int x = 0; x < 21; x++) {
        for (int z = 0; z < 21; z++) {
            builder.setBlockDownward(new Vector(x, 13, z), Material.SANDSTONE);
        }
    }
    builder.fill(new Vector(0, 14, 0), new Vector(20, 18, 20), Material.SANDSTONE);
    for (int i = 1; i <= 9; i++) {
        builder.fill(new Vector(i, i + 18, i), new Vector(20 - i, i + 18, 20 - i), Material.SANDSTONE);
        builder.fill(new Vector(i + 1, i + 18, i + 1), new Vector(19 - i, i + 18, 19 - i), Material.AIR);
    }
    // east tower
    builder.fill(new Vector(0, 18, 0), new Vector(4, 27, 4), Material.SANDSTONE, Material.AIR);
    builder.fill(new Vector(1, 28, 1), new Vector(3, 28, 3), Material.SANDSTONE);
    Stairs stairsN = new Stairs(Material.SANDSTONE_STAIRS);
    stairsN.setFacingDirection(getRelativeFacing(BlockFace.SOUTH));
    builder.setBlock(new Vector(2, 28, 0), stairsN.getItemType(), stairsN);
    Stairs stairsE = new Stairs(Material.SANDSTONE_STAIRS);
    stairsE.setFacingDirection(getRelativeFacing(BlockFace.WEST));
    builder.setBlock(new Vector(4, 28, 2), stairsE.getItemType(), stairsE);
    Stairs stairsS = new Stairs(Material.SANDSTONE_STAIRS);
    stairsS.setFacingDirection(getRelativeFacing(BlockFace.NORTH));
    builder.setBlock(new Vector(2, 28, 4), stairsS.getItemType(), stairsS);
    Stairs stairsW = new Stairs(Material.SANDSTONE_STAIRS);
    stairsW.setFacingDirection(getRelativeFacing(BlockFace.EAST));
    builder.setBlock(new Vector(0, 28, 2), stairsW.getItemType(), stairsW);
    builder.fill(new Vector(1, 19, 5), new Vector(3, 22, 11), Material.SANDSTONE);
    builder.fill(new Vector(2, 22, 4), new Vector(2, 24, 4), Material.AIR);
    builder.fill(new Vector(1, 19, 3), new Vector(2, 20, 3), Material.SANDSTONE);
    builder.setBlock(new Vector(1, 19, 2), Material.SANDSTONE);
    Step step = new Step(Material.SANDSTONE);
    builder.setBlock(new Vector(1, 20, 2), step.getItemType(), step);
    builder.setBlock(new Vector(2, 19, 2), stairsE.getItemType(), stairsE);
    for (int i = 0; i < 2; i++) {
        builder.setBlock(new Vector(2, 21 + i, 4 + i), stairsN.getItemType(), stairsN);
    }
    // west tower
    builder.fill(new Vector(16, 18, 0), new Vector(20, 27, 4), Material.SANDSTONE, Material.AIR);
    builder.fill(new Vector(17, 28, 1), new Vector(19, 28, 3), Material.SANDSTONE);
    builder.setBlock(new Vector(18, 28, 0), stairsN.getItemType(), stairsN);
    builder.setBlock(new Vector(20, 28, 2), stairsE.getItemType(), stairsE);
    builder.setBlock(new Vector(18, 28, 4), stairsS.getItemType(), stairsS);
    builder.setBlock(new Vector(16, 28, 2), stairsW.getItemType(), stairsW);
    builder.fill(new Vector(17, 19, 5), new Vector(19, 22, 11), Material.SANDSTONE);
    builder.fill(new Vector(18, 22, 4), new Vector(18, 24, 4), Material.AIR);
    builder.fill(new Vector(18, 19, 3), new Vector(19, 20, 3), Material.SANDSTONE);
    builder.setBlock(new Vector(19, 19, 2), Material.SANDSTONE);
    builder.setBlock(new Vector(19, 20, 2), step.getItemType(), step);
    builder.setBlock(new Vector(18, 19, 2), stairsW.getItemType(), stairsW);
    for (int i = 0; i < 2; i++) {
        builder.setBlock(new Vector(18, 21 + i, 4 + i), stairsN.getItemType(), stairsN);
    }
    // tower symbols
    for (int i = 0; i < 2; i++) {
        // front
        builder.fill(new Vector(1 + (i << 4), 20, 0), new Vector(1 + (i << 4), 21, 0), Material.SANDSTONE, 2);
        builder.fill(new Vector(2 + (i << 4), 20, 0), new Vector(2 + (i << 4), 21, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.fill(new Vector(3 + (i << 4), 20, 0), new Vector(3 + (i << 4), 21, 0), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(1 + (i << 4), 22, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(2 + (i << 4), 22, 0), Material.SANDSTONE, 1);
        builder.setBlock(new Vector(3 + (i << 4), 22, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(1 + (i << 4), 23, 0), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(2 + (i << 4), 23, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(3 + (i << 4), 23, 0), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(1 + (i << 4), 24, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(2 + (i << 4), 24, 0), Material.SANDSTONE, 1);
        builder.setBlock(new Vector(3 + (i << 4), 24, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.fill(new Vector(1 + (i << 4), 25, 0), new Vector(3 + (i << 4), 25, 0), Material.ORANGE_TERRACOTTA, 1);
        builder.fill(new Vector(1 + (i << 4), 26, 0), new Vector(3 + (i << 4), 26, 0), Material.SANDSTONE, 2);
        // side
        builder.fill(new Vector(i * 20, 20, 1), new Vector(i * 20, 21, 1), Material.SANDSTONE, 2);
        builder.fill(new Vector(i * 20, 20, 2), new Vector(i * 20, 21, 2), Material.ORANGE_TERRACOTTA, 1);
        builder.fill(new Vector(i * 20, 20, 3), new Vector(i * 20, 21, 3), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(i * 20, 22, 1), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(i * 20, 22, 2), Material.SANDSTONE, 1);
        builder.setBlock(new Vector(i * 20, 22, 3), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(i * 20, 23, 1), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(i * 20, 23, 2), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(i * 20, 23, 3), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(i * 20, 24, 1), Material.ORANGE_TERRACOTTA, 1);
        builder.setBlock(new Vector(i * 20, 24, 2), Material.SANDSTONE, 1);
        builder.setBlock(new Vector(i * 20, 24, 3), Material.ORANGE_TERRACOTTA, 1);
        builder.fill(new Vector(i * 20, 25, 1), new Vector(i * 20, 25, 3), Material.ORANGE_TERRACOTTA, 1);
        builder.fill(new Vector(i * 20, 26, 1), new Vector(i * 20, 26, 3), Material.SANDSTONE, 2);
    }
    // front entrance
    builder.fill(new Vector(8, 18, 1), new Vector(12, 22, 4), Material.SANDSTONE, Material.AIR);
    builder.fill(new Vector(9, 19, 0), new Vector(11, 21, 4), Material.AIR);
    builder.fill(new Vector(9, 19, 1), new Vector(9, 20, 1), Material.SANDSTONE, 2);
    builder.fill(new Vector(11, 19, 1), new Vector(11, 20, 1), Material.SANDSTONE, 2);
    builder.fill(new Vector(9, 21, 1), new Vector(11, 21, 1), Material.SANDSTONE, 2);
    builder.fill(new Vector(8, 18, 0), new Vector(8, 21, 0), Material.SANDSTONE);
    builder.fill(new Vector(12, 18, 0), new Vector(12, 21, 0), Material.SANDSTONE);
    builder.fill(new Vector(8, 22, 0), new Vector(12, 22, 0), Material.SANDSTONE, 2);
    builder.setBlock(new Vector(8, 23, 0), Material.SANDSTONE, 2);
    builder.setBlock(new Vector(9, 23, 0), Material.ORANGE_TERRACOTTA, 1);
    builder.setBlock(new Vector(10, 23, 0), Material.SANDSTONE, 1);
    builder.setBlock(new Vector(11, 23, 0), Material.ORANGE_TERRACOTTA, 1);
    builder.setBlock(new Vector(12, 23, 0), Material.SANDSTONE, 2);
    builder.fill(new Vector(9, 24, 0), new Vector(11, 24, 0), Material.SANDSTONE, 2);
    // east entrance
    builder.fill(new Vector(5, 23, 9), new Vector(5, 25, 11), Material.SANDSTONE, 2);
    builder.fill(new Vector(6, 25, 9), new Vector(6, 25, 11), Material.SANDSTONE);
    builder.fill(new Vector(5, 23, 10), new Vector(6, 24, 10), Material.AIR);
    // west entrance
    builder.fill(new Vector(15, 23, 9), new Vector(15, 25, 11), Material.SANDSTONE, 2);
    builder.fill(new Vector(14, 25, 9), new Vector(14, 25, 11), Material.SANDSTONE);
    builder.fill(new Vector(14, 23, 10), new Vector(15, 24, 10), Material.AIR);
    // corridor to east tower
    builder.fill(new Vector(4, 19, 1), new Vector(8, 21, 3), Material.SANDSTONE, Material.AIR);
    builder.fill(new Vector(4, 19, 2), new Vector(8, 20, 2), Material.AIR);
    // corridor to west tower
    builder.fill(new Vector(12, 19, 1), new Vector(16, 21, 3), Material.SANDSTONE, Material.AIR);
    builder.fill(new Vector(12, 19, 2), new Vector(16, 20, 2), Material.AIR);
    // pillars in the middle of 1st floor
    builder.fill(new Vector(8, 19, 8), new Vector(8, 21, 8), Material.SANDSTONE, 2);
    builder.fill(new Vector(12, 19, 8), new Vector(12, 21, 8), Material.SANDSTONE, 2);
    builder.fill(new Vector(12, 19, 12), new Vector(12, 21, 12), Material.SANDSTONE, 2);
    builder.fill(new Vector(8, 19, 12), new Vector(8, 21, 12), Material.SANDSTONE, 2);
    // 2nd floor
    builder.fill(new Vector(5, 22, 5), new Vector(15, 22, 15), Material.SANDSTONE);
    builder.fill(new Vector(9, 22, 9), new Vector(11, 22, 11), Material.AIR);
    // east and west corridors
    builder.fill(new Vector(3, 19, 5), new Vector(3, 20, 11), Material.AIR);
    builder.fill(new Vector(4, 21, 5), new Vector(4, 21, 16), Material.SANDSTONE);
    builder.fill(new Vector(17, 19, 5), new Vector(17, 20, 11), Material.AIR);
    builder.fill(new Vector(16, 21, 5), new Vector(16, 21, 16), Material.SANDSTONE);
    builder.fill(new Vector(2, 19, 12), new Vector(2, 19, 18), Material.SANDSTONE);
    builder.fill(new Vector(18, 19, 12), new Vector(18, 19, 18), Material.SANDSTONE);
    builder.fill(new Vector(3, 19, 18), new Vector(18, 19, 18), Material.SANDSTONE);
    for (int i = 0; i < 7; i++) {
        builder.setBlock(new Vector(4, 19, 5 + (i << 1)), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(4, 20, 5 + (i << 1)), Material.SANDSTONE, 1);
        builder.setBlock(new Vector(16, 19, 5 + (i << 1)), Material.SANDSTONE, 2);
        builder.setBlock(new Vector(16, 20, 5 + (i << 1)), Material.SANDSTONE, 1);
    }
    // floor symbols
    builder.setBlock(new Vector(9, 18, 9), Material.ORANGE_TERRACOTTA, 1);
    builder.setBlock(new Vector(11, 18, 9), Material.ORANGE_TERRACOTTA, 1);
    builder.setBlock(new Vector(11, 18, 11), Material.ORANGE_TERRACOTTA, 1);
    builder.setBlock(new Vector(9, 18, 11), Material.ORANGE_TERRACOTTA, 1);
    builder.setBlock(new Vector(10, 18, 10), Material.BLUE_TERRACOTTA, 11);
    builder.fill(new Vector(10, 18, 7), new Vector(10, 18, 8), Material.ORANGE_TERRACOTTA, 1);
    builder.fill(new Vector(12, 18, 10), new Vector(13, 18, 10), Material.ORANGE_TERRACOTTA, 1);
    builder.fill(new Vector(10, 18, 12), new Vector(10, 18, 13), Material.ORANGE_TERRACOTTA, 1);
    builder.fill(new Vector(7, 18, 10), new Vector(8, 18, 10), Material.ORANGE_TERRACOTTA, 1);
    // trap chamber
    builder.fill(new Vector(8, 0, 8), new Vector(12, 3, 12), Material.SANDSTONE, 2);
    builder.fill(new Vector(8, 4, 8), new Vector(12, 4, 12), Material.SANDSTONE, 1);
    builder.fill(new Vector(8, 5, 8), new Vector(12, 5, 12), Material.SANDSTONE, 2);
    builder.fill(new Vector(8, 6, 8), new Vector(12, 13, 12), Material.SANDSTONE);
    builder.fill(new Vector(9, 3, 9), new Vector(11, 17, 11), Material.AIR);
    builder.fill(new Vector(9, 1, 9), new Vector(11, 1, 11), Material.TNT);
    builder.fill(new Vector(9, 2, 9), new Vector(11, 2, 11), Material.SANDSTONE, 2);
    builder.fill(new Vector(10, 3, 8), new Vector(10, 4, 8), Material.AIR);
    builder.setBlock(new Vector(10, 3, 7), Material.SANDSTONE, 2);
    builder.setBlock(new Vector(10, 4, 7), Material.SANDSTONE, 1);
    builder.fill(new Vector(12, 3, 10), new Vector(12, 4, 10), Material.AIR);
    builder.setBlock(new Vector(13, 3, 10), Material.SANDSTONE, 2);
    builder.setBlock(new Vector(13, 4, 10), Material.SANDSTONE, 1);
    builder.fill(new Vector(10, 3, 12), new Vector(10, 4, 12), Material.AIR);
    builder.setBlock(new Vector(10, 3, 13), Material.SANDSTONE, 2);
    builder.setBlock(new Vector(10, 4, 13), Material.SANDSTONE, 1);
    builder.fill(new Vector(8, 3, 10), new Vector(8, 4, 10), Material.AIR);
    builder.setBlock(new Vector(7, 3, 10), Material.SANDSTONE, 2);
    builder.setBlock(new Vector(7, 4, 10), Material.SANDSTONE, 1);
    builder.setBlock(new Vector(10, 3, 10), Material.STONE_PRESSURE_PLATE);
    RandomItemsContent chestContent = getChestContent();
    if (!hasPlacedChest0) {
        hasPlacedChest0 = builder.createRandomItemsContainer(new Vector(10, 3, 12), random, chestContent, new Chest(getRelativeFacing(BlockFace.NORTH)), random.nextInt(5) + 2);
    }
    if (!hasPlacedChest1) {
        hasPlacedChest1 = builder.createRandomItemsContainer(new Vector(8, 3, 10), random, chestContent, new Chest(getRelativeFacing(BlockFace.EAST)), random.nextInt(5) + 2);
    }
    if (!hasPlacedChest2) {
        hasPlacedChest2 = builder.createRandomItemsContainer(new Vector(10, 3, 8), random, chestContent, new Chest(getRelativeFacing(BlockFace.SOUTH)), random.nextInt(5) + 2);
    }
    if (!hasPlacedChest3) {
        hasPlacedChest3 = builder.createRandomItemsContainer(new Vector(12, 3, 10), random, chestContent, new Chest(getRelativeFacing(BlockFace.WEST)), random.nextInt(5) + 2);
    }
    return true;
}
Also used : Chest(org.bukkit.material.Chest) StructureBuilder(net.glowstone.generator.structures.util.StructureBuilder) RandomItemsContent(net.glowstone.generator.objects.RandomItemsContent) Stairs(org.bukkit.material.Stairs) Step(org.bukkit.material.Step) Vector(org.bukkit.util.Vector)

Aggregations

RandomItemsContent (net.glowstone.generator.objects.RandomItemsContent)4 RandomAmountItem (net.glowstone.generator.objects.RandomItemsContent.RandomAmountItem)3 StructureBuilder (net.glowstone.generator.structures.util.StructureBuilder)3 Chest (org.bukkit.material.Chest)3 Vector (org.bukkit.util.Vector)3 HashMap (java.util.HashMap)2 StructureMaterial (net.glowstone.generator.structures.util.StructureBuilder.StructureMaterial)2 Stairs (org.bukkit.material.Stairs)2 BlockFace (org.bukkit.block.BlockFace)1 BlockState (org.bukkit.block.BlockState)1 Diode (org.bukkit.material.Diode)1 Dispenser (org.bukkit.material.Dispenser)1 Lever (org.bukkit.material.Lever)1 PistonBaseMaterial (org.bukkit.material.PistonBaseMaterial)1 Step (org.bukkit.material.Step)1 TripwireHook (org.bukkit.material.TripwireHook)1 Vine (org.bukkit.material.Vine)1