本文整理汇总了Java中net.minecraft.world.gen.structure.template.TemplateManager类的典型用法代码示例。如果您正苦于以下问题:Java TemplateManager类的具体用法?Java TemplateManager怎么用?Java TemplateManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TemplateManager类属于net.minecraft.world.gen.structure.template包,在下文中一共展示了TemplateManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: generatePotentialRooms
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的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;
}
示例3: 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());
}
}
}
}
示例4: func_191086_a
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的package包/类
public boolean func_191086_a(TemplateManager p_191086_1_, int p_191086_2_, StructureEndCityPieces.CityTemplate p_191086_3_, BlockPos p_191086_4_, List<StructureComponent> p_191086_5_, Random p_191086_6_)
{
Rotation rotation = p_191086_3_.placeSettings.getRotation();
StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, p_191086_3_, new BlockPos(-3, 4, -3), "fat_tower_base", rotation, true));
structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(0, 4, 0), "fat_tower_middle", rotation, true));
for (int i = 0; i < 2 && p_191086_6_.nextInt(3) != 0; ++i)
{
structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(0, 8, 0), "fat_tower_middle", rotation, true));
for (Tuple<Rotation, BlockPos> tuple : StructureEndCityPieces.FAT_TOWER_BRIDGES)
{
if (p_191086_6_.nextBoolean())
{
StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate1 = StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, (BlockPos)tuple.getSecond(), "bridge_end", rotation.add((Rotation)tuple.getFirst()), true));
StructureEndCityPieces.func_191088_b(p_191086_1_, StructureEndCityPieces.TOWER_BRIDGE_GENERATOR, p_191086_2_ + 1, structureendcitypieces$citytemplate1, (BlockPos)null, p_191086_5_, p_191086_6_);
}
}
}
StructureEndCityPieces.func_189935_b(p_191086_5_, StructureEndCityPieces.func_191090_b(p_191086_1_, structureendcitypieces$citytemplate, new BlockPos(-2, 8, -2), "fat_tower_top", rotation, true));
return true;
}
示例5: readStructureFromNBT
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的package包/类
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_)
{
super.readStructureFromNBT(tagCompound, p_143011_2_);
this.cropTypeA = Block.getBlockById(tagCompound.getInteger("CA"));
this.cropTypeB = Block.getBlockById(tagCompound.getInteger("CB"));
this.cropTypeC = Block.getBlockById(tagCompound.getInteger("CC"));
this.cropTypeD = Block.getBlockById(tagCompound.getInteger("CD"));
if (!(this.cropTypeA instanceof BlockCrops))
{
this.cropTypeA = Blocks.WHEAT;
}
if (!(this.cropTypeB instanceof BlockCrops))
{
this.cropTypeB = Blocks.CARROTS;
}
if (!(this.cropTypeC instanceof BlockCrops))
{
this.cropTypeC = Blocks.POTATOES;
}
if (!(this.cropTypeD instanceof BlockCrops))
{
this.cropTypeD = Blocks.BEETROOTS;
}
}
示例6: SaveHandler
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的package包/类
public SaveHandler(File p_i46648_1_, String saveDirectoryNameIn, boolean p_i46648_3_, DataFixer dataFixerIn)
{
this.dataFixer = dataFixerIn;
this.worldDirectory = new File(p_i46648_1_, saveDirectoryNameIn);
this.worldDirectory.mkdirs();
this.playersDirectory = new File(this.worldDirectory, "playerdata");
this.mapDataDir = new File(this.worldDirectory, "data");
this.mapDataDir.mkdirs();
this.saveDirectoryName = saveDirectoryNameIn;
if (p_i46648_3_)
{
this.playersDirectory.mkdirs();
this.structureTemplateManager = new TemplateManager((new File(this.worldDirectory, "structures")).toString(), dataFixerIn);
}
else
{
this.structureTemplateManager = null;
}
this.setSessionLock();
}
示例7: 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;
}
}
示例8: SaveHandler
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的package包/类
public SaveHandler(File p_i46648_1_, String saveDirectoryNameIn, boolean p_i46648_3_, DataFixer dataFixerIn)
{
this.dataFixer = dataFixerIn;
this.worldDirectory = new File(p_i46648_1_, saveDirectoryNameIn);
this.worldDirectory.mkdirs();
this.playersDirectory = new File(this.worldDirectory, "playerdata");
this.mapDataDir = new File(this.worldDirectory, "data");
this.mapDataDir.mkdirs();
this.saveDirectoryName = saveDirectoryNameIn;
if (p_i46648_3_)
{
this.playersDirectory.mkdirs();
this.structureTemplateManager = new TemplateManager((new File(this.worldDirectory, "structures")).toString());
}
else
{
this.structureTemplateManager = null;
}
this.setSessionLock();
}
示例9: 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;
}
}
示例10: generateRooms
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的package包/类
public ArrayList<PotentialPosition> generateRooms(TemplateManager manager, World world, ArrayList<PotentialPosition> potentialPositions, int roomCount)
{
LostEclipse.LOGGER.info("Potential size: " + potentialPositions.size());
ArrayList<PotentialPosition> nextPotentialPositions = new ArrayList<PotentialPosition>();
for (int i = 0; i < potentialPositions.size(); i++)
{
BlockPos center = potentialPositions.get(i).getPos();
Rotation rotation = potentialPositions.get(i).getRotation();
LostEclipse.LOGGER.info("Generating randomized rooms off of hallways.");
ArrayList<PotentialPosition> nextPositions = generateRandomRoom(manager, world, center, rotation);
if (nextPositions != null)
{
for (PotentialPosition position : nextPositions)
{
if (position != null)
nextPotentialPositions.add(position);
}
}
}
return nextPotentialPositions;
}
示例11: generateHallway
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的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);
}
示例12: procedurallyGenerate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的package包/类
/**
* Procedurally generate a dungeon through recursion using a simple 'Procedurally Build' algorithm.
* @param manager
* @param world
* @param startingPos - this position will ALWAYS be the position of the entrance.
*/
public void procedurallyGenerate(TemplateManager manager, World world, BlockPos startingPos, List<DungeonRoomPosition> nextPos)
{
List<DungeonRoomPosition> nextPos2 = Lists.newArrayList(); // list which will hold the positions to be tried in the NEXT recursion of the method.
if (roomCount > roomTries) return;
else
{
ArrayList<StructureBoundingBox> roomListCopy = Lists.newArrayList(roomList);
for (DungeonRoomPosition room : nextPos)
{
// check to make sure rooms don't overlap
for (StructureBoundingBox existingBB : roomListCopy)
{
// if structures don't overlap
if (!DungeonHelper.checkOverlap(existingBB, room.getBoundingBox()))
{
LootSlashConquer.LOGGER.info("Room generated successfully.");
List<DungeonRoomPosition> nextRooms = this.generateRoom(manager, world, room);
// copy new generated rooms into bigger list
for (DungeonRoomPosition nextRoom : nextRooms)
{
nextPos2.add(nextRoom);
}
}
else
{
LootSlashConquer.LOGGER.info("Room failed to generate.");
}
}
}
}
roomCount++;
procedurallyGenerate(manager, world, startingPos, nextPos2);
}
示例13: 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;
}
示例14: generateRoom
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的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());
}
示例15: getRandomizedDungeonTemplate
import net.minecraft.world.gen.structure.template.TemplateManager; //导入依赖的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())));
}