private static void lamp(World world, Coord pos) { MetaBlock spruce = new MetaBlock(Blocks.planks); MetaBlock fence = new MetaBlock(Blocks.oak_fence); spruce.withProperty(BlockPlanks.VARIANT_PROP, BlockPlanks.EnumType.SPRUCE); Coord cursor = new Coord(pos); cursor.add(Cardinal.UP, 4); spruce.setBlock(world, new Coord(cursor)); cursor.add(Cardinal.DOWN); WorldGenPrimitive.setBlock(world, cursor, Blocks.oak_fence); cursor.add(Cardinal.DOWN); WorldGenPrimitive.setBlock(world, cursor, Blocks.glowstone); for (Cardinal dir : Cardinal.directions) { MetaBlock trapdoor = new MetaBlock(Blocks.trapdoor); trapdoor.withProperty(BlockTrapDoor.FACING_PROP, Cardinal.getFacing(dir)); trapdoor.withProperty(BlockTrapDoor.OPEN_PROP, true); Coord p = new Coord(cursor); trapdoor.setBlock(world, p); } cursor.add(Cardinal.DOWN); fence.setBlock(world, cursor); cursor.add(Cardinal.DOWN); spruce.setBlock(world, cursor); }
public boolean validLocation(World world, Cardinal dir, int x, int y, int z) { if (!(dir == Cardinal.NORTH || dir == Cardinal.SOUTH)) return false; List<Coord> box = WorldGenPrimitive.getRectHollow(x - 7, y - 2, z - 7, x + 7, y + 5, z + 7); for (Coord pos : box) { MetaBlock b = WorldGenPrimitive.getBlock(world, pos); if (!b.getBlock().getMaterial().isSolid()) return false; } return true; }
public static void add(World world, Coord pos, int slot, ItemStack item) { TileEntity te = WorldGenPrimitive.getTileEntity(world, pos); if (te == null) return; if (!(te instanceof TileEntityDispenser)) return; TileEntityDispenser dispenser = (TileEntityDispenser) te; dispenser.setInventorySlotContents(slot, item); }
@Override public boolean validLocation(World world, Cardinal dir, int x, int y, int z) { Coord start; Coord end; start = new Coord(x, y, z); end = new Coord(start); start.add(Cardinal.reverse(dir), 9); end.add(dir, 9); Cardinal[] orth = Cardinal.getOrthogonal(dir); start.add(orth[0], 5); end.add(orth[1], 5); start.add(Cardinal.DOWN); end.add(Cardinal.UP, 3); for (Coord c : WorldGenPrimitive.getRectHollow(start, end)) { if (world.isAirBlock(c.getBlockPos())) return false; } return true; }
@Override public boolean generate( World world, Random rand, LevelSettings settings, Cardinal[] entrances, Coord origin) { int x = origin.getX(); int y = origin.getY(); int z = origin.getZ(); MetaBlock breadboard = new MetaBlock(Blocks.planks); Coord cursor; Coord start; Coord end; Cardinal dir = entrances[0]; start = new Coord(x, y, z); end = new Coord(start); start.add(Cardinal.reverse(dir), 9); end.add(dir, 9); Cardinal[] orth = Cardinal.getOrthogonal(dir); start.add(orth[0], 4); end.add(orth[1], 4); start.add(Cardinal.DOWN); end.add(Cardinal.UP, 3); WorldGenPrimitive.fillRectHollow( world, rand, start, end, new MetaBlock(Blocks.cobblestone), false, true); start = new Coord(x, y, z); start.add(orth[0], 2); end = new Coord(start); start.add(Cardinal.reverse(dir), 3); end.add(dir, 7); end.add(Cardinal.UP); WorldGenPrimitive.fillRectSolid(world, rand, start, end, breadboard, true, true); start.add(orth[1], 2); end.add(orth[1], 2); WorldGenPrimitive.fillRectSolid(world, rand, start, end, breadboard, true, true); start.add(orth[1], 2); end.add(orth[1], 2); WorldGenPrimitive.fillRectSolid(world, rand, start, end, breadboard, true, true); cursor = new Coord(x, y, z); cursor.add(orth[0], 2); launcher(world, rand, dir, cursor); cursor.add(orth[1], 2); launcher(world, rand, dir, cursor); cursor.add(orth[1], 2); launcher(world, rand, dir, cursor); cursor.add(dir, 6); launcher(world, rand, dir, cursor); cursor.add(orth[0], 2); launcher(world, rand, dir, cursor); cursor.add(orth[0], 2); launcher(world, rand, dir, cursor); start = new Coord(x, y, z); start.add(dir, 4); end = new Coord(start); start.add(orth[0], 2); end.add(orth[1], 2); end.add(dir, 2); WorldGenPrimitive.fillRectSolid(world, rand, start, end, new MetaBlock(Blocks.air), true, true); cursor = new Coord(x, y, z); cursor.add(dir, 2); Repeater.generate(world, rand, dir, 0, cursor); cursor.add(orth[0], 2); Repeater.generate(world, rand, dir, 0, cursor); cursor.add(orth[1], 4); Repeater.generate(world, rand, dir, 0, cursor); cursor = new Coord(x, y, z); cursor.add(Cardinal.reverse(dir), 3); cursor.add(orth[0]); Repeater.generate(world, rand, orth[0], 0, cursor); cursor.add(orth[1], 2); Repeater.generate(world, rand, orth[1], 0, cursor); MetaBlock wire = new MetaBlock(Blocks.redstone_wire); start = new Coord(x, y, z); start.add(Cardinal.DOWN, 2); start.add(orth[1]); start.add(Cardinal.reverse(dir), 2); end = new Coord(start); end.add(orth[0], 5); end.add(Cardinal.reverse(dir), 5); end.add(Cardinal.DOWN, 2); WorldGenPrimitive.fillRectSolid( world, rand, start, end, new MetaBlock(Blocks.cobblestone), true, true); cursor = new Coord(x, y, z); cursor.add(Cardinal.reverse(dir), 3); cursor.add(Cardinal.DOWN); Torch.generate(world, Torch.REDSTONE, Cardinal.UP, cursor); cursor.add(Cardinal.DOWN); breadboard.setBlock(world, cursor); cursor.add(orth[0]); Torch.generate(world, Torch.REDSTONE, orth[0], cursor); cursor.add(orth[0]); wire.setBlock(world, cursor); cursor.add(Cardinal.reverse(dir)); wire.setBlock(world, cursor); cursor.add(Cardinal.reverse(dir)); wire.setBlock(world, cursor); cursor.add(orth[1]); wire.setBlock(world, cursor); cursor.add(orth[1]); wire.setBlock(world, cursor); cursor.add(dir); Repeater.generate(world, rand, Cardinal.reverse(dir), 4, cursor); cursor.add(Cardinal.UP); cursor.add(Cardinal.reverse(dir)); breadboard.setBlock(world, cursor); cursor.add(Cardinal.UP); Lever.generate(world, Cardinal.UP, cursor, true); return false; }
private void launcher(World world, Random rand, Cardinal dir, Coord pos) { Coord cursor = new Coord(pos); WorldGenPrimitive.setBlock(world, cursor, Blocks.redstone_wire); cursor.add(Cardinal.reverse(dir)); WorldGenPrimitive.setBlock(world, cursor, Blocks.redstone_wire); cursor.add(Cardinal.reverse(dir)); Repeater.generate(world, rand, dir, 0, cursor); cursor.add(Cardinal.reverse(dir)); cursor.add(Cardinal.UP); Dropper dropper = new Dropper(); dropper.generate(world, Cardinal.UP, cursor); for (int i = 0; i < 8; ++i) { dropper.add(world, cursor, i, new ItemStack(Items.dye, 1, i)); } dropper.add(world, cursor, 8, new ItemStack(Items.wooden_hoe)); cursor.add(Cardinal.UP); WorldGenPrimitive.setBlock(world, cursor, Blocks.hopper); cursor.add(dir); Comparator.generate(world, rand, dir, false, cursor); cursor.add(dir); WorldGenPrimitive.setBlock(world, cursor, Blocks.redstone_wire); cursor.add(dir); WorldGenPrimitive.setBlock(world, cursor, Blocks.redstone_wire); cursor.add(dir); Coord top = new Coord(pos.getX(), 80, pos.getZ()); while (top.getY() > pos.getY()) { top.add(Cardinal.DOWN); if (WorldGenPrimitive.getBlock(world, top).getBlock().getMaterial().isSolid()) break; } if (top.getY() >= 100) return; Coord start = new Coord(cursor); start.add(Cardinal.UP); start.add(dir); Coord end = new Coord(start); MetaBlock breadboard = new MetaBlock(Blocks.planks); boolean torch = false; while (end.getY() < top.getY()) { if (torch) { Torch.generate(world, Torch.REDSTONE, Cardinal.UP, cursor); } else { breadboard.setBlock(world, cursor); } torch = !torch; cursor.add(Cardinal.UP); end.add(Cardinal.UP); } if (torch) { cursor.add(Cardinal.DOWN); } Dispenser.generate(world, Cardinal.UP, cursor); for (int i = 0; i < 9; i++) { Dispenser.add(world, cursor, i, Firework.get(rand, 16 + rand.nextInt(16))); } cursor.add(Cardinal.UP); MetaBlock cob = new MetaBlock(Blocks.cobblestone); WorldGenPrimitive.fillRectSolid(world, rand, start, end, cob, true, true); start.add(Cardinal.reverse(dir), 2); end.add(Cardinal.reverse(dir), 2); WorldGenPrimitive.fillRectSolid(world, rand, start, end, cob, true, true); Cardinal[] orth = Cardinal.getOrthogonal(dir); start.add(dir); end.add(dir); Coord above = new Coord(end); above.add(Cardinal.UP, 10); List<Coord> tubeEnd = WorldGenPrimitive.getRectSolid(cursor, above); MetaBlock air = new MetaBlock(Blocks.air); for (Coord c : tubeEnd) { if (WorldGenPrimitive.getBlock(world, c).getBlock().getMaterial().isSolid()) { air.setBlock(world, c); } } start.add(orth[0]); end.add(orth[0]); WorldGenPrimitive.fillRectSolid(world, rand, start, end, cob, true, true); start.add(orth[1], 2); end.add(orth[1], 2); WorldGenPrimitive.fillRectSolid(world, rand, start, end, cob, true, true); }
@Override protected void genWall( World world, Random rand, IDungeonLevel level, Cardinal dir, ITheme theme, int x, int y, int z) { MetaBlock air = new MetaBlock(Blocks.air); MetaBlock stair = theme.getSecondaryStair(); Coord cursor; Coord start; Coord end; Cardinal[] orth = Cardinal.getOrthogonal(dir); start = new Coord(x, y, z); start.add(dir, 2); end = new Coord(start); start.add(orth[0], 1); end.add(orth[1], 1); end.add(Cardinal.UP, 2); WorldGenPrimitive.fillRectSolid(world, rand, start, end, air, true, true); start.add(dir, 1); end.add(dir, 1); WorldGenPrimitive.fillRectSolid(world, rand, start, end, theme.getSecondaryWall(), true, true); for (Cardinal d : orth) { cursor = new Coord(x, y, z); cursor.add(Cardinal.UP, 2); cursor.add(dir, 2); cursor.add(d, 1); WorldGenPrimitive.blockOrientation(stair, Cardinal.reverse(dir), true); WorldGenPrimitive.setBlock(world, rand, cursor, stair, true, true); cursor = new Coord(x, y, z); cursor.add(dir, 2); cursor.add(d, 1); WorldGenPrimitive.blockOrientation(stair, Cardinal.reverse(d), false); WorldGenPrimitive.setBlock(world, rand, cursor, stair, true, true); } cursor = new Coord(x, y, z); cursor.add(Cardinal.UP, 1); cursor.add(dir, 3); WorldGenPrimitive.setBlock(world, rand, cursor, air, true, true); cursor.add(Cardinal.UP, 1); WorldGenPrimitive.blockOrientation(stair, Cardinal.reverse(dir), true); WorldGenPrimitive.setBlock(world, rand, cursor, stair, true, true); Coord shelf = new Coord(x, y, z); shelf.add(dir, 3); Coord below = new Coord(shelf); shelf.add(Cardinal.UP, 1); if (world.isAirBlock(below.getBlockPos())) return; boolean trapped = Dungeon.getLevel(y) == 3 && rand.nextInt(3) == 0; TreasureChest.generate(world, rand, level.getSettings(), shelf, Dungeon.getLevel(y), trapped); if (trapped) { WorldGenPrimitive.setBlock(world, shelf.getX(), shelf.getY() - 2, shelf.getZ(), Blocks.tnt); if (rand.nextBoolean()) WorldGenPrimitive.setBlock(world, shelf.getX(), shelf.getY() - 3, shelf.getZ(), Blocks.tnt); } }
@Override public boolean generate( World world, Random rand, LevelSettings settings, Cardinal[] entrances, Coord origin) { int x = origin.getX(); int y = origin.getY(); int z = origin.getZ(); MetaBlock air = new MetaBlock(Blocks.air); MetaBlock oakLog = Log.getLog(Log.OAK); MetaBlock stair = new MetaBlock(Blocks.spruce_stairs); MetaBlock stonebrick = new MetaBlock(Blocks.stonebrick); MetaBlock cyan = new MetaBlock(Blocks.stained_hardened_clay); cyan.withProperty(BlockColored.COLOR, EnumDyeColor.CYAN); MetaBlock doubleSlab = new MetaBlock(Blocks.double_stone_slab); doubleSlab.withProperty(BlockDoubleStoneSlab.VARIANT_PROP, BlockStoneSlab.EnumType.STONE); MetaBlock sprucePlank = new MetaBlock(Blocks.planks); sprucePlank.withProperty(BlockPlanks.VARIANT_PROP, BlockPlanks.EnumType.SPRUCE); WorldGenPrimitive.fillRectSolid(world, rand, x - 4, y, z - 4, x + 4, y + 4, z + 5, air); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y - 1, z - 4, x + 4, y - 1, z + 5, new MetaBlock(Blocks.cobblestone)); WorldGenPrimitive.fillRectSolid( world, rand, x - 3, y - 1, z - 2, x + 3, y - 1, z + 3, cyan, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 2, y - 1, z - 1, x + 2, y - 1, z + 2, doubleSlab, true, true); // wood panel walls BlockFactoryCheckers panels = new BlockFactoryCheckers( Log.getLog(Log.SPRUCE, Cardinal.UP), Log.getLog(Log.SPRUCE, Cardinal.EAST)); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y + 1, z + 6, x + 4, y + 3, z + 6, panels, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y + 1, z - 5, x + 4, y + 3, z - 5, panels, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y, z + 6, x + 4, y, z + 6, sprucePlank, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y, z - 5, x + 4, y, z - 5, sprucePlank, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 5, y - 1, z - 4, x - 5, y, z + 5, sprucePlank, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x + 5, y - 1, z - 4, x + 5, y, z + 5, sprucePlank, true, true); stair.withProperty(BlockStairs.FACING, EnumFacing.SOUTH); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y + 4, z - 4, x + 4, y + 4, z - 4, stair, true, true); stair.withProperty(BlockStairs.FACING, EnumFacing.NORTH); WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y + 4, z + 5, x + 4, y + 4, z + 5, stair, true, true); // doors WorldGenPrimitive.fillRectSolid( world, rand, x - 1, y, z - 5, x + 1, y + 2, z - 5, new MetaBlock(Blocks.cobblestone)); WorldGenPrimitive.fillRectSolid(world, rand, x, y, z - 5, x, y + 1, z - 5, air); WorldGenPrimitive.fillRectSolid( world, rand, x - 1, y, z + 6, x + 1, y + 2, z + 6, new MetaBlock(Blocks.cobblestone)); WorldGenPrimitive.fillRectSolid(world, rand, x, y, z + 6, x, y + 1, z + 6, air); // west wall WorldGenPrimitive.fillRectSolid( world, rand, x - 5, y, z - 5, x - 5, y + 4, z + 6, sprucePlank, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 5, y, z - 1, x - 5, y, z + 2, new MetaBlock(Blocks.noteblock)); WorldGenPrimitive.fillRectSolid( world, rand, x - 5, y + 1, z - 3, x - 5, y + 3, z + 4, new MetaBlock(Blocks.bookshelf)); MetaBlock black = new MetaBlock(Blocks.wool); black.withProperty(BlockColored.COLOR, EnumDyeColor.BLACK); WorldGenPrimitive.fillRectSolid( world, rand, x - 5, y + 1, z - 1, x - 5, y + 3, z + 2, black, true, true); MetaBlock cocao = new MetaBlock(Blocks.cocoa); cocao.withProperty(BlockCocoa.FACING, EnumFacing.EAST); WorldGenPrimitive.setBlock(world, x - 5, y + 2, z - 2, Log.getLog(Log.JUNGLE, Cardinal.EAST)); cocao.setBlock(world, new Coord(x - 4, y + 2, z - 2)); WorldGenPrimitive.setBlock(world, x - 5, y + 2, z + 3, Log.getLog(Log.JUNGLE, Cardinal.EAST)); cocao.setBlock(world, new Coord(x - 4, y + 2, z + 3)); lamp(world, new Coord(x - 2, y, z - 4)); lamp(world, new Coord(x + 2, y, z - 4)); lamp(world, new Coord(x - 2, y, z + 5)); lamp(world, new Coord(x + 2, y, z + 5)); // east wall WorldGenPrimitive.fillRectSolid( world, rand, x + 5, y + 1, z - 4, x + 5, y + 4, z + 5, stonebrick); MetaBlock lime = new MetaBlock(Blocks.wool); lime.withProperty(BlockColored.COLOR, EnumDyeColor.LIME); MetaBlock greenBlock = RogueConfig.getBoolean(RogueConfig.PRECIOUSBLOCKS) ? new MetaBlock(Blocks.emerald_block) : lime; WorldGenPrimitive.fillRectSolid( world, rand, x + 5, y, z - 1, x + 5, y + 4, z - 1, greenBlock, true, true); WorldGenPrimitive.fillRectSolid( world, rand, x + 5, y, z, x + 5, y, z + 1, greenBlock, true, true); WorldGenPrimitive.fillRectSolid(world, rand, x + 5, y + 1, z, x + 5, y + 1, z + 1, air); greenBlock.setBlock(world, new Coord(x + 5, y + 1, z + 2)); WorldGenPrimitive.fillRectSolid( world, rand, x + 5, y + 2, z, x + 5, y + 2, z + 1, greenBlock, true, true); WorldGenPrimitive.fillRectSolid(world, rand, x + 5, y + 3, z, x + 5, y + 3, z + 1, air); greenBlock.setBlock(world, new Coord(x + 5, y + 3, z + 2)); WorldGenPrimitive.fillRectSolid( world, rand, x + 5, y + 4, z, x + 5, y + 4, z + 1, greenBlock, true, true); // roof WorldGenPrimitive.fillRectSolid( world, rand, x - 4, y + 5, z - 5, x + 4, y + 6, z + 6, new MetaBlock(Blocks.stone)); WorldGenPrimitive.fillRectSolid( world, rand, x - 2, y + 5, z - 1, x + 2, y + 5, z - 1, WorldGenPrimitive.blockOrientation(stair, Cardinal.SOUTH, true), true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 2, y + 5, z + 2, x + 2, y + 5, z + 2, WorldGenPrimitive.blockOrientation(stair, Cardinal.NORTH, true), true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 3, y + 5, z, x - 3, y + 5, z + 1, WorldGenPrimitive.blockOrientation(stair, Cardinal.EAST, true), true, true); WorldGenPrimitive.fillRectSolid( world, rand, x + 3, y + 5, z, x + 3, y + 5, z + 1, WorldGenPrimitive.blockOrientation(stair, Cardinal.WEST, true), true, true); WorldGenPrimitive.fillRectSolid( world, rand, x - 2, y + 5, z, x + 2, y + 5, z + 1, new MetaBlock(Blocks.redstone_lamp)); WorldGenPrimitive.setBlock(world, x - 3, y + 5, z - 1, oakLog); WorldGenPrimitive.setBlock(world, x + 3, y + 5, z - 1, oakLog); WorldGenPrimitive.setBlock(world, x - 3, y + 5, z + 2, oakLog); WorldGenPrimitive.setBlock(world, x + 3, y + 5, z + 2, oakLog); // table WorldGenPrimitive.fillRectSolid( world, rand, x - 2, y, z, x - 2, y, z + 1, WorldGenPrimitive.blockOrientation(stair, Cardinal.WEST, true), true, true); WorldGenPrimitive.fillRectSolid( world, rand, x + 2, y, z, x + 2, y, z + 1, WorldGenPrimitive.blockOrientation(stair, Cardinal.EAST, true), true, true); MetaBlock spruceSlabUpsideDown = new MetaBlock(Blocks.wooden_slab); spruceSlabUpsideDown.withProperty(BlockPlanks.VARIANT_PROP, BlockPlanks.EnumType.SPRUCE); spruceSlabUpsideDown.withProperty(BlockSlab.HALF_PROP, BlockSlab.EnumBlockHalf.TOP); WorldGenPrimitive.fillRectSolid( world, rand, x - 1, y, z, x + 1, y, z + 1, spruceSlabUpsideDown, true, true); // chairs MetaBlock chair = new MetaBlock(Blocks.nether_brick_stairs); WorldGenPrimitive.blockOrientation(chair, Cardinal.SOUTH, false); chair.setBlock(world, new Coord(x - 1, y, z - 2)); chair.setBlock(world, new Coord(x + 1, y, z - 2)); WorldGenPrimitive.blockOrientation(chair, Cardinal.NORTH, false); chair.setBlock(world, new Coord(x - 1, y, z + 3)); chair.setBlock(world, new Coord(x + 1, y, z + 3)); // wall entrances WorldGenPrimitive.fillRectSolid( world, rand, x - 7, y - 1, z - 4, x - 6, y + 4, z + 4, stonebrick); WorldGenPrimitive.fillRectSolid( world, rand, x + 6, y - 1, z - 4, x + 7, y + 4, z + 4, stonebrick); ITreasureChest recordChest = new TreasureChestEmpty() .generate(world, rand, settings.getLoot(), new Coord(x - 4, y, z - 4), 0, false); recordChest.setInventorySlot(Record.getRecord(Record.STAL), recordChest.getInventorySize() / 2); WorldGenPrimitive.setBlock(world, x - 3, y, z - 4, Blocks.jukebox); ITreasureChest bdubsChest = new TreasureChestEmpty() .generate(world, rand, settings.getLoot(), new Coord(x - 3, y, z + 5), 0, false); bdubsChest.setInventorySlot( ItemNovelty.getItem(ItemNovelty.BDOUBLEO), (bdubsChest.getInventorySize() / 2) - 2); ItemStack shirt = new ItemStack(Items.leather_chestplate); Loot.setItemName(shirt, "Pink Sweater", null); Loot.setItemLore(shirt, "\"It's chinese red!\""); ItemArmour.dyeArmor(shirt, 250, 96, 128); bdubsChest.setInventorySlot(shirt, (bdubsChest.getInventorySize() / 2) + 2); ITreasureChest gennybChest = new TreasureChestEmpty() .generate(world, rand, settings.getLoot(), new Coord(x + 3, y, z + 5), 0, false); gennybChest.setInventorySlot( ItemNovelty.getItem(ItemNovelty.GENERIKB), gennybChest.getInventorySize() / 2); WorldGenPrimitive.setBlock(world, x + 4, y, z - 4, Blocks.bookshelf); WorldGenPrimitive.setBlock(world, x + 4, y + 1, z - 4, Blocks.brewing_stand); ITreasureChest contraband = new TreasureChestEmpty() .generate(world, rand, settings.getLoot(), new Coord(x + 3, y, z - 4), 0, false); for (int i = 0; i < 8; ++i) { ItemStack booze = PotionMixture.getBooze(rand); contraband.setInventorySlot(booze, rand.nextInt(contraband.getInventorySize())); } return true; }