• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Template类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Template类属于net.minecraft.world.gen.structure.template包,在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


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


示例17: translateWallPos

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
public static BlockPos translateWallPos(Template template, BlockPos wallPos, Rotation wallRotation)
{
	int x = wallPos.getX();
	int z = wallPos.getZ();
	
	if (wallRotation == Rotation.NONE) x += template.getSize().getX() / 2;
	else if (wallRotation == Rotation.CLOCKWISE_90) z += template.getSize().getZ() / 2;
	else if (wallRotation == Rotation.CLOCKWISE_180) x -= template.getSize().getX() / 2;
	else if (wallRotation == Rotation.COUNTERCLOCKWISE_90) z -= template.getSize().getZ() / 2;
	
	return new BlockPos(x, wallPos.getY(), z);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:13,代码来源:DungeonHelper.java


示例18: getStructureBoundingBox

import net.minecraft.world.gen.structure.template.Template; //导入依赖的package包/类
/** Returns the bounding box of the specific template. Used to make sure it doesn't intersect with other rooms. */
public static StructureBoundingBox getStructureBoundingBox(Template template, Rotation rotation, BlockPos center)
{
	int minX = 0;
	int maxX = 0; 
	int minY = 0;
	int maxY = 0;
	int minZ = 0;
	int maxZ = 0;
	
	// we offset everything by one to get the inner room with walls, ceilings, or floors. Rooms can connect through walls so we want those checks to pass.
	if (rotation == Rotation.NONE || rotation == Rotation.CLOCKWISE_180)
	{
		minX = center.getX() - (template.getSize().getX() / 2) - 1;
		maxX = center.getX() + (template.getSize().getX() / 2) - 1;
		minY = center.getY() + 1;
		maxY = center.getY() + template.getSize().getY() - 1;
		minZ = center.getZ() - (template.getSize().getZ() / 2) - 1;
		maxZ = center.getZ() + (template.getSize().getZ() / 2) - 1;
	}
	else
	{
		minX = center.getX() - (template.getSize().getZ() / 2) - 1;
		maxX = center.getX() + (template.getSize().getZ() / 2) - 1;
		minY = center.getY() + 1;
		maxY = center.getY() + template.getSize().getY() - 1;
		minZ = center.getZ() - (template.getSize().getX() / 2) - 1;
		maxZ = center.getZ() + (template.getSize().getX() / 2) - 1;
	}
	
	return new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:33,代码来源:DungeonHelper.java


示例19: getRandomizedDungeonTemplate

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


示例20: getStaircaseTemplate

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Trees类代码示例发布时间:2022-05-22
下一篇:
Java CGraphicsConfig类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap