Search in sources :

Example 16 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project malmo by Microsoft.

the class DefaultWorldGeneratorImplementation method shouldCreateWorld.

@Override
public boolean shouldCreateWorld(MissionInit missionInit) {
    if (this.dwparams != null && this.dwparams.isForceReset())
        return true;
    World world = null;
    MinecraftServer server = MinecraftServer.getServer();
    if (server.worldServers != null && server.worldServers.length != 0)
        world = server.getEntityWorld();
    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 != null && !genOptions.isEmpty())
        // Default world has no generator options.
        return true;
    return false;
}
Also used : World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 17 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project malmo by Microsoft.

the class ServerQuitFromTimeUpImplementation method getWorldTime.

@Override
protected long getWorldTime() {
    World world = null;
    MinecraftServer server = MinecraftServer.getServer();
    if (server.worldServers != null && server.worldServers.length != 0)
        world = server.getEntityWorld();
    return (world != null) ? world.getTotalWorldTime() : 0;
}
Also used : World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 18 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project MinecraftForge by MinecraftForge.

the class DimensionManager method initDimension.

public static void initDimension(int dim) {
    WorldServer overworld = getWorld(0);
    if (overworld == null) {
        throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
    }
    try {
        DimensionManager.getProviderType(dim);
    } catch (Exception e) {
        System.err.println("Cannot Hotload Dim: " + e.getMessage());
        // If a provider hasn't been registered then we can't hotload the dim
        return;
    }
    MinecraftServer mcServer = overworld.getMinecraftServer();
    ISaveHandler savehandler = overworld.getSaveHandler();
    //WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());
    WorldServer world = (dim == 0 ? overworld : (WorldServer) (new WorldServerMulti(mcServer, savehandler, dim, overworld, mcServer.theProfiler).init()));
    world.addEventListener(new ServerWorldEventHandler(mcServer, world));
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
    if (!mcServer.isSinglePlayer()) {
        world.getWorldInfo().setGameType(mcServer.getGameType());
    }
    mcServer.setDifficultyForAllWorlds(mcServer.getDifficulty());
}
Also used : ISaveHandler(net.minecraft.world.storage.ISaveHandler) WorldEvent(net.minecraftforge.event.world.WorldEvent) WorldServer(net.minecraft.world.WorldServer) ServerWorldEventHandler(net.minecraft.world.ServerWorldEventHandler) MinecraftException(net.minecraft.world.MinecraftException) WorldServerMulti(net.minecraft.world.WorldServerMulti) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 19 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project MinecraftForge by MinecraftForge.

the class FMLCommonHandler method handleServerStopped.

public void handleServerStopped() {
    sidedDelegate.serverStopped();
    MinecraftServer server = getMinecraftServerInstance();
    Loader.instance().serverStopped();
    // FORCE the internal server to stop: hello optifine workaround!
    if (server != null)
        ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316" + "_v", "u", "serverStopped");
    // allow any pending exit to continue, clear exitLatch
    CountDownLatch latch = exitLatch;
    if (latch != null) {
        latch.countDown();
        exitLatch = null;
    }
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 20 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project NetherEx by LogicTechCorp.

the class WorldGenElderMushroom method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    while (isWorldGen && world.isAirBlock(pos) && pos.getY() > 32) {
        pos = pos.down();
    }
    for (int posX = -1; posX < 2; posX++) {
        for (int posZ = -1; posZ < 2; posZ++) {
            BlockPos newPos = pos.add(posX, 0, posZ);
            IBlockState state = world.getBlockState(newPos);
            if (!state.getBlock().canSustainPlant(state, world, newPos, EnumFacing.UP, NetherExBlocks.PLANT_MUSHROOM_ELDER) && state.getBlock() != Blocks.SOUL_SAND) {
                return false;
            }
        }
    }
    pos = pos.up();
    Mirror[] mirrors = Mirror.values();
    Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
    Rotation[] rotations = Rotation.values();
    Rotation rotation = rotations[rand.nextInt(rotations.length)];
    MinecraftServer minecraftServer = world.getMinecraftServer();
    TemplateManager templateManager = world.getSaveHandler().getStructureTemplateManager();
    Template template = templateManager.getTemplate(minecraftServer, WeightedUtil.getRandomStructure(rand, variants));
    PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.AIR);
    BlockPos structureSize = Template.transformedBlockPos(placementSettings.copy(), template.getSize());
    float airAmount = 0;
    float blockAmount = MathHelper.abs((structureSize.getX() + 2) * (structureSize.getY() + 1) * (structureSize.getZ() + 2));
    for (int posX = -1; posX < structureSize.getX() + 1; posX++) {
        for (int posZ = -1; posZ < structureSize.getZ() + 1; posZ++) {
            for (int posY = 0; posY < structureSize.getY() + 1; posY++) {
                BlockPos newPos = pos.add(-(posX / 2), posY, -(posZ / 2));
                Block block = world.getBlockState(newPos).getBlock();
                if (world.isAirBlock(newPos)) {
                    airAmount += 1.0F;
                } else if (block == Blocks.NETHERRACK || block == Blocks.GLOWSTONE || block == NetherExBlocks.BLOCK_NETHERRACK || block == NetherExBlocks.PLANT_MUSHROOM_ELDER_CAP || block == NetherExBlocks.PLANT_MUSHROOM_ELDER_STEM) {
                    return false;
                }
            }
        }
    }
    if (MathHelper.abs(airAmount) / MathHelper.abs(blockAmount) >= 0.75F) {
        if (!isWorldGen) {
            world.setBlockToAir(pos);
        }
        template.addBlocksToWorld(world, pos.add(-(structureSize.getX() / 2), 0, -(structureSize.getZ() / 2)), placementSettings.copy());
        return true;
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template) TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) Mirror(net.minecraft.util.Mirror)

Aggregations

MinecraftServer (net.minecraft.server.MinecraftServer)32 BlockPos (net.minecraft.util.math.BlockPos)13 Template (net.minecraft.world.gen.structure.template.Template)9 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)8 World (net.minecraft.world.World)6 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 Mirror (net.minecraft.util.Mirror)5 Rotation (net.minecraft.util.Rotation)5 WorldServer (net.minecraft.world.WorldServer)5 RCConfig (ivorius.reccomplex.RCConfig)4 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)4 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)4 ServerTranslations (ivorius.reccomplex.utils.ServerTranslations)4 List (java.util.List)4 Nullable (javax.annotation.Nullable)4 IBlockState (net.minecraft.block.state.IBlockState)4 CommandBase (net.minecraft.command.CommandBase)4 CommandException (net.minecraft.command.CommandException)4 ICommandSender (net.minecraft.command.ICommandSender)4