Search in sources :

Example 1 with RCP

use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.

the class CommandSetProperty method execute.

@Override
public void execute(MockWorld world, ICommandSender sender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    PositionedBlockExpression matcher = parameters.get("exp").orElse("").to(RCP::expression, new PositionedBlockExpression(RecurrentComplex.specialRegistry)).require();
    String propertyName = parameters.get(0).require();
    String propertyValue = parameters.get(1).require();
    RCP.Shape shape = parameters.get("shape").to(RCP::shape).optional().orElse(RCP.Shape.cube);
    Consumer<BlockPos> consumer = (BlockPos pos) -> {
        PositionedBlockExpression.Argument at = PositionedBlockExpression.Argument.at(world, pos);
        if (matcher.test(at))
            TransformerProperty.withProperty(at.state, propertyName, propertyValue).ifPresent(state -> world.setBlockState(pos, state, 3));
    };
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(sender, null, true);
    RCCommands.assertSize(sender, selectionOwner);
    CommandFill.runShape(shape, selectionOwner.getSelection(), consumer);
}
Also used : Parameters(ivorius.mcopts.commands.parameters.Parameters) PositionedBlockExpression(ivorius.reccomplex.utils.expression.PositionedBlockExpression) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) BlockPos(net.minecraft.util.math.BlockPos) RCP(ivorius.reccomplex.commands.parameters.RCP)

Example 2 with RCP

use of ivorius.reccomplex.commands.parameters.RCP 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 3 with RCP

use of ivorius.reccomplex.commands.parameters.RCP 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 4 with RCP

use of ivorius.reccomplex.commands.parameters.RCP 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)

Example 5 with RCP

use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.

the class CommandMapStructure method map.

@Nonnull
public static MapResult map(String structureID, @Nullable ResourceDirectory directory, ICommandSender commandSender, CommandVirtual command, String[] args, boolean inform) throws CommandException {
    GenericStructure structure = Parameter.makeUp(null, 0, structureID).to(RCP::structure).require().copyAsGenericStructure();
    if (structure == null) {
        if (inform)
            throw RecurrentComplex.translations.commandException("commands.structure.notGeneric", structureID);
        return MapResult.SKIPPED;
    }
    IvWorldData worldData = structure.constructWorldData();
    MockWorld world = new MockWorld.WorldData(worldData);
    try {
        command.execute(world, new SelectingSender(commandSender, BlockPos.ORIGIN, worldData.blockCollection.area().getHigherCorner()), args);
    } catch (MockWorld.VirtualWorldException ex) {
        throw RecurrentComplex.translations.commandException("commands.rcmap.nonvirtual.arguments");
    }
    structure.worldDataCompound = worldData.createTagCompound();
    if (directory == null)
        return MapResult.SUCCESS;
    return PacketSaveStructureHandler.write(commandSender, structure, structureID, directory, true, inform) ? MapResult.SUCCESS : MapResult.FAILED;
}
Also used : IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) MockWorld(ivorius.ivtoolkit.world.MockWorld) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) RCP(ivorius.reccomplex.commands.parameters.RCP) Nonnull(javax.annotation.Nonnull)

Aggregations

RCP (ivorius.reccomplex.commands.parameters.RCP)12 Parameters (ivorius.mcopts.commands.parameters.Parameters)8 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)7 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)6 Expect (ivorius.mcopts.commands.parameters.expect.Expect)6 RCConfig (ivorius.reccomplex.RCConfig)6 RCE (ivorius.reccomplex.commands.parameters.expect.RCE)6 CommandException (net.minecraft.command.CommandException)6 ICommandSender (net.minecraft.command.ICommandSender)6 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5 MinecraftServer (net.minecraft.server.MinecraftServer)5 NaP (ivorius.mcopts.commands.parameters.NaP)4 RCCommands (ivorius.reccomplex.commands.RCCommands)4 BlockPos (net.minecraft.util.math.BlockPos)4 MockWorld (ivorius.ivtoolkit.world.MockWorld)3 MCE (ivorius.mcopts.commands.parameters.expect.MCE)3 LeveledRegistry (ivorius.reccomplex.files.loading.LeveledRegistry)3 RawResourceLocation (ivorius.reccomplex.utils.RawResourceLocation)3 ResourceExpression (ivorius.reccomplex.utils.expression.ResourceExpression)3