Search in sources :

Example 26 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project SecurityCraft by Geforce132.

the class GuiRetinalScannerSetup method actionPerformed.

protected void actionPerformed(GuiButton guibutton) {
    switch(guibutton.id) {
        case 0:
            String players = this.textboxAllowedPlayers.getText();
            World W = Minecraft.getMinecraft().theWorld;
            MinecraftServer minecraftserver = MinecraftServer.getServer();
            try {
                if (this.mc.isSingleplayer()) {
                //String string = "saves/" + BlockRetinalScanner.worldObj.getSaveHandler().getWorldDirectoryName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ;
                //File file = new File(string);
                //file.mkdirs();
                //file.createNewFile();
                //PrintWriter out = new PrintWriter("saves/" + BlockRetinalScanner.worldObj.getSaveHandler().getWorldDirectoryName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ + "/players.txt");		
                //out.println(players);
                //out.close();
                } else {
                //String string = minecraftserver.getWorldName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ;
                //File file = new File(string);
                //file.mkdirs();
                //file.createNewFile();
                //PrintWriter out = new PrintWriter(minecraftserver.getWorldName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ + "/players.txt");		
                //out.println(players);
                //out.close();
                }
                if (this.mc.isSingleplayer()) {
                    EntityClientPlayerMP P = Minecraft.getMinecraft().thePlayer;
                    P.closeScreen();
                    P.openGui(mod_SecurityCraft.instance, 3, W, (int) P.posX, (int) P.posY, (int) P.posZ);
                } else {
                //HelpfulMethods.closePlayerScreen(BlockRetinalScanner.playerObj);
                //BlockRetinalScanner.playerObj.openGui(mod_SecurityCraft.instance, 3, W, (int) BlockRetinalScanner.playerObj.posX, (int) BlockRetinalScanner.playerObj.posY, (int) BlockRetinalScanner.playerObj.posZ);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
    }
}
Also used : EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 27 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.

the class CommandContaining method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    BlockExpression matcher = parameters.rc().expression(new BlockExpression(RecurrentComplex.specialRegistry)).require();
    CommandSearchStructure.postResultMessage(commandSender, RCTextStyle::structure, CommandSearchStructure.search(StructureRegistry.INSTANCE.ids(), name -> containedBlocks(StructureRegistry.INSTANCE.get(name), matcher)));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) IvBlockCollection(ivorius.ivtoolkit.blocks.IvBlockCollection) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Nullable(javax.annotation.Nullable) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression)

Example 28 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.

the class CommandPreview method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    EntityPlayer player = getCommandSenderAsPlayer(commandSender);
    RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
    Operation.PreviewType previewType = parameters.get().first().map(Operation.PreviewType::find, s -> ServerTranslations.commandException("commands.rcpreview.invalid")).require();
    RCEntityInfo.setPreviewType(previewType);
    RCEntityInfo.sendPreviewTypeToClients(player);
    commandSender.sendMessage(ServerTranslations.format("commands.rcpreview.success", previewType.key));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Operation(ivorius.reccomplex.operation.Operation) RCCommands(ivorius.reccomplex.commands.RCCommands) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Nullable(javax.annotation.Nullable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) Operation(ivorius.reccomplex.operation.Operation)

Example 29 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.

the class CommandWriteAll method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    String adapterID = parameters.get().first().require();
    if (!RecurrentComplex.saver.has(adapterID))
        throw ServerTranslations.commandException("commands.rcsaveall.noregistry");
    ResourceDirectory directory = parameters.rc("dir").resourceDirectory().optional().orElse(ResourceDirectory.ACTIVE);
    Optional<FileSaverAdapter<?>> adapterOptional = Optional.ofNullable(RecurrentComplex.saver.get(adapterID));
    Set<String> ids = adapterOptional.map(a -> a.getRegistry().ids()).orElse(Collections.emptySet());
    ResourceExpression resourceExpression = ExpressionCache.of(new ResourceExpression(id -> adapterOptional.map(a -> a.getRegistry().has(id)).orElse(false)), parameters.get().at(1).require());
    int saved = 0, failed = 0;
    for (String id : ids) {
        if (!resourceExpression.test(new RawResourceLocation(adapterOptional.map(a -> a.getRegistry().status(id).getDomain()).orElseThrow(IllegalStateException::new), id)))
            continue;
        boolean success = RecurrentComplex.saver.trySave(directory.toPath(), adapterID, id);
        if (success)
            saved++;
        else
            failed++;
    }
    commandSender.sendMessage(ServerTranslations.format("commands.rcsaveall.result", saved, directory, failed));
    RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.CUSTOM);
    RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.SERVER);
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) ExpressionCache(ivorius.reccomplex.utils.algebra.ExpressionCache) LeveledRegistry(ivorius.reccomplex.files.loading.LeveledRegistry) RCCommands(ivorius.reccomplex.commands.RCCommands) Set(java.util.Set) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) FileSaverAdapter(ivorius.reccomplex.files.saving.FileSaverAdapter) RCConfig(ivorius.reccomplex.RCConfig) RawResourceLocation(ivorius.reccomplex.utils.RawResourceLocation) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) ResourceExpression(ivorius.reccomplex.utils.expression.ResourceExpression) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) Optional(java.util.Optional) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Collections(java.util.Collections) Nullable(javax.annotation.Nullable) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) FileSaverAdapter(ivorius.reccomplex.files.saving.FileSaverAdapter) ResourceExpression(ivorius.reccomplex.utils.expression.ResourceExpression) RawResourceLocation(ivorius.reccomplex.utils.RawResourceLocation)

Example 30 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project NewHorizonsCoreMod by GTNewHorizons.

the class CustomFuelsCommand 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)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