本文整理汇总了Java中net.minecraft.world.gen.structure.template.PlacementSettings.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Java PlacementSettings.setRotation方法的具体用法?Java PlacementSettings.setRotation怎么用?Java PlacementSettings.setRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.gen.structure.template.PlacementSettings
的用法示例。
在下文中一共展示了PlacementSettings.setRotation方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixRotationBlockPos
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的package包/类
/**
* Inserted in addComponentParts in net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces$Igloo
*
* This modifies the blockpos passed to addBlocksToWorldChunk to keep the structure within the original bounding box.
*/
public static BlockPos fixRotationBlockPos(BlockPos bp, PlacementSettings ps, StructureComponent structure) {
StructureBoundingBox structurebb = structure.getBoundingBox();
EnumFacing facing = structure.getCoordBaseMode();
BlockPos newpos = bp;
switch (facing) {
case SOUTH:
ps.setRotation(Rotation.NONE);
newpos = new BlockPos(structurebb.minX, structurebb.minY, structurebb.minZ);
break;
case EAST:
ps.setRotation(Rotation.COUNTERCLOCKWISE_90);
newpos = new BlockPos(structurebb.minX, structurebb.minY, structurebb.maxZ);
break;
case NORTH:
ps.setRotation(Rotation.CLOCKWISE_180);
newpos = new BlockPos(structurebb.maxX, structurebb.minY, structurebb.maxZ);
break;
case WEST:
ps.setRotation(Rotation.CLOCKWISE_90);
newpos = new BlockPos(structurebb.maxX, structurebb.minY, structurebb.minZ);
break;
}
return newpos;
}
示例2: getPasteModePlacement
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的package包/类
private PlacementSettings getPasteModePlacement(ItemStack stack, EntityPlayer player)
{
EnumFacing facing = this.getTemplateFacing(stack);
EnumFacing areaFacing = this.getAreaFacing(stack, Mode.PASTE);
if (areaFacing == null)
{
areaFacing = facing;
}
Rotation rotation = PositionUtils.getRotation(facing, areaFacing);
PlacementSettings placement = new PlacementSettings();
boolean ignoreEntities = player.capabilities.isCreativeMode == false ||
WandOption.AFFECT_ENTITIES.isEnabled(stack, Mode.PASTE) == false;
placement.setMirror(this.getMirror(stack));
placement.setRotation(rotation);
placement.setIgnoreEntities(ignoreEntities);
return placement;
}
示例3: gen
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的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);
}
}
}
}
示例4: genCubes
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的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);
}
}
}
示例5: moveAreaImmediate
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的package包/类
private void moveAreaImmediate(ItemStack stack, World world, EntityPlayer player, BlockPos posSrc1, BlockPos posSrc2, BlockPos posDst1,
Mirror mirror, Rotation rotation)
{
PlacementSettings placement = new PlacementSettings();
placement.setMirror(mirror);
placement.setRotation(rotation);
placement.setIgnoreEntities(false);
placement.setReplacedBlock(Blocks.BARRIER); // meh
ReplaceMode replace = WandOption.REPLACE_EXISTING.isEnabled(stack, Mode.MOVE_DST) ? ReplaceMode.EVERYTHING : ReplaceMode.NOTHING;
TemplateEnderUtilities template = new TemplateEnderUtilities(placement, replace);
template.takeBlocksFromWorld(world, posSrc1, posSrc2.subtract(posSrc1), true, false);
this.deleteArea(stack, world, player, posSrc1, posSrc2, true);
template.addBlocksToWorld(world, posDst1);
}
示例6: generateTower
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的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;
}
}
}
示例7: generateMonument
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的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));
}
}
}
}
示例8: execute
import net.minecraft.world.gen.structure.template.PlacementSettings; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 1)
throw new WrongUsageException(getUsage(sender));
String cmd = args[0].toLowerCase(Locale.ENGLISH);
if ("list".equals(cmd))
{
sender.sendMessage(new TextComponentString("Known Platforms:"));
for (ResourceLocation rl : getPlatforms())
{
sender.sendMessage(new TextComponentString(" " + rl.toString()));
}
}
else if ("spawn".equals(cmd) || "preview".equals(cmd))
{
if (args.length < 2)
throw new WrongUsageException(getUsage(sender));
Entity ent = sender.getCommandSenderEntity();
PlacementSettings settings = new PlacementSettings();
WorldServer world = (WorldServer)sender.getEntityWorld();
if (args.length >= 3)
{
//TODO: Preview doesnt quite work correctly with rotations....
String rot = args[2].toLowerCase(Locale.ENGLISH);
if ("0".equals(rot) || "none".equals(rot))
settings.setRotation(Rotation.NONE);
else if ("90".equals(rot))
settings.setRotation(Rotation.CLOCKWISE_90);
else if ("180".equals(rot))
settings.setRotation(Rotation.CLOCKWISE_180);
else if ("270".equals(rot))
settings.setRotation(Rotation.COUNTERCLOCKWISE_90);
else
throw new WrongUsageException("Only rotations none, 0, 90, 180, and 270 allowed.");
}
BlockPos pos;
if (args.length >= 6)
pos = CommandBase.parseBlockPos(sender, args, 3, false);
else if (ent != null)
pos = ent.getPosition();
else
throw new WrongUsageException("Must specify a position if the command sender is not an entity");
Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[1]), world, true);
BlockPos spawn = StructureUtil.findSpawn(temp, settings);
if (spawn != null)
pos = pos.subtract(spawn);
if ("spawn".equals(cmd))
{
sender.sendMessage(new TextComponentString("Building \"" + args[1] +"\" 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!
}
else
{
BlockPos tpos = pos.down();
if (spawn != null)
tpos = tpos.add(spawn);
sender.sendMessage(new TextComponentString("Previewing \"" + args[1] +"\" at " + pos.toString()));
world.setBlockState(tpos, Blocks.STRUCTURE_BLOCK.getDefaultState().withProperty(BlockStructure.MODE, TileEntityStructure.Mode.LOAD));
TileEntityStructure te = (TileEntityStructure)world.getTileEntity(tpos);
if (spawn != null)
te.setPosition(te.getPosition().subtract(spawn));
te.setSize(temp.getSize());
te.setMode(Mode.LOAD);
te.markDirty();
}
}
else
throw new WrongUsageException(getUsage(sender));
}