Search in sources :

Example 1 with ResourceDirectory

use of ivorius.reccomplex.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.

the class CommandMapAllStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    ResourceExpression expression = new ResourceExpression(StructureRegistry.INSTANCE::has);
    IvOptional.ifAbsent(parameters.rc("exp").expression(expression).optional(), () -> expression.setExpression(""));
    ResourceDirectory directory = parameters.rc("dir").resourceDirectory().optional().orElse(ResourceDirectory.ACTIVE);
    CommandVirtual virtual = parameters.rc().virtualCommand(server).require();
    int saved = 0, failed = 0, skipped = 0;
    for (String id : StructureRegistry.INSTANCE.ids()) {
        if (!expression.test(new RawResourceLocation(StructureRegistry.INSTANCE.status(id).getDomain(), id)))
            continue;
        Structure<?> info = StructureRegistry.INSTANCE.get(id);
        if (!(info instanceof GenericStructure)) {
            skipped++;
            continue;
        }
        GenericStructure structure = (GenericStructure) info;
        IvWorldData worldData = structure.constructWorldData();
        MockWorld world = new MockWorld.WorldData(worldData);
        try {
            virtual.execute(world, new CommandSelecting.SelectingSender(commandSender, BlockPos.ORIGIN, worldData.blockCollection.area().getHigherCorner()), parameters.get().move(1).varargs());
        } catch (MockWorld.VirtualWorldException ex) {
            throw ServerTranslations.commandException("commands.rcmap.nonvirtual.arguments");
        }
        structure.worldDataCompound = worldData.createTagCompound();
        if (PacketSaveStructureHandler.write(commandSender, structure, id, directory, true, false))
            saved++;
        else
            failed++;
    }
    commandSender.sendMessage(ServerTranslations.format("commands.rcmapall.result", saved, RCTextStyle.path(directory), failed, skipped));
    RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.CUSTOM);
    RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.SERVER);
}
Also used : IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) CommandSelecting(ivorius.reccomplex.commands.CommandSelecting) RawResourceLocation(ivorius.reccomplex.utils.RawResourceLocation) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) CommandVirtual(ivorius.reccomplex.commands.CommandVirtual) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) MockWorld(ivorius.ivtoolkit.world.MockWorld) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) ResourceExpression(ivorius.reccomplex.utils.expression.ResourceExpression)

Example 2 with ResourceDirectory

use of ivorius.reccomplex.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.

the class PacketSaveInvGenComponentHandler method processServer.

@Override
public void processServer(PacketSaveInvGenComponent message, MessageContext ctx, WorldServer server) {
    NetHandlerPlayServer playServer = ctx.getServerHandler();
    EntityPlayerMP player = playServer.player;
    if (RecurrentComplex.checkPerms(player))
        return;
    SaveDirectoryData.Result saveDirectoryDataResult = message.getSaveDirectoryDataResult();
    String id = message.getKey();
    ResourceDirectory saveDir = saveDirectoryDataResult.directory;
    ResourceDirectory delDir = saveDir.opposite();
    GenericItemCollectionRegistry.INSTANCE.register(id, "", message.getInventoryGenerator(), saveDir.isActive(), saveDir.getLevel());
    if (RCCommands.informSaveResult((message.getInventoryGenerator() != null && id != null) && RecurrentComplex.saver.trySave(saveDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, saveDir, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id)) {
        if (saveDirectoryDataResult.deleteOther)
            RCCommands.informDeleteResult(RecurrentComplex.saver.tryDeleteWithID(delDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id, delDir);
        ItemStack heldItem = playServer.player.getHeldItem(EnumHand.MAIN_HAND);
        if (heldItem != null && heldItem.getItem() instanceof ItemInventoryGenComponentTag)
            ItemInventoryGenComponentTag.setComponentKey(heldItem, id);
        player.openContainer.detectAndSendChanges();
    }
}
Also used : ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) SaveDirectoryData(ivorius.reccomplex.utils.SaveDirectoryData) ItemInventoryGenComponentTag(ivorius.reccomplex.item.ItemInventoryGenComponentTag) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 3 with ResourceDirectory

use of ivorius.reccomplex.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.

the class CommandVisitFiles method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(ResourceDirectory.ACTIVE);
    OpenGlHelper.openFile(directory.toFile());
}
Also used : ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) RCP(ivorius.reccomplex.commands.parameters.RCP)

Example 4 with ResourceDirectory

use of ivorius.reccomplex.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.

the class CommandEditStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(commandSender);
    Parameters parameters = Parameters.of(args, expect()::declare);
    ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
    String structureID = parameters.get("id").optional().orElse(parameters.get(0).require());
    GenericStructure base = parameters.get(0).to(p -> RCP.genericStructure(p, false)).require();
    GenericStructure from = parameters.get("from").to(p -> RCP.genericStructure(p, false)).optional().orElse(base);
    if (base != from) {
        from = from.copyAsGenericStructure();
        from.worldDataCompound = base.worldDataCompound.copy();
    }
    PacketEditStructureHandler.openEditStructure(entityPlayerMP, from, entityPlayerMP.getPosition(), structureID, directory);
}
Also used : GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) PacketEditStructureHandler(ivorius.reccomplex.network.PacketEditStructureHandler) ivorius.mcopts.commands.parameters(ivorius.mcopts.commands.parameters) RCConfig(ivorius.reccomplex.RCConfig) CommandExpecting(ivorius.mcopts.commands.CommandExpecting) RCE(ivorius.reccomplex.commands.parameters.expect.RCE) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) Expect(ivorius.mcopts.commands.parameters.expect.Expect) ICommandSender(net.minecraft.command.ICommandSender) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 5 with ResourceDirectory

use of ivorius.reccomplex.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.

the class CommandExportStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    EntityPlayerMP player = getCommandSenderAsPlayer(commandSender);
    ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
    String structureID = parameters.get("id").optional().orElse(parameters.get(0).optional().orElse(null));
    GenericStructure from = parameters.get(0).to(RCP::structureFromBlueprint, commandSender).require();
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    from.worldDataCompound = IvWorldData.capture(commandSender.getEntityWorld(), selectionOwner.getSelection(), true).createTagCompound();
    PacketEditStructureHandler.openEditStructure(player, from, selectionOwner.getSelection().getLowerCorner(), structureID, directory);
}
Also used : Parameters(ivorius.mcopts.commands.parameters.Parameters) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Aggregations

ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)13 RCP (ivorius.reccomplex.commands.parameters.RCP)7 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 Parameters (ivorius.mcopts.commands.parameters.Parameters)5 RCConfig (ivorius.reccomplex.RCConfig)5 RawResourceLocation (ivorius.reccomplex.utils.RawResourceLocation)5 ResourceExpression (ivorius.reccomplex.utils.expression.ResourceExpression)5 CommandException (net.minecraft.command.CommandException)5 ICommandSender (net.minecraft.command.ICommandSender)5 MinecraftServer (net.minecraft.server.MinecraftServer)5 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)4 Expect (ivorius.mcopts.commands.parameters.expect.Expect)4 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)4 RCCommands (ivorius.reccomplex.commands.RCCommands)4 RCE (ivorius.reccomplex.commands.parameters.expect.RCE)4 LeveledRegistry (ivorius.reccomplex.files.loading.LeveledRegistry)4 NaP (ivorius.mcopts.commands.parameters.NaP)3 FileSaverAdapter (ivorius.reccomplex.files.saving.FileSaverAdapter)3 SaveDirectoryData (ivorius.reccomplex.utils.SaveDirectoryData)3