Search in sources :

Example 6 with IvWorldData

use of ivorius.ivtoolkit.tools.IvWorldData 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 7 with IvWorldData

use of ivorius.ivtoolkit.tools.IvWorldData in project RecurrentComplex by Ivorforce.

the class CommandSelectMove method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror", "noselect");
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    RCCommands.assertSize(commandSender, selectionOwner);
    BlockPos pos = parameters.pos("x", "y", "z", selectionOwner.getSelectedPoint1(), false).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    boolean noselect = parameters.has("noselect");
    BlockArea area = selectionOwner.getSelection();
    IvWorldData worldData = IvWorldData.capture(commandSender.getEntityWorld(), area, true);
    NBTTagCompound worldDataCompound = worldData.createTagCompound();
    GenericStructure structure = GenericStructure.createDefaultStructure();
    structure.worldDataCompound = worldDataCompound;
    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.world.gen.feature.structure.OperationGenerateStructure) 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) OperationClearArea(ivorius.reccomplex.world.gen.feature.structure.OperationClearArea) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) OperationMulti(ivorius.reccomplex.world.gen.feature.structure.OperationMulti) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 8 with IvWorldData

use of ivorius.ivtoolkit.tools.IvWorldData in project RecurrentComplex by Ivorforce.

the class OperationRegistry method dummyOperation.

@Nullable
public static NBTTagCompound dummyOperation(@Nonnull Operation operation, int level) {
    if (level == 0)
        return writeOperation(operation);
    if (operation instanceof OperationGenerateStructure) {
        OperationGenerateStructure genStructure = (OperationGenerateStructure) operation;
        if (level == 1 && genStructure.structure != null) {
            IvWorldData dummyWorldData = genStructure.structure.constructWorldData();
            dummyWorldData.entities.clear();
            dummyWorldData.tileEntities.clear();
            for (BlockPos pos : dummyWorldData.blockCollection.area()) dummyWorldData.blockCollection.setBlockState(pos, (dummyWorldData.blockCollection.getBlockState(pos).isNormalCube() ? Blocks.STONE : Blocks.AIR).getDefaultState());
            GenericStructure dummyStructure = new GenericStructure();
            dummyStructure.worldDataCompound = dummyWorldData.createTagCompound();
            return writeOperation(new OperationGenerateStructure(dummyStructure, genStructure.generationInfoID, genStructure.transform, genStructure.lowerCoord, genStructure.generateAsSource));
        } else if (level == 2)
            return writeOperation(new OperationClearArea(genStructure.generationArea()));
    }
    return null;
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) BlockPos(net.minecraft.util.math.BlockPos) OperationClearArea(ivorius.reccomplex.world.gen.feature.structure.OperationClearArea) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) Nullable(javax.annotation.Nullable)

Example 9 with IvWorldData

use of ivorius.ivtoolkit.tools.IvWorldData in project RecurrentComplex by Ivorforce.

the class CommandExportSchematic method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
    BlockArea area = selectionOwner.getSelection();
    RCCommands.assertSize(commandSender, selectionOwner);
    String structureName = parameters.get().first().optional().orElse("NewStructure_" + commandSender.getEntityWorld().rand.nextInt(1000));
    BlockPos lowerCoord = area.getLowerCorner();
    BlockPos higherCoord = area.getHigherCorner();
    IvWorldData data = IvWorldData.capture(commandSender.getEntityWorld(), new BlockArea(lowerCoord, higherCoord), true);
    SchematicFile schematicFile = toSchematic(data);
    SchematicLoader.writeSchematicByName(schematicFile, structureName);
    commandSender.sendMessage(ServerTranslations.format("commands.strucExportSchematic.success", structureName));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) BlockPos(net.minecraft.util.math.BlockPos)

Example 10 with IvWorldData

use of ivorius.ivtoolkit.tools.IvWorldData in project RecurrentComplex by Ivorforce.

the class CommandMapStructure 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();
    ResourceDirectory directory = parameters.rc("dir").resourceDirectory().optional().orElse(ResourceDirectory.ACTIVE);
    CommandVirtual virtual = parameters.rc().move(1).virtualCommand(server).require();
    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(2).varargs());
    } catch (MockWorld.VirtualWorldException ex) {
        throw ServerTranslations.commandException("commands.rcmap.nonvirtual.arguments");
    }
    structure.worldDataCompound = worldData.createTagCompound();
    PacketSaveStructureHandler.write(commandSender, structure, id, directory, true, true);
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) CommandVirtual(ivorius.reccomplex.commands.CommandVirtual) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) CommandSelecting(ivorius.reccomplex.commands.CommandSelecting) MockWorld(ivorius.ivtoolkit.world.MockWorld) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Aggregations

IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)10 BlockPos (net.minecraft.util.math.BlockPos)7 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)5 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)4 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)3 OperationGenerateStructure (ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure)3 Nullable (javax.annotation.Nullable)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 WorldServer (net.minecraft.world.WorldServer)3 IvMutableBlockPos (ivorius.ivtoolkit.blocks.IvMutableBlockPos)2 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)2 MockWorld (ivorius.ivtoolkit.world.MockWorld)2 CommandSelecting (ivorius.reccomplex.commands.CommandSelecting)2 CommandVirtual (ivorius.reccomplex.commands.CommandVirtual)2 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)2 NBTStorable (ivorius.reccomplex.nbt.NBTStorable)2 OperationClearArea (ivorius.reccomplex.world.gen.feature.structure.OperationClearArea)2 RunTransformer (ivorius.reccomplex.world.gen.feature.structure.generic.transformers.RunTransformer)2