当前位置: 首页>>代码示例>>Java>>正文


Java Template.addBlocksToWorld方法代码示例

本文整理汇总了Java中net.minecraft.world.gen.structure.template.Template.addBlocksToWorld方法的典型用法代码示例。如果您正苦于以下问题:Java Template.addBlocksToWorld方法的具体用法?Java Template.addBlocksToWorld怎么用?Java Template.addBlocksToWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.world.gen.structure.template.Template的用法示例。


在下文中一共展示了Template.addBlocksToWorld方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generate

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
@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;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:26,代码来源:Dungeon.java

示例2: generateOverworldStructures

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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());
                }
            }
        }
    }
 
开发者ID:OCDiary,项目名称:TheOink,代码行数:23,代码来源:OinkWorldGenerator.java

示例3: generateHallway

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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);
}
 
开发者ID:TheXFactor117,项目名称:Lost-Eclipse-Outdated,代码行数:22,代码来源:ProceduralDungeonBase.java

示例4: generate

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
@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!
}
 
开发者ID:LexManos,项目名称:YUNoMakeGoodMap,代码行数:26,代码来源:StructureLoader.java

示例5: generateStaircase

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
/** 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;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:32,代码来源:Dungeon.java

示例6: generateRoom

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
/** 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());
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:16,代码来源:Dungeon.java

示例7: gen

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:35,代码来源:ObeliskDecorator.java

示例8: genCubes

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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);
		}
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:38,代码来源:AshenCubeStructure.java

示例9: generate

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:35,代码来源:WorldGenFossils.java

示例10: generate

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:35,代码来源:WorldGenFossils.java

示例11: execute

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:LexManos,项目名称:YUNoMakeGoodMap,代码行数:36,代码来源:NewSpawnPlatformCommand.java

示例12: generateTower

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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;
		}
	}

}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:65,代码来源:PigmanMageTowerGenerator.java

示例13: generateMonument

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
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));
			}
		}

	}

}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:57,代码来源:InfernalMonumentGenerator.java

示例14: generate

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
public void generate(World world, BlockPos pos, PlacementSettings settings) {
	Template template = load(world);
	template.addBlocksToWorld(world, pos, settings);
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:5,代码来源:ModGen.java

示例15: generateRandomRoom

import net.minecraft.world.gen.structure.template.Template; //导入方法依赖的package包/类
private ArrayList<PotentialPosition> generateRandomRoom(TemplateManager manager, World world, BlockPos center, Rotation rotation)
{
	// if there is a room at a potential position, return.
	for (int i = 0; i < roomPositions.size(); i++)
	{
		if (center.equals(roomPositions.get(i)))
		{
			LostEclipse.LOGGER.info("Room and potential position matched.");
			return null;
		}
	}
	
	// settings and such
	PlacementSettings settings = new PlacementSettings().setRotation(rotation);
	Template template = getRandomizedDungeonTemplate(manager, world);
	
	// add blocks (and handle any data blocks)
	BlockPos corner = translateToCorner(template, center, rotation); // translate from center to corner
	template.addBlocksToWorld(world, corner, settings); // spawn in template at corner pos
	handleDataBlocks(template, world, corner, settings); // update chest contents
	roomPositions.add(center); // add template position to array
	
	ArrayList<PotentialPosition> potentialPositions = new ArrayList<PotentialPosition>();
	
	int hallways = (int) (Math.random() * 3 + 1);
	LostEclipse.LOGGER.info("Hallways: " + hallways);
	
	for (int i = 1; i <= hallways; i++)
	{
		boolean none = false;
		boolean clockwise = false;
		boolean clockwise180 = false;
		boolean counterclockwise = false;
		
		Rotation hallwayRotation = Rotation.values()[(int) (Math.random() * 4)];
		LostEclipse.LOGGER.info("Hallway Rotation: " + hallwayRotation);
		
		switch (hallwayRotation)
		{
			case NONE:
				if (!none) potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				else potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				none = true;
				break;
			case CLOCKWISE_90:
				if (!clockwise) potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				else potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				clockwise = true;
				break;
			case CLOCKWISE_180:
				if (!clockwise180) potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				else potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				clockwise180 = true;
				break;
			case COUNTERCLOCKWISE_90:
				if (!counterclockwise) potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				else potentialPositions.add(generateHallway(manager, world, center, hallwayRotation));
				counterclockwise = true;
				break;
		}
	}
	
	for (int i = 0; i < potentialPositions.size(); i++)
	{
		if (potentialPositions.get(i) == null)
			potentialPositions.remove(i);
	}
	
	return potentialPositions;
}
 
开发者ID:TheXFactor117,项目名称:Lost-Eclipse-Outdated,代码行数:71,代码来源:ProceduralDungeonBase.java


注:本文中的net.minecraft.world.gen.structure.template.Template.addBlocksToWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。