Search in sources :

Example 1 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure 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 GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.

the class CommandExportStructure method getNewGenericStructure.

public static GenericStructure getNewGenericStructure(ICommandSender commandSender, RCParameter parameter) throws CommandException {
    GenericStructure genericStructureInfo;
    if (parameter.has(1)) {
        genericStructureInfo = parameter.genericStructure().require();
    } else {
        genericStructureInfo = GenericStructure.createDefaultStructure();
        genericStructureInfo.metadata.authors = commandSender.getName();
    }
    return genericStructureInfo;
}
Also used : GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 3 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.

the class CommandSelectDuplicate method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror");
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    BlockArea area = selectionOwner.getSelection();
    BlockPos pos = parameters.pos("x", "y", "z", commandSender.getPosition(), false).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    IvWorldData worldData = IvWorldData.capture(commandSender.getEntityWorld(), area, true);
    NBTTagCompound worldDataCompound = worldData.createTagCompound();
    GenericStructure structureInfo = GenericStructure.createDefaultStructure();
    structureInfo.worldDataCompound = worldDataCompound;
    OperationRegistry.queueOperation(new OperationGenerateStructure(structureInfo, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld()), commandSender);
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 4 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.

the class CommandSelectMove method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    BlockPos move = parameters.get(RCP.pos("x", "y", "z", BlockPos.ORIGIN, false)).require();
    AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    boolean noselect = parameters.has("noselect");
    boolean duplicate = parameters.has("duplicate");
    int times = parameters.get("times").to(NaP::asInt).optional().orElse(1);
    BlockArea area = selectionOwner.getSelection();
    IvWorldData worldData = IvWorldData.capture(commandSender.getEntityWorld(), area, true);
    NBTTagCompound worldDataCompound = worldData.createTagCompound();
    GenericStructure structure = GenericStructure.createDefaultStructure();
    structure.worldDataCompound = worldDataCompound;
    BlockPos pos = selectionOwner.getSelection().getLowerCorner();
    for (int i = 0; i < times; i++) {
        pos = pos.add(move);
        if (duplicate)
            OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld()), commandSender);
        else
            OperationRegistry.queueOperation(new OperationMulti(new OperationClearArea(area), new OperationGenerateStructure(structure, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld())), commandSender);
    }
    if (!noselect) {
        StructureGenerator<GenericStructure.InstanceData> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
        // noinspection OptionalGetWithoutIsPresent
        StructureBoundingBox boundingBox = generator.boundingBox().get();
        selectionOwner.setSelection(RCBlockAreas.from(boundingBox));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.operation.OperationGenerateStructure) Parameters(ivorius.mcopts.commands.parameters.Parameters) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer) OperationClearArea(ivorius.reccomplex.operation.OperationClearArea) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) OperationMulti(ivorius.reccomplex.operation.OperationMulti) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) BlockPos(net.minecraft.util.math.BlockPos) NaP(ivorius.mcopts.commands.parameters.NaP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 5 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.

the class CommandPaste method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
    RCEntityInfo entityInfo = RCCommands.getStructureEntityInfo(entityPlayerMP, null);
    NBTTagCompound worldData = entityInfo.getWorldDataClipboard();
    if (worldData == null)
        throw RecurrentComplex.translations.commandException("commands.strucPaste.noClipboard");
    WorldServer world = (WorldServer) sender.getEntityWorld();
    BlockPos pos = parameters.get(MCP.pos("x", "y", "z", sender.getPosition(), false)).require();
    AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    String seed = parameters.get("seed").optional().orElse(null);
    boolean generate = parameters.has("generate");
    GenericStructure structure = GenericStructure.createDefaultStructure();
    structure.worldDataCompound = worldData;
    // TODO Generate with generation info?
    OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, !generate).withSeed(seed).prepare(world), sender);
    if (parameters.has("select")) {
        StructureGenerator<?> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
        // Can never not place so don't handle
        // noinspection OptionalGetWithoutIsPresent
        RCCommands.select(sender, RCBlockAreas.from(generator.boundingBox().get()));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.operation.OperationGenerateStructure) Parameters(ivorius.mcopts.commands.parameters.Parameters) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Aggregations

GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)19 BlockPos (net.minecraft.util.math.BlockPos)7 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)6 StructureGenerator (ivorius.reccomplex.world.gen.feature.StructureGenerator)6 WorldServer (net.minecraft.world.WorldServer)6 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)5 Parameters (ivorius.mcopts.commands.parameters.Parameters)5 RCP (ivorius.reccomplex.commands.parameters.RCP)5 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 OperationGenerateStructure (ivorius.reccomplex.operation.OperationGenerateStructure)4 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)3 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)3 RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)3 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BlockPositions (ivorius.ivtoolkit.blocks.BlockPositions)2 MockWorld (ivorius.ivtoolkit.world.MockWorld)2 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)2 ivorius.mcopts.commands.parameters (ivorius.mcopts.commands.parameters)2