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);
}
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);
}
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);
}
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)));
}
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;
}
Aggregations