@Override public boolean generate(World world, Random rand, BlockPos position) { WorldServer server = (WorldServer) world; TemplateManager manager = server.getStructureTemplateManager(); Template dungeonEntrance = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/test_entrance")); PlacementSettings settings = new PlacementSettings(); if (LSCWorldGenerator.canSpawnHere(dungeonEntrance, world, position)) { LootSlashConquer.LOGGER.info("Generating Dungeon at " + position); // spawn the entrance on the surface BlockPos entrancePos = DungeonHelper.translateToCorner(dungeonEntrance, position, Rotation.NONE); dungeonEntrance.addBlocksToWorld(world, entrancePos, new DungeonBlockProcessor(entrancePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2); // start the procedural generation procedurallyGenerate(manager, world, position, this.generateStaircase(manager, world, position)); return true; } return false; }
/** * Generates a stores potential room positions off of the current template. Note: this does not take into account existing rooms. Check for existing rooms when spawning each specific room position. * @param currentTemplate */ private List<DungeonRoomPosition> generatePotentialRooms(TemplateManager manager, World world, Template currentTemplate, Rotation currentTemplateRotation, BlockPos currentCenter, Rotation currentSide) { List<DungeonRoomPosition> list = Lists.newArrayList(); //Rotation side = Rotation.values()[(int) (Math.random() * 4)]; for (Rotation side : Rotation.values()) { Template nextTemplate = DungeonHelper.getRandomizedDungeonTemplate(manager, world); Rotation nextTemplateRotation = Rotation.values()[(int) (Math.random() * 4)]; BlockPos centeredPosition = DungeonHelper.translateToNextRoom(currentTemplate, nextTemplate, currentCenter, side, currentTemplateRotation, nextTemplateRotation); StructureBoundingBox boundingBox = DungeonHelper.getStructureBoundingBox(nextTemplate, nextTemplateRotation, centeredPosition); if (currentSide == null || (currentSide != null && currentSide.add(Rotation.CLOCKWISE_180) != side)) // check to make sure we aren't spawning a room on the side we just spawned from. { list.add(new DungeonRoomPosition(centeredPosition, nextTemplate, nextTemplateRotation, side, boundingBox)); } } return list; }
private void generateOverworldStructures(World world, Random random, int posX, int posZ) { if(OinkConfig.piggyActive) { WorldServer server = (WorldServer) world; TemplateManager manager = server.getStructureTemplateManager(); Template piggy = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(TheOink.MODID, "pigstructure")); if ((int) (Math.random() * OinkConfig.piggyStructChance) == 0) { int randX = posX + (int) (Math.random() * 16); int randZ = posZ + (int) (Math.random() * 16); int groundY = getGroundFromAbove(world, randX, randZ); BlockPos pos = new BlockPos(randX, groundY, randZ); if (canSpawnHere(piggy, world, pos)) { TheOink.LOGGER.info("Generating Pig at " + pos); piggy.addBlocksToWorld(world, pos, new PlacementSettings()); handleDataBlocks(piggy, world, pos, new PlacementSettings()); } } } }
public boolean func_191086_a(TemplateManager p_191086_1_, int p_191086_2_, StructureEndCityPieces.CityTemplate p_191086_3_, BlockPos p_191086_4_, List<StructureComponent> p_191086_5_, Random p_191086_6_) { Rotation rotation = p_191086_3_.placeSettings.getRotation(); StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, p_191086_3_, new BlockPos(-3, 4, -3), "fat_tower_base", rotation, true)); structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(0, 4, 0), "fat_tower_middle", rotation, true)); for (int i = 0; i < 2 && p_191086_6_.nextInt(3) != 0; ++i) { structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(0, 8, 0), "fat_tower_middle", rotation, true)); for (Tuple<Rotation, BlockPos> tuple : StructureEndCityPieces.FAT_TOWER_BRIDGES) { if (p_191086_6_.nextBoolean()) { StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate1 = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, (BlockPos)tuple.getSecond(), "bridge_end", rotation.add((Rotation)tuple.getFirst()), true)); StructureEndCityPieces.func_191088_b(p_191086_1_, StructureEndCityPieces.TOWER_BRIDGE_GENERATOR, p_191086_2_ + 1, structureendcitypieces$citytemplate1, (BlockPos)null, p_191086_5_, p_191086_6_); } } } StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-2, 8, -2), "fat_tower_top", rotation, true)); return true; }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.cropTypeA = Block.getBlockById(tagCompound.getInteger("CA")); this.cropTypeB = Block.getBlockById(tagCompound.getInteger("CB")); this.cropTypeC = Block.getBlockById(tagCompound.getInteger("CC")); this.cropTypeD = Block.getBlockById(tagCompound.getInteger("CD")); if (!(this.cropTypeA instanceof BlockCrops)) { this.cropTypeA = Blocks.WHEAT; } if (!(this.cropTypeB instanceof BlockCrops)) { this.cropTypeB = Blocks.CARROTS; } if (!(this.cropTypeC instanceof BlockCrops)) { this.cropTypeC = Blocks.POTATOES; } if (!(this.cropTypeD instanceof BlockCrops)) { this.cropTypeD = Blocks.BEETROOTS; } }
public SaveHandler(File p_i46648_1_, String saveDirectoryNameIn, boolean p_i46648_3_, DataFixer dataFixerIn) { this.dataFixer = dataFixerIn; this.worldDirectory = new File(p_i46648_1_, saveDirectoryNameIn); this.worldDirectory.mkdirs(); this.playersDirectory = new File(this.worldDirectory, "playerdata"); this.mapDataDir = new File(this.worldDirectory, "data"); this.mapDataDir.mkdirs(); this.saveDirectoryName = saveDirectoryNameIn; if (p_i46648_3_) { this.playersDirectory.mkdirs(); this.structureTemplateManager = new TemplateManager((new File(this.worldDirectory, "structures")).toString(), dataFixerIn); } else { this.structureTemplateManager = null; } this.setSessionLock(); }
public boolean save(boolean p_189712_1_) { if (this.mode == TileEntityStructure.Mode.SAVE && !this.world.isRemote && !StringUtils.isNullOrEmpty(this.name)) { BlockPos blockpos = this.getPos().add(this.position); WorldServer worldserver = (WorldServer)this.world; MinecraftServer minecraftserver = this.world.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name)); template.takeBlocksFromWorld(this.world, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID); template.setAuthor(this.author); return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name)); } else { return false; } }
public SaveHandler(File p_i46648_1_, String saveDirectoryNameIn, boolean p_i46648_3_, DataFixer dataFixerIn) { this.dataFixer = dataFixerIn; this.worldDirectory = new File(p_i46648_1_, saveDirectoryNameIn); this.worldDirectory.mkdirs(); this.playersDirectory = new File(this.worldDirectory, "playerdata"); this.mapDataDir = new File(this.worldDirectory, "data"); this.mapDataDir.mkdirs(); this.saveDirectoryName = saveDirectoryNameIn; if (p_i46648_3_) { this.playersDirectory.mkdirs(); this.structureTemplateManager = new TemplateManager((new File(this.worldDirectory, "structures")).toString()); } else { this.structureTemplateManager = null; } this.setSessionLock(); }
public boolean save(boolean p_189712_1_) { if (this.mode == TileEntityStructure.Mode.SAVE && !this.worldObj.isRemote && !StringUtils.isNullOrEmpty(this.name)) { BlockPos blockpos = this.getPos().add(this.position); WorldServer worldserver = (WorldServer)this.worldObj; MinecraftServer minecraftserver = this.worldObj.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name)); template.takeBlocksFromWorld(this.worldObj, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID); template.setAuthor(this.author); return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name)); } else { return false; } }
public ArrayList<PotentialPosition> generateRooms(TemplateManager manager, World world, ArrayList<PotentialPosition> potentialPositions, int roomCount) { LostEclipse.LOGGER.info("Potential size: " + potentialPositions.size()); ArrayList<PotentialPosition> nextPotentialPositions = new ArrayList<PotentialPosition>(); for (int i = 0; i < potentialPositions.size(); i++) { BlockPos center = potentialPositions.get(i).getPos(); Rotation rotation = potentialPositions.get(i).getRotation(); LostEclipse.LOGGER.info("Generating randomized rooms off of hallways."); ArrayList<PotentialPosition> nextPositions = generateRandomRoom(manager, world, center, rotation); if (nextPositions != null) { for (PotentialPosition position : nextPositions) { if (position != null) nextPotentialPositions.add(position); } } } return nextPotentialPositions; }
private PotentialPosition generateHallway(TemplateManager manager, World world, BlockPos roomCenter, Rotation rotation) { Template hallway = getRandomizedHallwayTemplate(manager, world); // get hallway and its center position BlockPos hallwayCenter = getHallwayPosition(hallway, roomCenter, rotation); for (BlockPos position : hallwayPositions) // check to make sure hallway can spawn. If not, exit. { if (position.equals(hallwayCenter)) return null; } PlacementSettings settings = new PlacementSettings().setRotation(rotation); BlockPos hallwayCorner = translateHallwayToCorner(hallway, hallwayCenter, rotation); hallway.addBlocksToWorld(world, hallwayCorner, settings); // add hallway into world at translated position handleDataBlocks(hallway, world, hallwayCorner, settings); hallwayPositions.add(hallwayCenter); // add hallway to hallwayPositions list BlockPos potentialPosition = getRoomPosition(getRandomizedDungeonTemplate(manager, world), hallwayCenter, rotation); return new PotentialPosition(potentialPosition, rotation); }
/** * Procedurally generate a dungeon through recursion using a simple 'Procedurally Build' algorithm. * @param manager * @param world * @param startingPos - this position will ALWAYS be the position of the entrance. */ public void procedurallyGenerate(TemplateManager manager, World world, BlockPos startingPos, List<DungeonRoomPosition> nextPos) { List<DungeonRoomPosition> nextPos2 = Lists.newArrayList(); // list which will hold the positions to be tried in the NEXT recursion of the method. if (roomCount > roomTries) return; else { ArrayList<StructureBoundingBox> roomListCopy = Lists.newArrayList(roomList); for (DungeonRoomPosition room : nextPos) { // check to make sure rooms don't overlap for (StructureBoundingBox existingBB : roomListCopy) { // if structures don't overlap if (!DungeonHelper.checkOverlap(existingBB, room.getBoundingBox())) { LootSlashConquer.LOGGER.info("Room generated successfully."); List<DungeonRoomPosition> nextRooms = this.generateRoom(manager, world, room); // copy new generated rooms into bigger list for (DungeonRoomPosition nextRoom : nextRooms) { nextPos2.add(nextRoom); } } else { LootSlashConquer.LOGGER.info("Room failed to generate."); } } } } roomCount++; procedurallyGenerate(manager, world, startingPos, nextPos2); }
/** Generates the staircase underneath the entrance. */ // WORKING private List<DungeonRoomPosition> generateStaircase(TemplateManager manager, World world, BlockPos entranceCenter) { Template encasedStaircase = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/encased_staircase")); Template bottomStaircase = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/bottom_staircase")); PlacementSettings settings = new PlacementSettings(); int depth = 4; // how many staircases are generated? List<DungeonRoomPosition> list = null; for (int i = 0; i < depth; i++) { if (i < depth - 1) // make sure we aren't at the last staircase { BlockPos encasedStaircasePos = DungeonHelper.translateToCorner(encasedStaircase, entranceCenter.add(0, -4 * (i + 1), 0), Rotation.NONE); // get the staircase position; offset by height and multiply by depth. encasedStaircase.addBlocksToWorld(world, encasedStaircasePos, new DungeonBlockProcessor(encasedStaircasePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2); } else // we know this is the bottom staircase, so spawn bottom staircase and store potential rooms. { BlockPos bottomStaircaseCenteredPos = entranceCenter.add(0, -4 * (depth - 1) + -5, 0); BlockPos bottomStaircasePos = DungeonHelper.translateToCorner(bottomStaircase, bottomStaircaseCenteredPos, Rotation.NONE); bottomStaircase.addBlocksToWorld(world, bottomStaircasePos, new DungeonBlockProcessor(bottomStaircasePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2); roomList.add(DungeonHelper.getStructureBoundingBox(bottomStaircase, Rotation.NONE, bottomStaircaseCenteredPos)); // add StructureBoundingBox to room list. Used to make sure we don't generate rooms inside of other bounding boxes. list = this.generatePotentialRooms(manager, world, bottomStaircase, Rotation.NONE, bottomStaircaseCenteredPos, null); } } return list; }
/** Generates a room based on the DungeonRoomPosition passed in. */ @Nullable private List<DungeonRoomPosition> generateRoom(TemplateManager manager, World world, DungeonRoomPosition drp) { Template template = drp.getTemplate(); PlacementSettings settings = new PlacementSettings().setRotation(drp.getTemplateRotation()); BlockPos centeredPosition = drp.getPos(); BlockPos cornerPosition = DungeonHelper.translateToCorner(template, centeredPosition, settings.getRotation()); template.addBlocksToWorld(world, cornerPosition, new DungeonBlockProcessor(cornerPosition, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2); DungeonHelper.handleDataBlocks(template, world, cornerPosition, settings, 1); roomList.add(drp.getBoundingBox()); return this.generatePotentialRooms(manager, world, template, settings.getRotation(), centeredPosition, drp.getSide()); }
public static Template getRandomizedDungeonTemplate(TemplateManager manager, World world) { ArrayList<Template> templates = new ArrayList<Template>(); templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/test_room1"))); templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/test_room2"))); return templates.get((int) (Math.random() * (templates.size()))); }
public static Template getStaircaseTemplate(TemplateManager manager, World world) { ArrayList<Template> templates = new ArrayList<Template>(); templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "staircase1"))); return templates.get((int) (Math.random() * (templates.size()))); }
@Override public TemplateManager getStructureTemplateManager() { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getStructureTemplateManager(); } else if (m_realWorld != null) { return m_realWorld.getStructureTemplateManager(); } else { return super.getStructureTemplateManager(); } }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.hasPlacedChest[0] = tagCompound.getBoolean("hasPlacedChest0"); this.hasPlacedChest[1] = tagCompound.getBoolean("hasPlacedChest1"); this.hasPlacedChest[2] = tagCompound.getBoolean("hasPlacedChest2"); this.hasPlacedChest[3] = tagCompound.getBoolean("hasPlacedChest3"); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { this.scatteredFeatureSizeX = tagCompound.getInteger("Width"); this.scatteredFeatureSizeY = tagCompound.getInteger("Height"); this.scatteredFeatureSizeZ = tagCompound.getInteger("Depth"); this.horizontalPos = tagCompound.getInteger("HPos"); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.placedMainChest = tagCompound.getBoolean("placedMainChest"); this.placedHiddenChest = tagCompound.getBoolean("placedHiddenChest"); this.placedTrap1 = tagCompound.getBoolean("placedTrap1"); this.placedTrap2 = tagCompound.getBoolean("placedTrap2"); }
public boolean func_191086_a(TemplateManager p_191086_1_, int p_191086_2_, StructureEndCityPieces.CityTemplate p_191086_3_, BlockPos p_191086_4_, List<StructureComponent> p_191086_5_, Random p_191086_6_) { if (p_191086_2_ > 8) { return false; } else { Rotation rotation = p_191086_3_.placeSettings.getRotation(); StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, p_191086_3_, p_191086_4_, "base_floor", rotation, true)); int i = p_191086_6_.nextInt(3); if (i == 0) { StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-1, 4, -1), "base_roof", rotation, true)); } else if (i == 1) { structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-1, 0, -1), "second_floor_2", rotation, false)); structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-1, 8, -1), "second_roof", rotation, false)); StructureEndCityPieces.func_191088_b(p_191086_1_, StructureEndCityPieces.TOWER_GENERATOR, p_191086_2_ + 1, structureendcitypieces$citytemplate, (BlockPos)null, p_191086_5_, p_191086_6_); } else if (i == 2) { structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-1, 0, -1), "second_floor_2", rotation, false)); structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-1, 4, -1), "third_floor_c", rotation, false)); structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-1, 8, -1), "third_roof", rotation, true)); StructureEndCityPieces.func_191088_b(p_191086_1_, StructureEndCityPieces.TOWER_GENERATOR, p_191086_2_ + 1, structureendcitypieces$citytemplate, (BlockPos)null, p_191086_5_, p_191086_6_); } return true; } }
private static StructureEndCityPieces.CityTemplate func_191090_b(TemplateManager p_191090_0_, StructureEndCityPieces.CityTemplate p_191090_1_, BlockPos p_191090_2_, String p_191090_3_, Rotation p_191090_4_, boolean p_191090_5_) { StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = new StructureEndCityPieces.CityTemplate(p_191090_0_, p_191090_3_, p_191090_1_.templatePosition, p_191090_4_, p_191090_5_); BlockPos blockpos = p_191090_1_.template.calculateConnectedPos(p_191090_1_.placeSettings, p_191090_2_, structureendcitypieces$citytemplate.placeSettings, BlockPos.ORIGIN); structureendcitypieces$citytemplate.offset(blockpos.getX(), blockpos.getY(), blockpos.getZ()); return structureendcitypieces$citytemplate; }
public static void func_191087_a(TemplateManager p_191087_0_, BlockPos p_191087_1_, Rotation p_191087_2_, List<StructureComponent> p_191087_3_, Random p_191087_4_) { FAT_TOWER_GENERATOR.init(); HOUSE_TOWER_GENERATOR.init(); TOWER_BRIDGE_GENERATOR.init(); TOWER_GENERATOR.init(); StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = func_189935_b(p_191087_3_, new StructureEndCityPieces.CityTemplate(p_191087_0_, "base_floor", p_191087_1_, p_191087_2_, true)); structureendcitypieces$citytemplate = func_189935_b(p_191087_3_, func_191090_b(p_191087_0_, structureendcitypieces$citytemplate, new BlockPos(-1, 0, -1), "second_floor", p_191087_2_, false)); structureendcitypieces$citytemplate = func_189935_b(p_191087_3_, func_191090_b(p_191087_0_, structureendcitypieces$citytemplate, new BlockPos(-1, 4, -1), "third_floor", p_191087_2_, false)); structureendcitypieces$citytemplate = func_189935_b(p_191087_3_, func_191090_b(p_191087_0_, structureendcitypieces$citytemplate, new BlockPos(-1, 8, -1), "third_roof", p_191087_2_, true)); func_191088_b(p_191087_0_, TOWER_GENERATOR, 1, structureendcitypieces$citytemplate, (BlockPos)null, p_191087_3_, p_191087_4_); }
private static boolean func_191088_b(TemplateManager p_191088_0_, StructureEndCityPieces.IGenerator p_191088_1_, int p_191088_2_, StructureEndCityPieces.CityTemplate p_191088_3_, BlockPos p_191088_4_, List<StructureComponent> p_191088_5_, Random p_191088_6_) { if (p_191088_2_ > 8) { return false; } else { List<StructureComponent> list = Lists.<StructureComponent>newArrayList(); if (p_191088_1_.func_191086_a(p_191088_0_, p_191088_2_, p_191088_3_, p_191088_4_, list, p_191088_6_)) { boolean flag = false; int i = p_191088_6_.nextInt(); for (StructureComponent structurecomponent : list) { structurecomponent.componentType = i; StructureComponent structurecomponent1 = StructureComponent.findIntersecting(p_191088_5_, structurecomponent.getBoundingBox()); if (structurecomponent1 != null && structurecomponent1.componentType != p_191088_3_.componentType) { flag = true; break; } } if (!flag) { p_191088_5_.addAll(list); return true; } } return false; } }
public CityTemplate(TemplateManager p_i47214_1_, String p_i47214_2_, BlockPos p_i47214_3_, Rotation p_i47214_4_, boolean p_i47214_5_) { super(0); this.pieceName = p_i47214_2_; this.templatePosition = p_i47214_3_; this.rotation = p_i47214_4_; this.overwrite = p_i47214_5_; this.func_191085_a(p_i47214_1_); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.pieceName = tagCompound.getString("Template"); this.rotation = Rotation.valueOf(tagCompound.getString("Rot")); this.overwrite = tagCompound.getBoolean("OW"); this.func_191085_a(p_143011_2_); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.leftLow = tagCompound.getBoolean("leftLow"); this.leftHigh = tagCompound.getBoolean("leftHigh"); this.rightLow = tagCompound.getBoolean("rightLow"); this.rightHigh = tagCompound.getBoolean("rightHigh"); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.hasRails = tagCompound.getBoolean("hr"); this.hasSpiders = tagCompound.getBoolean("sc"); this.spawnerPlaced = tagCompound.getBoolean("hps"); this.sectionCount = tagCompound.getInteger("Num"); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); NBTTagList nbttaglist = tagCompound.getTagList("Entrances", 11); for (int i = 0; i < nbttaglist.tagCount(); ++i) { this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.getIntArrayAt(i))); } }
public MansionTemplate(TemplateManager p_i47356_1_, String p_i47356_2_, BlockPos p_i47356_3_, Rotation p_i47356_4_, Mirror p_i47356_5_) { super(0); this.field_191082_d = p_i47356_2_; this.templatePosition = p_i47356_3_; this.field_191083_e = p_i47356_4_; this.field_191084_f = p_i47356_5_; this.func_191081_a(p_i47356_1_); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { super.readStructureFromNBT(tagCompound, p_143011_2_); this.field_191082_d = tagCompound.getString("Template"); this.field_191083_e = Rotation.valueOf(tagCompound.getString("Rot")); this.field_191084_f = Mirror.valueOf(tagCompound.getString("Mi")); this.func_191081_a(p_143011_2_); }
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_) { this.averageGroundLvl = tagCompound.getInteger("HPos"); this.villagersSpawned = tagCompound.getInteger("VCount"); this.structureType = tagCompound.getByte("Type"); if (tagCompound.getBoolean("Desert")) { this.structureType = 1; } this.isZombieInfested = tagCompound.getBoolean("Zombie"); }
public boolean generate(World worldIn, Random rand, BlockPos position) { Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; int i = random.nextInt(FOSSILS.length); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]); Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]); ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd()); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random); BlockPos blockpos = template.transformedSize(rotation); int j = random.nextInt(16 - blockpos.getX()); int k = random.nextInt(16 - blockpos.getZ()); int l = 256; for (int i1 = 0; i1 < blockpos.getX(); ++i1) { for (int j1 = 0; j1 < blockpos.getX(); ++j1) { l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k)); } } int k1 = Math.max(l - 15 - random.nextInt(10), 10); BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation); placementsettings.setIntegrity(0.9F); template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20); placementsettings.setIntegrity(0.1F); template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20); return true; }
public boolean isStructureLoadable() { if (this.mode == TileEntityStructure.Mode.LOAD && !this.world.isRemote) { WorldServer worldserver = (WorldServer)this.world; MinecraftServer minecraftserver = this.world.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); return templatemanager.get(minecraftserver, new ResourceLocation(this.name)) != null; } else { return false; } }
public boolean generate(World worldIn, Random rand, BlockPos position) { Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; int i = random.nextInt(FOSSILS.length); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]); Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]); ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd()); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random); BlockPos blockpos = template.transformedSize(rotation); int j = random.nextInt(16 - blockpos.getX()); int k = random.nextInt(16 - blockpos.getZ()); int l = 256; for (int i1 = 0; i1 < blockpos.getX(); ++i1) { for (int j1 = 0; j1 < blockpos.getX(); ++j1) { l = Math.min(l, worldIn.getHeightmapHeight(position.getX() + i1 + j, position.getZ() + j1 + k)); } } int k1 = Math.max(l - 15 - random.nextInt(10), 10); BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation); placementsettings.setIntegrity(0.9F); template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4); placementsettings.setIntegrity(0.1F); template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4); return true; }
public boolean isStructureLoadable() { if (this.mode == TileEntityStructure.Mode.LOAD && !this.worldObj.isRemote) { WorldServer worldserver = (WorldServer)this.worldObj; MinecraftServer minecraftserver = this.worldObj.getMinecraftServer(); TemplateManager templatemanager = worldserver.getStructureTemplateManager(); return templatemanager.get(minecraftserver, new ResourceLocation(this.name)) != null; } else { return false; } }
public CrystexiumSpikeStructure(TemplateManager manager, BlockPos blockPos, SpikeType type, int size) { super(0); this.type = type; this.size = size; this.templatePosition = blockPos; this.loadTemplate(manager); }
@Override public boolean generate(World world, Random rand, BlockPos position) { if (this.canSpawnUnderground(world, position, 2, 50)) { WorldServer server = (WorldServer) world; TemplateManager manager = server.getStructureTemplateManager(); procedurallyGenerate(manager, world, position, null, maxRooms); return true; } return false; }
private void procedurallyGenerate(TemplateManager manager, World world, BlockPos startingPos, ArrayList<PotentialPosition> potentialPositions, int maxRooms) { LostEclipse.LOGGER.info("Generating room " + roomCount + " out of " + maxRooms); ArrayList<PotentialPosition> nextPositions = potentialPositions; if (roomCount == maxRooms) { return; } else { if (roomCount == 0) { nextPositions = generateStartingRoom(manager, world, startingPos, maxRooms); } else { nextPositions = generateRooms(manager, world, potentialPositions, maxRooms); } } for (int i = 0; i < nextPositions.size(); i++) { if (nextPositions.get(i) == null) { nextPositions.remove(i); } } roomCount++; procedurallyGenerate(manager, world, startingPos, nextPositions, maxRooms); }
private Template getRandomizedDungeonTemplate(TemplateManager manager, World world) { ArrayList<Template> templates = new ArrayList<Template>(); templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "loot_room_1"))); templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "loot_room_2"))); templates.add(manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "loot_room_3"))); return templates.get((int) (Math.random() * (templates.size()))); }