本文整理汇总了Java中net.minecraft.world.gen.structure.template.TemplateManager.getTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateManager.getTemplate方法的具体用法?Java TemplateManager.getTemplate怎么用?Java TemplateManager.getTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.gen.structure.template.TemplateManager
的用法示例。
在下文中一共展示了TemplateManager.getTemplate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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;
}
示例2: generateOverworldStructures
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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());
}
}
}
}
示例3: save
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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;
}
}
示例4: save
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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;
}
}
示例5: generateStaircase
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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;
}
示例6: generate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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;
}
示例7: generate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的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;
}
示例8: load
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
public Template load(World world) {
TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
return manager.getTemplate(world.getMinecraftServer(), location);
}
示例9: addComponentParts
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
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;
}
}
示例10: func_191085_a
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
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);
}
示例11: func_191081_a
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
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);
}
示例12: addComponentParts
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
/**
* 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;
}
}
示例13: loadTemplate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
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);
}
示例14: loadTemplate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入方法依赖的package包/类
private void loadTemplate(TemplateManager p_191081_1_)
{
Template template = p_191081_1_.getTemplate((MinecraftServer)null, CrystalMod.resourceL("fusiontemple"));
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(Rotation.NONE).setReplacedBlock(Blocks.STRUCTURE_VOID);
this.setup(template, this.templatePosition, placementsettings);
}