use of net.minecraft.server.MinecraftServer in project malmo by Microsoft.
the class FileWorldGeneratorImplementation method shouldCreateWorld.
@Override
public boolean shouldCreateWorld(MissionInit missionInit) {
if (this.fwparams != null && this.fwparams.isForceReset())
return true;
World world = null;
MinecraftServer server = MinecraftServer.getServer();
if (server.worldServers != null && server.worldServers.length != 0)
world = server.getEntityWorld();
if (world == null)
// There is no world, so we definitely need to create one.
return true;
String name = (world != null) ? world.getWorldInfo().getWorldName() : "";
// Extract the name from the path (need to cope with backslashes or forward slashes.)
// Makes no sense to have an empty filename, but createWorld will deal with it graciously.
String mapfile = (this.mapFilename == null) ? "" : this.mapFilename;
String[] parts = mapfile.split("[\\\\/]");
if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null)
// We don't check whether the game modes match - it's up to the server state machine to sort that out.
return false;
// There's no world, or the world is different to the basemap file, so create.
return true;
}
use of net.minecraft.server.MinecraftServer in project malmo by Microsoft.
the class FlatWorldGeneratorImplementation method shouldCreateWorld.
@Override
public boolean shouldCreateWorld(MissionInit missionInit) {
World world = null;
MinecraftServer server = MinecraftServer.getServer();
if (server.worldServers != null && server.worldServers.length != 0)
world = server.getEntityWorld();
if (this.fwparams != null && this.fwparams.isForceReset())
return true;
if (Minecraft.getMinecraft().theWorld == null && world == null)
// Definitely need to create a world if there isn't one in existence!
return true;
String genOptions = world.getWorldInfo().getGeneratorOptions();
if (!genOptions.equals(this.fwparams.getGeneratorString()))
// Generation doesn't match, so recreate.
return true;
return false;
}
use of net.minecraft.server.MinecraftServer in project MinecraftForge by MinecraftForge.
the class StartupQuery method abort.
public static void abort() {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server != null)
server.initiateShutdown();
// to abort loading and go back to the main menu
aborted = true;
// to halt the server
throw new AbortedException();
}
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 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