Java 类net.minecraft.world.gen.structure.template.PlacementSettings 实例源码
项目:Loot-Slash-Conquer
文件:Dungeon.java
@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;
}
项目:TheOink
文件:OinkWorldGenerator.java
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());
}
}
}
}
项目:CustomWorldGen
文件:StructureEndCityPieces.java
private void loadAndSetup(BlockPos p_186180_1_)
{
Template template = StructureEndCityPieces.MANAGER.getTemplate((MinecraftServer)null, new ResourceLocation("endcity/" + this.pieceName));
PlacementSettings placementsettings;
if (this.overwrite)
{
placementsettings = StructureEndCityPieces.OVERWRITE.copy().setRotation(this.rotation);
}
else
{
placementsettings = StructureEndCityPieces.INSERT.copy().setRotation(this.rotation);
}
this.setup(template, p_186180_1_, placementsettings);
}
项目:muon
文件:MuonHooks.java
/**
* Inserted in addComponentParts in net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces$Igloo
*
* This modifies the blockpos passed to addBlocksToWorldChunk to keep the structure within the original bounding box.
*/
public static BlockPos fixRotationBlockPos(BlockPos bp, PlacementSettings ps, StructureComponent structure) {
StructureBoundingBox structurebb = structure.getBoundingBox();
EnumFacing facing = structure.getCoordBaseMode();
BlockPos newpos = bp;
switch (facing) {
case SOUTH:
ps.setRotation(Rotation.NONE);
newpos = new BlockPos(structurebb.minX, structurebb.minY, structurebb.minZ);
break;
case EAST:
ps.setRotation(Rotation.COUNTERCLOCKWISE_90);
newpos = new BlockPos(structurebb.minX, structurebb.minY, structurebb.maxZ);
break;
case NORTH:
ps.setRotation(Rotation.CLOCKWISE_180);
newpos = new BlockPos(structurebb.maxX, structurebb.minY, structurebb.maxZ);
break;
case WEST:
ps.setRotation(Rotation.CLOCKWISE_90);
newpos = new BlockPos(structurebb.maxX, structurebb.minY, structurebb.minZ);
break;
}
return newpos;
}
项目:Lost-Eclipse-Outdated
文件:ProceduralDungeonBase.java
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);
}
项目:enderutilities
文件:ItemBuildersWand.java
private PlacementSettings getPasteModePlacement(ItemStack stack, EntityPlayer player)
{
EnumFacing facing = this.getTemplateFacing(stack);
EnumFacing areaFacing = this.getAreaFacing(stack, Mode.PASTE);
if (areaFacing == null)
{
areaFacing = facing;
}
Rotation rotation = PositionUtils.getRotation(facing, areaFacing);
PlacementSettings placement = new PlacementSettings();
boolean ignoreEntities = player.capabilities.isCreativeMode == false ||
WandOption.AFFECT_ENTITIES.isEnabled(stack, Mode.PASTE) == false;
placement.setMirror(this.getMirror(stack));
placement.setRotation(rotation);
placement.setIgnoreEntities(ignoreEntities);
return placement;
}
项目:YUNoMakeGoodMap
文件:StructureLoader.java
@Override
public void generate(World world, BlockPos pos)
{
PlacementSettings settings = new PlacementSettings();
Template temp = null;
String suffix = world.provider.getDimensionType().getSuffix();
String opts = world.getWorldInfo().getGeneratorOptions() + suffix;
if (!Strings.isNullOrEmpty(opts))
temp = StructureUtil.loadTemplate(new ResourceLocation(opts), (WorldServer)world, true);
if (temp == null)
temp = StructureUtil.loadTemplate(new ResourceLocation("/config/", this.fileName + suffix), (WorldServer)world, !Strings.isNullOrEmpty(suffix));
if (temp == null)
return; //If we're not in the overworld, and we don't have a template...
BlockPos spawn = StructureUtil.findSpawn(temp, settings);
if (spawn != null)
{
pos = pos.subtract(spawn);
world.setSpawnPoint(pos);
}
temp.addBlocksToWorld(world, pos, settings, 0); //Push to world, with no neighbor notifications!
world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!
}
项目:Loot-Slash-Conquer
文件:Dungeon.java
/** 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;
}
项目:Loot-Slash-Conquer
文件:Dungeon.java
/** 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());
}
项目:Loot-Slash-Conquer
文件:DungeonBlockProcessor.java
public DungeonBlockProcessor(BlockPos pos, PlacementSettings settings)
{
this.chance = settings.getIntegrity();
this.random = settings.getRandom(pos);
this.outerBlock = null;
this.innerBlock = null;
}
项目:Loot-Slash-Conquer
文件:DungeonBlockProcessor.java
public DungeonBlockProcessor(BlockPos pos, PlacementSettings settings, Block outer, Block inner)
{
this.chance = settings.getIntegrity();
this.random = settings.getRandom(pos);
this.outerBlock = outer;
this.innerBlock = inner;
}
项目:harshencastle
文件:HarshenStructure.java
public void loadIntoWorld(World world, BlockPos pos, Random random, boolean useRuin)
{
if(world.isRemote)
return;
preAddition(world, pos, random);
HarshenTemplate.getTemplate(location).addBlocksToWorld(world, pos, new PlacementSettings().setIgnoreEntities(false).setIgnoreStructureBlock(true), random, useRuin);
postAddition(world, pos, random);
}
项目:harshencastle
文件:HarshenTemplate.java
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn)
{
Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap();
StructureBoundingBox structureboundingbox = placementIn.getBoundingBox();
for (Template.BlockInfo template$blockinfo : this.blocks)
{
BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos);
if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos))
{
IBlockState iblockstate = template$blockinfo.blockState;
if (iblockstate.getBlock() instanceof BlockStructure && template$blockinfo.tileentityData != null)
{
TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode"));
if (tileentitystructure$mode == TileEntityStructure.Mode.DATA)
{
map.put(blockpos, template$blockinfo.tileentityData.getString("metadata"));
}
}
}
}
return map;
}
项目:Solar
文件:ObeliskDecorator.java
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
random.setSeed(world.getSeed());
long good = random.nextLong();
long succ = random.nextLong();
good *= x >> 3;
succ *= z >> 3;
random.setSeed(good * succ * world.getSeed());
//Generate
if(GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity > 0D
&& GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity / 100D > random.nextDouble()) {
List<AxisAlignedBB> occupied = Lists.newArrayList();
for(int i = 0; i < GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.size; i++) {
BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 0, z).toBlockPos());
int below = random.nextInt(7);
if(top.getY() > below) {
top = top.add(0, -below, 0);
}
Template obelisk = obelisks.next().load(world);
Rotation rotation = Rotation.values()[random.nextInt(4)];
Vector3 vec = Vector3.create(obelisk.getSize()).rotate(rotation);
AxisAlignedBB obeliskBB = new AxisAlignedBB(top, vec.add(top).toBlockPos()).grow(1);
if(occupied.stream().noneMatch(bb -> bb.intersects(obeliskBB))) {
PlacementSettings settings = new PlacementSettings();
settings.setRotation(rotation);
settings.setRandom(random);
obelisk.addBlocksToWorld(world, top, settings);
occupied.add(obeliskBB);
}
}
}
}
项目:Solar
文件:AshenCubeStructure.java
private void genCubes(World world, BlockPos pos) {
//Gen Cube
BlockPos origin = pos.add(5, 0, 5);
Template template = Structure.ASHEN_CUBE.load(world);
boolean loot = GEN_CONFIG.ASHEN_CUBE_STRUCTURE.loot / 100D > random.nextDouble();
PlacementSettings integrity = new PlacementSettings();
integrity.setIntegrity(loot ? 1F : 0.35F + 0.45F * random.nextFloat());
template.addBlocksToWorld(world, origin, integrity);
integrity.setIntegrity(!loot && random.nextFloat() > 0.45F ? 1F : random.nextFloat());
Structure.ASHEN_CUBE_.generate(world, origin, integrity);
//Add loot
for (int i = 0; i < 6 + random.nextInt(6); i++) {
loot = GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.loot / 100D > random.nextDouble();
if (loot) {
BlockPos inside = origin.add(1 + random.nextInt(4), 1, 1 + random.nextInt(4));
IBlockState pot = ModBlocks.LARGE_POT.getDefaultState().withProperty(State.POT_VARIANT, random.nextInt(3));
world.setBlockState(inside, pot);
}
}
//Gen Cubes
AxisAlignedBB cubeBB = new AxisAlignedBB(origin, origin.add(template.getSize()));
for(int i = 0; i < GEN_CONFIG.ASHEN_CUBE_STRUCTURE.size; i++) {
Template cube = nuggets.next().load(world);
Rotation rotation = Rotation.values()[random.nextInt(4)];
Vector3 vec = Vector3.create(cube.getSize()).rotate(rotation);
BlockPos offset = randomVector().add(pos).toBlockPos();
if(offset.getY() < 1 || (world.canSeeSky(offset) && GEN_CONFIG.ASHEN_CUBE_STRUCTURE.underground)) continue;
AxisAlignedBB nuggetBB = new AxisAlignedBB(offset, vec.add(offset).toBlockPos());
if(!nuggetBB.intersects(cubeBB)) {
PlacementSettings settings = new PlacementSettings();
settings.setIntegrity(random.nextFloat() > 0.85F ? 0.9F : 0.35F + 0.45F * random.nextFloat());
settings.setRotation(rotation);
settings.setRandom(random);
cube.addBlocksToWorld(world, offset, settings);
}
}
}
项目:Backmemed
文件:StructureComponentTemplate.java
protected void setup(Template p_186173_1_, BlockPos p_186173_2_, PlacementSettings p_186173_3_)
{
this.template = p_186173_1_;
this.setCoordBaseMode(EnumFacing.NORTH);
this.templatePosition = p_186173_2_;
this.placeSettings = p_186173_3_;
this.setBoundingBoxFromTemplate();
}
项目:Backmemed
文件:WorldGenFossils.java
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;
}
项目:CustomWorldGen
文件:StructureComponentTemplate.java
protected void setup(Template p_186173_1_, BlockPos p_186173_2_, PlacementSettings p_186173_3_)
{
this.template = p_186173_1_;
this.setCoordBaseMode(EnumFacing.NORTH);
this.templatePosition = p_186173_2_;
this.placeSettings = p_186173_3_;
this.setBoundingBoxFromTemplate();
}
项目:CustomWorldGen
文件:WorldGenFossils.java
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;
}
项目:enderutilities
文件:ItemBuildersWand.java
private void moveAreaImmediate(ItemStack stack, World world, EntityPlayer player, BlockPos posSrc1, BlockPos posSrc2, BlockPos posDst1,
Mirror mirror, Rotation rotation)
{
PlacementSettings placement = new PlacementSettings();
placement.setMirror(mirror);
placement.setRotation(rotation);
placement.setIgnoreEntities(false);
placement.setReplacedBlock(Blocks.BARRIER); // meh
ReplaceMode replace = WandOption.REPLACE_EXISTING.isEnabled(stack, Mode.MOVE_DST) ? ReplaceMode.EVERYTHING : ReplaceMode.NOTHING;
TemplateEnderUtilities template = new TemplateEnderUtilities(placement, replace);
template.takeBlocksFromWorld(world, posSrc1, posSrc2.subtract(posSrc1), true, false);
this.deleteArea(stack, world, player, posSrc1, posSrc2, true);
template.addBlocksToWorld(world, posDst1);
}
项目:enderutilities
文件:ItemBuildersWand.java
private TemplateEnderUtilities getTemplate(World world, EntityPlayer player, ItemStack stack, PlacementSettings placement)
{
TemplateManagerEU templateManager = this.getTemplateManager();
ResourceLocation rl = this.getTemplateResource(stack, player);
TemplateEnderUtilities template = templateManager.getTemplate(rl);
template.setPlacementSettings(placement);
return template;
}
项目:YUNoMakeGoodMap
文件:StructureUtil.java
public static BlockPos findSpawn(Template temp, PlacementSettings settings)
{
for (Entry<BlockPos, String> e : temp.getDataBlocks(new BlockPos(0,0,0), settings).entrySet())
{
if ("SPAWN_POINT".equals(e.getValue()))
return e.getKey();
}
return null;
}
项目:YUNoMakeGoodMap
文件:NewSpawnPlatformCommand.java
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length != 2)
throw new WrongUsageException(getUsage(sender));
EntityPlayer player = getPlayer(server, sender, args[1]);
if (player != null)
{
PlacementSettings settings = new PlacementSettings();
WorldServer world = (WorldServer) sender.getEntityWorld();
int platformNumber = SpawnPlatformSavedData.get(world).addAndGetPlatformNumber();
BlockPos pos = getPositionOfPlatform(world, platformNumber);
Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[0]), world, true);
BlockPos spawn = StructureUtil.findSpawn(temp, settings);
spawn = spawn == null ? pos : spawn.add(pos);
sender.sendMessage(new TextComponentString("Building \"" + args[0] + "\" at " + pos.toString()));
temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications!
world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).setPositionAndUpdate(spawn.getX() + 0.5, spawn.getY() + 1.6, spawn.getZ() + 0.5);
}
player.setSpawnChunk(spawn, true, world.provider.getDimension());
}
else
{
throw new WrongUsageException(getUsage(sender));
}
}
项目:harshencastle
文件:HarshenStructure.java
@Override
public void addToWorld(World world, BlockPos pos, Random random, boolean useRuin) {
HarshenTemplate.getTemplate(location).addBlocksToWorld(world, pos, new PlacementSettings().setIgnoreEntities(false).setIgnoreStructureBlock(true), random, useRuin);
}
项目:harshencastle
文件:HarshenTemplate.java
public BlockPos calculateConnectedPos(PlacementSettings placementIn, BlockPos p_186262_2_, PlacementSettings p_186262_3_, BlockPos p_186262_4_)
{
BlockPos blockpos = transformedBlockPos(placementIn, p_186262_2_);
BlockPos blockpos1 = transformedBlockPos(p_186262_3_, p_186262_4_);
return blockpos.subtract(blockpos1);
}
项目:harshencastle
文件:HarshenTemplate.java
public static BlockPos transformedBlockPos(PlacementSettings placementIn, BlockPos pos)
{
return transformedBlockPos(pos, placementIn.getMirror(), placementIn.getRotation());
}
项目:harshencastle
文件:HarshenTemplate.java
public void addBlocksToWorldChunk(World worldIn, BlockPos pos, PlacementSettings placementIn, Random rand, boolean useRuin)
{
placementIn.setBoundingBox(null);
placementIn.getBoundingBox();
this.addBlocksToWorld(worldIn, pos, placementIn, rand, useRuin);
}
项目:harshencastle
文件:HarshenTemplate.java
/**
* This takes the data stored in this instance and puts them into the world.
*/
public void addBlocksToWorld(World worldIn, BlockPos pos, PlacementSettings placementIn, Random rand, boolean useRuin)
{
this.addBlocksToWorld(worldIn, pos, new BlockRotationProcessor(pos, placementIn), placementIn, 2, rand, useRuin);
}
项目:harshencastle
文件:HarshenTemplate.java
/**
* This takes the data stored in this instance and puts them into the world.
*/
public void addBlocksToWorld(World worldIn, BlockPos pos, PlacementSettings placementIn, int flags, Random rand, boolean useRuin)
{
this.addBlocksToWorld(worldIn, pos, new BlockRotationProcessor(pos, placementIn), placementIn, flags, rand, useRuin);
}
项目:Infernum
文件:PigmanMageTowerGenerator.java
public void generateTower(WorldServer world, BlockPos pos, Random rand) {
MinecraftServer server = world.getMinecraftServer();
Template template = world.getStructureTemplateManager().getTemplate(server, TOWER_STRUCTURE);
PlacementSettings settings = new PlacementSettings();
settings.setRotation(Rotation.values()[rand.nextInt(Rotation.values().length)]);
BlockPos size = template.getSize();
int airBlocks = 0;
for(int x = 0; x < size.getX(); x++) {
for (int z = 0; z < size.getZ(); z++) {
if (world.isAirBlock(pos.add(template.transformedBlockPos(settings, new BlockPos(x, 0, z))))) {
airBlocks++;
if (airBlocks > 0.33 * (size.getX() * size.getZ())) {
return;
}
}
}
}
for (int x = 0; x < size.getX(); x++) {
for (int z = 0; z < size.getZ(); z++) {
if (x == 0 || x == size.getX() - 1 || z == 0 || z == size.getZ() - 1) {
for (int y = 0; y < size.getY(); y++) {
BlockPos checkPos = pos.add(template.transformedBlockPos(settings, new BlockPos(x, y, z)));
IBlockState checkState = world.getBlockState(checkPos);
if (!checkState.getBlock().isAir(checkState, world, checkPos)) {
if (!(y <= 3 && (checkState.getBlock() == Blocks.NETHERRACK || checkState.getBlock() == Blocks.QUARTZ_ORE || checkState.getBlock() == Blocks.MAGMA))) {
return;
}
}
}
}
}
}
template.addBlocksToWorld(world, pos, settings);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
for (Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
String[] tokens = entry.getValue().split(" ");
if (tokens.length == 0)
return;
BlockPos dataPos = entry.getKey();
EntityPigMage pigMage;
switch (tokens[0]) {
case "pigman_mage":
pigMage = new EntityPigMage(world);
pigMage.setPosition(dataPos.getX() + 0.5, dataPos.getY(), dataPos.getZ() + 0.5);
pigMage.onInitialSpawn(world.getDifficultyForLocation(dataPos), null);
world.spawnEntity(pigMage);
break;
case "fortress_chest":
IBlockState chestState = Blocks.CHEST.getDefaultState().withRotation(settings.getRotation());
chestState = chestState.withMirror(Mirror.FRONT_BACK);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(NETHER_BRIDGE_LOOT_TABLE, rand.nextLong());
break;
}
}
}
项目:Infernum
文件:InfernalMonumentGenerator.java
public void generateMonument(WorldServer world, BlockPos pos, Random rand) {
MinecraftServer server = world.getMinecraftServer();
Template template = world.getStructureTemplateManager().getTemplate(server, MONUMENT_STRUCTURE);
PlacementSettings settings = new PlacementSettings();
settings.setRotation(Rotation.values()[rand.nextInt(Rotation.values().length)]);
BlockPos size = template.getSize();
int airBlocks = 0;
for(int x = 0; x < size.getX(); x++) {
for (int z = 0; z < size.getZ(); z++) {
if (world.isAirBlock(pos.add(template.transformedBlockPos(settings, new BlockPos(x, -1, z))))) {
airBlocks++;
if (airBlocks > 0.33 * (size.getX() * size.getZ())) {
return;
}
}
}
}
for (int x = 0; x < size.getX(); x++) {
for (int z = 0; z < size.getZ(); z++) {
if (x == 0 || x == size.getX() - 1 || z == 0 || z == size.getZ() - 1) {
for (int y = 0; y < size.getY(); y++) {
BlockPos checkPos = pos.add(template.transformedBlockPos(settings, new BlockPos(x, y, z)));
IBlockState checkState = world.getBlockState(checkPos);
if (!checkState.getBlock().isAir(checkState, world, checkPos)) {
if (!(y <= 0 && (checkState.getBlock() == Blocks.NETHERRACK || checkState.getBlock() == Blocks.QUARTZ_ORE || checkState.getBlock() == Blocks.MAGMA))) {
return;
}
}
}
}
}
}
template.addBlocksToWorld(world, pos, settings);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
for (Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
String[] tokens = entry.getValue().split(" ");
if (tokens.length == 0)
return;
BlockPos dataPos = entry.getKey();
if (tokens[0].equals("pedestal")) {
IBlockState chestState = InfernumBlocks.PEDESTAL.getDefaultState();
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile instanceof TilePedestal) {
((TilePedestal) tile).setStack(new ItemStack(InfernumItems.KNOWLEDGE_BOOK));
}
}
}
}
项目:Solar
文件:ModGen.java
public void generate(World world, BlockPos pos, PlacementSettings settings) {
Template template = load(world);
template.addBlocksToWorld(world, pos, settings);
}
项目:Solar
文件:MonolithStructure.java
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
random.setSeed(world.getSeed());
long good = random.nextLong();
long succ = random.nextLong();
good *= x >> 2;
succ *= z >> 2;
random.setSeed(good * succ ^ world.getSeed());
//Generate
if (GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.rarity > 0D
&& GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.rarity / 100D > random.nextDouble()) {
BlockPos origin = new BlockPos(x, 0, z);
//Gen Monolith
BlockPos surface = world.getTopSolidOrLiquidBlock(origin.add(8, 0, 8));
BlockPos pos = origin.add(5, Math.max(surface.getY() - (5 + random.nextInt(3)), 8), 4);
Structure.MONOLITH_CUBE.generate(world, pos.down(7), new PlacementSettings());
//Randomize glyphs
Vector3 start = Vector3.create(pos).add(0,-4,6);
Arrays.stream(EnumFacing.HORIZONTALS).forEach(facing -> {
for (int i = 0; i < 6; i++) {
IBlockState glyph = ModBlocks.MONOLITHIC_GLYPH.getDefaultState().withProperty(State.GLYPH, random.nextInt(16));
world.setBlockState(start.toBlockPos(), glyph);
start.offset(facing.getOpposite(), 1);
}
});
//Add loot
BlockPos loot = pos.down(7).add(1, 1, 1);
for (int i = 0; i < 6 + random.nextInt(6); i++) {
if (GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.loot / 100D > random.nextDouble()) {
BlockPos inside = loot.add(random.nextInt(4), 0, random.nextInt(4));
IBlockState pot = ModBlocks.LARGE_POT.getDefaultState().withProperty(State.POT_VARIANT, random.nextInt(3));
world.setBlockState(inside, pot);
}
}
//Gen ruin
if (GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.well) {
Structure.MONOLITH_RUIN.generate(world, pos, new PlacementSettings());
}
int size = random.nextInt(GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.size / 2);
size += GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.size / 2;
for (int i = 0; i < size; i++) {
BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 1, z).toBlockPos());
int below = random.nextInt(3);
if (top.getY() > below) {
top = top.add(0, -below, 0);
}
world.setBlockState(top, ModBlocks.ASHEN.getDefaultState());
}
}
}
项目:Backmemed
文件:ComponentScatteredFeaturePieces.java
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
{
if (!this.offsetToAverageGroundLevel(worldIn, structureBoundingBoxIn, -1))
{
return false;
}
else
{
StructureBoundingBox structureboundingbox = this.getBoundingBox();
BlockPos blockpos = new BlockPos(structureboundingbox.minX, structureboundingbox.minY, structureboundingbox.minZ);
Rotation[] arotation = Rotation.values();
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(arotation[randomIn.nextInt(arotation.length)]).setReplacedBlock(Blocks.STRUCTURE_VOID).setBoundingBox(structureboundingbox);
Template template = templatemanager.getTemplate(minecraftserver, IGLOO_TOP_ID);
template.addBlocksToWorldChunk(worldIn, blockpos, placementsettings);
if (randomIn.nextDouble() < 0.5D)
{
Template template1 = templatemanager.getTemplate(minecraftserver, IGLOO_MIDDLE_ID);
Template template2 = templatemanager.getTemplate(minecraftserver, IGLOO_BOTTOM_ID);
int i = randomIn.nextInt(8) + 4;
for (int j = 0; j < i; ++j)
{
BlockPos blockpos1 = template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - j * 3, 5), placementsettings, new BlockPos(1, 2, 1));
template1.addBlocksToWorldChunk(worldIn, blockpos.add(blockpos1), placementsettings);
}
BlockPos blockpos4 = blockpos.add(template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - i * 3, 5), placementsettings, new BlockPos(3, 5, 7)));
template2.addBlocksToWorldChunk(worldIn, blockpos4, placementsettings);
Map<BlockPos, String> map = template2.getDataBlocks(blockpos4, placementsettings);
for (Entry<BlockPos, String> entry : map.entrySet())
{
if ("chest".equals(entry.getValue()))
{
BlockPos blockpos2 = (BlockPos)entry.getKey();
worldIn.setBlockState(blockpos2, Blocks.AIR.getDefaultState(), 3);
TileEntity tileentity = worldIn.getTileEntity(blockpos2.down());
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setLootTable(LootTableList.CHESTS_IGLOO_CHEST, randomIn.nextLong());
}
}
}
}
else
{
BlockPos blockpos3 = Template.transformedBlockPos(placementsettings, new BlockPos(3, 0, 5));
worldIn.setBlockState(blockpos.add(blockpos3), Blocks.SNOW.getDefaultState(), 3);
}
return true;
}
}
项目:Backmemed
文件:StructureEndCityPieces.java
private void func_191085_a(TemplateManager p_191085_1_)
{
Template template = p_191085_1_.getTemplate((MinecraftServer)null, new ResourceLocation("endcity/" + this.pieceName));
PlacementSettings placementsettings = (this.overwrite ? StructureEndCityPieces.OVERWRITE : StructureEndCityPieces.INSERT).copy().setRotation(this.rotation);
this.setup(template, this.templatePosition, placementsettings);
}
项目:Backmemed
文件:WoodlandMansionPieces.java
private void func_191081_a(TemplateManager p_191081_1_)
{
Template template = p_191081_1_.getTemplate((MinecraftServer)null, new ResourceLocation("mansion/" + this.field_191082_d));
PlacementSettings placementsettings = (new PlacementSettings()).setIgnoreEntities(true).setRotation(this.field_191083_e).setMirror(this.field_191084_f);
this.setup(template, this.templatePosition, placementsettings);
}
项目:Backmemed
文件:TileEntityStructure.java
public boolean load(boolean p_189714_1_)
{
if (this.mode == TileEntityStructure.Mode.LOAD && !this.world.isRemote && !StringUtils.isNullOrEmpty(this.name))
{
BlockPos blockpos = this.getPos();
BlockPos blockpos1 = blockpos.add(this.position);
WorldServer worldserver = (WorldServer)this.world;
MinecraftServer minecraftserver = this.world.getMinecraftServer();
TemplateManager templatemanager = worldserver.getStructureTemplateManager();
Template template = templatemanager.get(minecraftserver, new ResourceLocation(this.name));
if (template == null)
{
return false;
}
else
{
if (!StringUtils.isNullOrEmpty(template.getAuthor()))
{
this.author = template.getAuthor();
}
BlockPos blockpos2 = template.getSize();
boolean flag = this.size.equals(blockpos2);
if (!flag)
{
this.size = blockpos2;
this.markDirty();
IBlockState iblockstate = this.world.getBlockState(blockpos);
this.world.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 3);
}
if (p_189714_1_ && !flag)
{
return false;
}
else
{
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(this.mirror).setRotation(this.rotation).setIgnoreEntities(this.ignoreEntities).setChunk((ChunkPos)null).setReplacedBlock((Block)null).setIgnoreStructureBlock(false);
if (this.integrity < 1.0F)
{
placementsettings.setIntegrity(MathHelper.clamp(this.integrity, 0.0F, 1.0F)).setSeed(Long.valueOf(this.seed));
}
template.addBlocksToWorldChunk(this.world, blockpos1, placementsettings);
return true;
}
}
}
else
{
return false;
}
}
项目:CustomWorldGen
文件:ComponentScatteredFeaturePieces.java
/**
* second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
* Mineshafts at the end, it adds Fences...
*/
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
{
if (!this.offsetToAverageGroundLevel(worldIn, structureBoundingBoxIn, -1))
{
return false;
}
else
{
StructureBoundingBox structureboundingbox = this.getBoundingBox();
BlockPos blockpos = new BlockPos(structureboundingbox.minX, structureboundingbox.minY, structureboundingbox.minZ);
Rotation[] arotation = Rotation.values();
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(arotation[randomIn.nextInt(arotation.length)]).setReplacedBlock(Blocks.STRUCTURE_VOID).setBoundingBox(structureboundingbox);
Template template = templatemanager.getTemplate(minecraftserver, IGLOO_TOP_ID);
template.addBlocksToWorldChunk(worldIn, blockpos, placementsettings);
if (randomIn.nextDouble() < 0.5D)
{
Template template1 = templatemanager.getTemplate(minecraftserver, IGLOO_MIDDLE_ID);
Template template2 = templatemanager.getTemplate(minecraftserver, IGLOO_BOTTOM_ID);
int i = randomIn.nextInt(8) + 4;
for (int j = 0; j < i; ++j)
{
BlockPos blockpos1 = template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - j * 3, 5), placementsettings, new BlockPos(1, 2, 1));
template1.addBlocksToWorldChunk(worldIn, blockpos.add(blockpos1), placementsettings);
}
BlockPos blockpos4 = blockpos.add(template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - i * 3, 5), placementsettings, new BlockPos(3, 5, 7)));
template2.addBlocksToWorldChunk(worldIn, blockpos4, placementsettings);
Map<BlockPos, String> map = template2.getDataBlocks(blockpos4, placementsettings);
for (Entry<BlockPos, String> entry : map.entrySet())
{
if ("chest".equals(entry.getValue()))
{
BlockPos blockpos2 = (BlockPos)entry.getKey();
worldIn.setBlockState(blockpos2, Blocks.AIR.getDefaultState(), 3);
TileEntity tileentity = worldIn.getTileEntity(blockpos2.down());
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setLootTable(LootTableList.CHESTS_IGLOO_CHEST, randomIn.nextLong());
}
}
}
}
else
{
BlockPos blockpos3 = Template.transformedBlockPos(placementsettings, new BlockPos(3, 0, 5));
worldIn.setBlockState(blockpos.add(blockpos3), Blocks.SNOW.getDefaultState(), 3);
}
return true;
}
}
项目:CustomWorldGen
文件:TileEntityStructure.java
public boolean load(boolean p_189714_1_)
{
if (this.mode == TileEntityStructure.Mode.LOAD && !this.worldObj.isRemote && !StringUtils.isNullOrEmpty(this.name))
{
BlockPos blockpos = this.getPos();
BlockPos blockpos1 = blockpos.add(this.position);
WorldServer worldserver = (WorldServer)this.worldObj;
MinecraftServer minecraftserver = this.worldObj.getMinecraftServer();
TemplateManager templatemanager = worldserver.getStructureTemplateManager();
Template template = templatemanager.get(minecraftserver, new ResourceLocation(this.name));
if (template == null)
{
return false;
}
else
{
if (!StringUtils.isNullOrEmpty(template.getAuthor()))
{
this.author = template.getAuthor();
}
BlockPos blockpos2 = template.getSize();
boolean flag = this.size.equals(blockpos2);
if (!flag)
{
this.size = blockpos2;
this.markDirty();
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
this.worldObj.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 3);
}
if (p_189714_1_ && !flag)
{
return false;
}
else
{
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(this.mirror).setRotation(this.rotation).setIgnoreEntities(this.ignoreEntities).setChunk((ChunkPos)null).setReplacedBlock((Block)null).setIgnoreStructureBlock(false);
if (this.integrity < 1.0F)
{
placementsettings.setIntegrity(MathHelper.clamp_float(this.integrity, 0.0F, 1.0F)).setSeed(Long.valueOf(this.seed));
}
template.addBlocksToWorldChunk(this.worldObj, blockpos1, placementsettings);
return true;
}
}
}
else
{
return false;
}
}
项目:CrystalMod
文件:CrystexiumSpikeStructure.java
private void loadTemplate(TemplateManager p_191081_1_)
{
Template template = p_191081_1_.getTemplate((MinecraftServer)null, CrystalMod.resourceL("crystex/spike_"+size));
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(Rotation.NONE).setReplacedBlock(Blocks.AIR);
this.setup(template, this.templatePosition, placementsettings);
}