use of ivorius.ivtoolkit.math.AxisAlignedTransform2D in project RecurrentComplex by Ivorforce.
the class CommandPaste method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "mirror", "generate", "select");
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
RCEntityInfo entityInfo = RCCommands.getStructureEntityInfo(entityPlayerMP, null);
NBTTagCompound worldData = entityInfo.getWorldDataClipboard();
if (worldData == null)
throw ServerTranslations.commandException("commands.strucPaste.noClipboard");
WorldServer world = (WorldServer) sender.getEntityWorld();
BlockPos pos = parameters.pos("x", "y", "z", sender.getPosition(), false).require();
AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
String seed = parameters.get("seed").first().optional().orElse(null);
boolean generate = parameters.has("generate");
boolean select = parameters.has("select");
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 (select) {
StructureGenerator<?> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
// Can never not place so don't handle
//noinspection OptionalGetWithoutIsPresent
StructureBoundingBox boundingBox = generator.boundingBox().get();
SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
owner.setSelection(RCBlockAreas.from(boundingBox));
}
}
use of ivorius.ivtoolkit.math.AxisAlignedTransform2D 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));
}
}
use of ivorius.ivtoolkit.math.AxisAlignedTransform2D in project RecurrentComplex by Ivorforce.
the class CommandImportSchematic method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "mirror");
if (args.length < 1)
throw ServerTranslations.wrongUsageException("commands.rcimportschematic.usage");
SchematicFile schematicFile = parseSchematic(parameters.get().first().require());
BlockPos pos = parameters.pos("x", "y", "z", commandSender.getPosition(), false).require();
AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
OperationRegistry.queueOperation(new OperationGenerateSchematic(schematicFile, transform, pos), commandSender);
}
use of ivorius.ivtoolkit.math.AxisAlignedTransform2D 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);
}
use of ivorius.ivtoolkit.math.AxisAlignedTransform2D 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));
}
}
Aggregations