Search in sources :

Example 6 with RCParameters

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

the class CommandLookupStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    String id = parameters.get().first().require();
    GenericStructure structure = parameters.rc().genericStructure().require();
    Metadata metadata = structure.metadata;
    boolean hasWeblink = !metadata.weblink.trim().isEmpty();
    ITextComponent weblink = hasWeblink ? new TextComponentString(RCStrings.abbreviateFormatted(metadata.weblink, 30)) : ServerTranslations.format("commands.rclookup.reply.nolink");
    if (hasWeblink) {
        weblink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, metadata.weblink));
        weblink.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(metadata.weblink)));
    }
    ITextComponent level = new TextComponentString(StructureRegistry.INSTANCE.status(id).getLevel().toString());
    level.getStyle().setColor(TextFormatting.YELLOW);
    commandSender.sendMessage(ServerTranslations.format(StructureRegistry.INSTANCE.hasActive(id) ? "commands.rclookup.reply.generates" : "commands.rclookup.reply.silent", id, RCTextStyle.users(metadata.authors), level, weblink));
    if (!metadata.comment.trim().isEmpty())
        commandSender.sendMessage(ServerTranslations.format("commands.rclookup.reply.comment", metadata.comment));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Metadata(ivorius.reccomplex.world.gen.feature.structure.generic.Metadata) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 7 with RCParameters

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

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

the class CommandExportStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    EntityPlayerMP player = getCommandSenderAsPlayer(commandSender);
    String structureID = parameters.get().first().optional().orElse(null);
    GenericStructure genericStructureInfo = getNewGenericStructure(commandSender, parameters.rc("from"));
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    genericStructureInfo.worldDataCompound = IvWorldData.capture(commandSender.getEntityWorld(), selectionOwner.getSelection(), true).createTagCompound();
    PacketEditStructureHandler.openEditStructure(genericStructureInfo, structureID, player);
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 9 with RCParameters

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

the class CommandImportStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror", "select");
    String structureID = parameters.get().first().require();
    Structure<?> structure = parameters.rc().structure().require();
    WorldServer world = parameters.mc("dimension").dimension(server, sender).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    BlockPos pos = parameters.pos("x", "y", "z", sender.getPosition(), false).require();
    boolean select = parameters.has("select");
    StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).transform(transform).lowerCoord(pos).asSource(true);
    // Can never not place so don't handle
    //noinspection OptionalGetWithoutIsPresent
    StructureBoundingBox boundingBox = generator.boundingBox().get();
    if (structure instanceof GenericStructure && world == sender.getEntityWorld())
        OperationRegistry.queueOperation(new OperationGenerateStructure((GenericStructure) structure, structureID, transform, pos, true).withStructureID(structureID).prepare(world), sender);
    else
        generator.generate();
    if (select) {
        SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
        owner.setSelection(RCBlockAreas.from(boundingBox));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) WorldServer(net.minecraft.world.WorldServer) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 10 with RCParameters

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

the class CommandDecorateOne method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    WorldServer entityWorld = (WorldServer) commandSender.getEntityWorld();
    BlockSurfacePos pos = parameters.iv().surfacePos(commandSender.getPosition(), false).require();
    if (!WorldGenStructures.generateRandomStructureInChunk(entityWorld.rand, pos.chunkCoord(), entityWorld, entityWorld.getBiome(pos.blockPos(0))))
        throw ServerTranslations.commandException("commands.rcdecorateone.none");
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) WorldServer(net.minecraft.world.WorldServer)

Aggregations

RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)39 BlockPos (net.minecraft.util.math.BlockPos)17 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)14 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)11 RCConfig (ivorius.reccomplex.RCConfig)8 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)8 ServerTranslations (ivorius.reccomplex.utils.ServerTranslations)8 Nullable (javax.annotation.Nullable)8 CommandException (net.minecraft.command.CommandException)8 ICommandSender (net.minecraft.command.ICommandSender)8 MinecraftServer (net.minecraft.server.MinecraftServer)8 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)7 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)7 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)7 List (java.util.List)7 WorldServer (net.minecraft.world.WorldServer)7 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)6 MockWorld (ivorius.ivtoolkit.world.MockWorld)6 CommandVirtual (ivorius.reccomplex.commands.CommandVirtual)6 RCCommands (ivorius.reccomplex.commands.RCCommands)6