Search in sources :

Example 1 with MinecraftServer

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;
}
Also used : World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 2 with MinecraftServer

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;
}
Also used : World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 3 with MinecraftServer

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();
}
Also used : MinecraftServer(net.minecraft.server.MinecraftServer)

Example 4 with MinecraftServer

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;
}
Also used : TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Mirror(net.minecraft.util.Mirror) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template)

Example 5 with MinecraftServer

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;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

MinecraftServer (net.minecraft.server.MinecraftServer)162 WorldServer (net.minecraft.world.WorldServer)35 BlockPos (net.minecraft.util.math.BlockPos)34 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)30 Player (org.spongepowered.api.entity.living.player.Player)30 PlayerConnection (org.spongepowered.api.network.PlayerConnection)30 CommandException (net.minecraft.command.CommandException)19 World (net.minecraft.world.World)18 Template (net.minecraft.world.gen.structure.template.Template)18 ICommandSender (net.minecraft.command.ICommandSender)15 Entity (net.minecraft.entity.Entity)15 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)15 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)15 ResourceLocation (net.minecraft.util.ResourceLocation)14 TextComponentString (net.minecraft.util.text.TextComponentString)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 Rotation (net.minecraft.util.Rotation)12 RCConfig (ivorius.reccomplex.RCConfig)11 TileEntity (net.minecraft.tileentity.TileEntity)11 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)10