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


Java Template类代码示例

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


Template类属于net.minecraft.world.gen.structure.template包,在下文中一共展示了Template类的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: generatePotentialRooms

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

示例3: processBlock

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
@Nullable
public Template.BlockInfo processBlock(World world, BlockPos pos, Template.BlockInfo blockInfo)
{
	Template.BlockInfo newBlockInfo;
	
    //if (blockInfo.blockState.getBlock() == ModBlocks.DUNGEON_BRICK)
    //{
    //	newBlockInfo = new Template.BlockInfo(pos, Blocks.PLANKS.getDefaultState(), blockInfo.tileentityData);
    //}
    //else
    //{
    	newBlockInfo = blockInfo;
    //}
	
	return this.chance < 1.0F && this.random.nextFloat() > this.chance ? null : newBlockInfo;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:17,代码来源:DungeonBlockProcessor.java

示例4: 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

示例5: save

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

示例6: loadAndSetup

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

示例7: save

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

示例8: 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

示例9: getHallwayPosition

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
protected BlockPos getHallwayPosition(Template template, BlockPos roomCenter, Rotation rotation)
{
	int x = roomCenter.getX();
	int z = roomCenter.getZ();
	
	switch (rotation)
	{
		case NONE:
			x += template.getSize().getX() - 1;
			break;
		case CLOCKWISE_90:
			z += template.getSize().getX() - 1;
			break;
		case CLOCKWISE_180:
			x -= template.getSize().getX() - 1;
			break;
		case COUNTERCLOCKWISE_90:
			z -= template.getSize().getX() - 1;
			break;
	}
	
	return new BlockPos(x, roomCenter.getY(), z);
}
 
开发者ID:TheXFactor117,项目名称:Lost-Eclipse-Outdated,代码行数:24,代码来源:ProceduralDungeonBase.java

示例10: getRoomPosition

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
protected BlockPos getRoomPosition(Template template, BlockPos hallwayCenter, Rotation rotation)
{
	int x = hallwayCenter.getX();
	int z = hallwayCenter.getZ();
	
	switch (rotation)
	{
		case NONE:
			x += template.getSize().getX() - 1;
			break;
		case CLOCKWISE_90:
			z += template.getSize().getZ() - 1;
			break;
		case CLOCKWISE_180:
			x -= template.getSize().getX() - 1;
			break;
		case COUNTERCLOCKWISE_90:
			z -= template.getSize().getZ() - 1;
			break;
	}
	
	return new BlockPos(x, hallwayCenter.getY(), z);
}
 
开发者ID:TheXFactor117,项目名称:Lost-Eclipse-Outdated,代码行数:24,代码来源:ProceduralDungeonBase.java

示例11: loadTemplate

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
private static Template loadTemplate(InputStream is)
{
    if (is == null)
        return null;
    try
    {
        NBTTagCompound nbt = CompressedStreamTools.readCompressed(is);
        Template template = new Template();
        template.read(nbt);
        return template;
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    finally
    {
        if (is != null)
            IOUtils.closeQuietly(is);
    }
    return null;
}
 
开发者ID:LexManos,项目名称:YUNoMakeGoodMap,代码行数:23,代码来源:StructureUtil.java

示例12: 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

示例13: canSpawnHere

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
public static boolean canSpawnHere(Template template, World world, BlockPos posAboveGround)
{
	int zwidth = template.getSize().getZ();
	int xwidth = template.getSize().getX();
	
	// check all the corners to see which ones are replaceable
	boolean corner1 = isCornerValid(world, posAboveGround);
	boolean corner2 = isCornerValid(world, posAboveGround.add(xwidth, 0, zwidth));
	
	// if Y > 20 and all corners pass the test, it's okay to spawn the structure
	return posAboveGround.getY() > 63 && corner1 && corner2;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:13,代码来源:LSCWorldGenerator.java

示例14: DungeonRoomPosition

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
public DungeonRoomPosition(BlockPos pos, Template template, Rotation templateRotation, Rotation side, StructureBoundingBox boundingBox)
{
	this.pos = pos;
	this.template = template;
	this.templateRotation = templateRotation;
	this.side = side;
	this.boundingBox = boundingBox;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:9,代码来源:DungeonRoomPosition.java

示例15: 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


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