Search in sources :

Example 1 with SchematicFile

use of ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile in project RecurrentComplex by Ivorforce.

the class CommandImportSchematic method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Function<Parameters, Parameters> c = expect()::declare;
    Parameters parameters = Parameters.of(args, c);
    if (args.length < 1)
        throw RecurrentComplex.translations.wrongUsageException("commands.rcimportschematic.usage");
    SchematicFile schematicFile = parseSchematic(parameters.get(0).require());
    BlockPos pos = parameters.get(MCP.pos("x", "y", "z", commandSender.getPosition(), false)).require();
    AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    OperationRegistry.queueOperation(new OperationGenerateSchematic(schematicFile, transform, pos), commandSender);
}
Also used : SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) Parameters(ivorius.mcopts.commands.parameters.Parameters) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) OperationGenerateSchematic(ivorius.reccomplex.operation.OperationGenerateSchematic) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with SchematicFile

use of ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile in project RecurrentComplex by Ivorforce.

the class OperationGenerateSchematic method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound compound) {
    try {
        file = new SchematicFile(compound.getCompoundTag("schematic"));
    } catch (SchematicFile.UnsupportedSchematicFormatException e) {
        RecurrentComplex.logger.error(e);
        file = new SchematicFile((short) 0, (short) 0, (short) 0);
    }
    transform = RCAxisAlignedTransform.read(compound, "rotation", "mirrorX");
    lowerCoord = BlockPositions.readFromNBT("lowerCoord", compound);
}
Also used : SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile)

Example 3 with SchematicFile

use of ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile in project RecurrentComplex by Ivorforce.

the class CommandConvertSchematic 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);
    if (args.length < 1)
        throw RecurrentComplex.translations.wrongUsageException("commands.rcconvertschematic.usage");
    ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
    String schematicName = parameters.get(0).require();
    String structureID = parameters.get("id").optional().orElse(schematicName);
    SchematicFile schematicFile = CommandImportSchematic.parseSchematic(schematicName);
    GenericStructure from = parameters.get("from").to(RCP::structureFromBlueprint, commandSender).require();
    from.worldDataCompound = CommandExportSchematic.toWorldData(schematicFile).createTagCompound();
    PacketEditStructureHandler.openEditStructure(player, from, player.getPosition(), structureID, directory);
}
Also used : SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) Parameters(ivorius.mcopts.commands.parameters.Parameters) 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 SchematicFile

use of ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile in project RecurrentComplex by Ivorforce.

the class CommandExportSchematic 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);
    BlockArea area = selectionOwner.getSelection();
    RCCommands.assertSize(commandSender, selectionOwner);
    String structureName = parameters.get(0).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(RecurrentComplex.translations.format("commands.strucExportSchematic.success", RCTextStyle.visit(getValidatedSchematicsFile(), "schematics/" + structureName)));
}
Also used : 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 5 with SchematicFile

use of ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile in project RecurrentComplex by Ivorforce.

the class CommandExportSchematic method toSchematic.

public static SchematicFile toSchematic(IvWorldData worldData) {
    SchematicFile schematicFile = new SchematicFile((short) worldData.blockCollection.width, (short) worldData.blockCollection.height, (short) worldData.blockCollection.length);
    for (BlockPos pos : BlockAreas.mutablePositions(worldData.blockCollection.area())) schematicFile.setBlockState(pos, worldData.blockCollection.getBlockState(pos));
    schematicFile.entityCompounds.addAll(worldData.entities);
    schematicFile.tileEntityCompounds.addAll(worldData.tileEntities);
    return schematicFile;
}
Also used : SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

SchematicFile (ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile)5 BlockPos (net.minecraft.util.math.BlockPos)3 Parameters (ivorius.mcopts.commands.parameters.Parameters)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)1 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)1 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)1 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)1 RCP (ivorius.reccomplex.commands.parameters.RCP)1 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)1 OperationGenerateSchematic (ivorius.reccomplex.operation.OperationGenerateSchematic)1 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1