use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandDecorate method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
BlockSurfaceArea area = new BlockSurfaceArea(parameters.iv().surfacePos(commandSender.getPosition(), false).require(), parameters.iv().move(2).surfacePos(commandSender.getPosition(), false).require());
BlockSurfaceArea chunkArea = new BlockSurfaceArea(getChunkPos(area.getPoint1()), getChunkPos(area.getPoint2()));
Predicate<Structure> structurePredicate = parameters.rc("exp").structurePredicate().optional().orElse(structureInfo -> true);
WorldServer world = (WorldServer) commandSender.getEntityWorld();
chunkArea.forEach(coord -> WorldGenStructures.decorate(world, world.rand, new ChunkPos(coord.x, coord.z), structurePredicate));
}
use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandPreview method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
EntityPlayer player = getCommandSenderAsPlayer(commandSender);
RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
Operation.PreviewType previewType = parameters.get().first().map(Operation.PreviewType::find, s -> ServerTranslations.commandException("commands.rcpreview.invalid")).require();
RCEntityInfo.setPreviewType(previewType);
RCEntityInfo.sendPreviewTypeToClients(player);
commandSender.sendMessage(ServerTranslations.format("commands.rcpreview.success", previewType.key));
}
use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandGenerateStructure method execute.
@Override
@ParametersAreNonnullByDefault
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(null);
GenerationType generationType = parameters.rc("gen").generationType(structure).require();
BlockSurfacePos pos = parameters.surfacePos("x", "z", sender.getPosition(), false).require();
String seed = parameters.get("seed").first().optional().orElse(null);
boolean select = parameters.has("select");
Placer placer = generationType.placer();
StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).generationInfo(generationType).seed(RCStrings.seed(seed)).structureID(structureID).randomPosition(pos, placer).fromCenter(true).transform(transform);
Optional<StructureBoundingBox> boundingBox = generator.boundingBox();
if (!boundingBox.isPresent())
throw ServerTranslations.commandException("commands.strucGen.noPlace");
if (structure instanceof GenericStructure && world == sender.getEntityWorld()) {
GenericStructure genericStructureInfo = (GenericStructure) structure;
BlockPos lowerCoord = StructureBoundingBoxes.min(boundingBox.get());
OperationRegistry.queueOperation(new OperationGenerateStructure(genericStructureInfo, generationType.id(), generator.transform(), lowerCoord, false).withSeed(seed).withStructureID(structureID).prepare(world), sender);
} else {
if (generator.generate() == null)
throw ServerTranslations.commandException("commands.strucGen.noPlace");
}
if (select) {
SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
owner.setSelection(RCBlockAreas.from(boundingBox.get()));
}
}
use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandConvertSchematic method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
EntityPlayerMP player = getCommandSenderAsPlayer(commandSender);
if (args.length < 1)
throw ServerTranslations.wrongUsageException("commands.rcconvertschematic.usage");
String schematicName = parameters.get().first().require();
SchematicFile schematicFile = CommandImportSchematic.parseSchematic(schematicName);
GenericStructure structure = CommandExportStructure.getNewGenericStructure(commandSender, parameters.rc("from"));
structure.worldDataCompound = CommandExportSchematic.toWorldData(schematicFile).createTagCompound();
PacketEditStructureHandler.openEditStructure(structure, schematicName, player);
}
use of ivorius.reccomplex.commands.parameters.RCParameters 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));
}
Aggregations