use of net.minecraft.server.MinecraftServer in project NetherEx by LogicTechCorp.
the class WorldGenWallStructure method generate.
@Override
public boolean generate(World world, Random rand, BlockPos pos) {
rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed());
Mirror[] mirrors = Mirror.values();
Rotation[] rotations = Rotation.values();
Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
Rotation rotation = rotations[rand.nextInt(rotations.length)];
MinecraftServer server = world.getMinecraftServer();
TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants));
PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.AIR).setRandom(rand);
BlockPos structureSize = Template.transformedBlockPos(placementSettings, template.getSize());
BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX() / 2, 96, pos.getZ() - structureSize.getZ() / 2);
BlockPos spawnPos = WorldGenUtil.getSuitableWallPos(world, newPos, structureSize, 0.8F);
if (!spawnPos.equals(BlockPos.ORIGIN)) {
WorldGenUtil.generateStructure(world, spawnPos, rand, template, placementSettings, lootTables, spawnerMobs);
return true;
}
return false;
}
use of net.minecraft.server.MinecraftServer in project NetherEx by LogicTechCorp.
the class WorldGenCeilingStructure method generate.
@Override
public boolean generate(World world, Random rand, BlockPos pos) {
rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed());
Mirror[] mirrors = Mirror.values();
Rotation[] rotations = Rotation.values();
Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
Rotation rotation = rotations[rand.nextInt(rotations.length)];
MinecraftServer server = world.getMinecraftServer();
TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants));
PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setRandom(rand);
BlockPos structureSize = Template.transformedBlockPos(placementSettings, template.getSize());
BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX() / 2, 48, pos.getZ() - structureSize.getZ() / 2);
BlockPos spawnPos = WorldGenUtil.getSuitableCeilingPos(world, newPos, structureSize);
if (!spawnPos.equals(BlockPos.ORIGIN)) {
WorldGenUtil.generateStructure(world, spawnPos, rand, template, placementSettings, lootTables, spawnerMobs);
return true;
}
return false;
}
use of net.minecraft.server.MinecraftServer in project Pearcel-Mod by MiningMark48.
the class StructureGenPearcel3 method generateStructure.
public static void generateStructure(WorldServer world, BlockPos pos, Random random) {
MinecraftServer server = world.getMinecraftServer();
Template template = world.getStructureTemplateManager().getTemplate(server, STRUCTURE);
PlacementSettings settings = new PlacementSettings();
settings.setRotation(Rotation.NONE);
template.addBlocksToWorld(world, pos, settings);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
for (Map.Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
String[] tokens = entry.getValue().split(" ");
if (tokens.length == 0)
return;
BlockPos dataPos = entry.getKey();
String s = tokens[0].toLowerCase();
if (s.equals("lootchest2")) {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT2, random.nextLong());
}
}
}
use of net.minecraft.server.MinecraftServer in project ArsMagica2 by Mithion.
the class DimensionUtilities method doDimensionTransfer.
public static void doDimensionTransfer(EntityLivingBase entity, int dimension) {
if (entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
new AMTeleporter(player.mcServer.worldServerForDimension(dimension)).teleport(entity);
} else {
entity.worldObj.theProfiler.startSection("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
int j = entity.dimension;
WorldServer worldserver = minecraftserver.worldServerForDimension(j);
WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimension);
entity.dimension = dimension;
entity.worldObj.removeEntity(entity);
entity.isDead = false;
entity.worldObj.theProfiler.startSection("reposition");
minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new AMTeleporter(worldserver1));
entity.worldObj.theProfiler.endStartSection("reloading");
Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);
if (e != null) {
e.copyDataFrom(entity, true);
worldserver1.spawnEntityInWorld(e);
}
entity.isDead = true;
entity.worldObj.theProfiler.endSection();
worldserver.resetUpdateEntityTick();
worldserver1.resetUpdateEntityTick();
entity.worldObj.theProfiler.endSection();
}
}
use of net.minecraft.server.MinecraftServer in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomDropsCommand method canCommandSenderUseCommand.
@Override
public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) {
if (pCommandSender instanceof EntityPlayerMP) {
EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender;
boolean tPlayerOpped = MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile());
// && tIncreative;
return tPlayerOpped;
} else if (pCommandSender instanceof MinecraftServer)
return true;
else
return false;
}
Aggregations