use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandLookupStructure 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();
Metadata metadata = structure.metadata;
boolean hasWeblink = !metadata.weblink.trim().isEmpty();
ITextComponent weblink = hasWeblink ? new TextComponentString(RCStrings.abbreviateFormatted(metadata.weblink, 30)) : ServerTranslations.format("commands.rclookup.reply.nolink");
if (hasWeblink) {
weblink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, metadata.weblink));
weblink.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(metadata.weblink)));
}
ITextComponent level = new TextComponentString(StructureRegistry.INSTANCE.status(id).getLevel().toString());
level.getStyle().setColor(TextFormatting.YELLOW);
commandSender.sendMessage(ServerTranslations.format(StructureRegistry.INSTANCE.hasActive(id) ? "commands.rclookup.reply.generates" : "commands.rclookup.reply.silent", id, RCTextStyle.users(metadata.authors), level, weblink));
if (!metadata.comment.trim().isEmpty())
commandSender.sendMessage(ServerTranslations.format("commands.rclookup.reply.comment", metadata.comment));
}
use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandMapAllStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
ResourceExpression expression = new ResourceExpression(StructureRegistry.INSTANCE::has);
IvOptional.ifAbsent(parameters.rc("exp").expression(expression).optional(), () -> expression.setExpression(""));
ResourceDirectory directory = parameters.rc("dir").resourceDirectory().optional().orElse(ResourceDirectory.ACTIVE);
CommandVirtual virtual = parameters.rc().virtualCommand(server).require();
int saved = 0, failed = 0, skipped = 0;
for (String id : StructureRegistry.INSTANCE.ids()) {
if (!expression.test(new RawResourceLocation(StructureRegistry.INSTANCE.status(id).getDomain(), id)))
continue;
Structure<?> info = StructureRegistry.INSTANCE.get(id);
if (!(info instanceof GenericStructure)) {
skipped++;
continue;
}
GenericStructure structure = (GenericStructure) info;
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(1).varargs());
} catch (MockWorld.VirtualWorldException ex) {
throw ServerTranslations.commandException("commands.rcmap.nonvirtual.arguments");
}
structure.worldDataCompound = worldData.createTagCompound();
if (PacketSaveStructureHandler.write(commandSender, structure, id, directory, true, false))
saved++;
else
failed++;
}
commandSender.sendMessage(ServerTranslations.format("commands.rcmapall.result", saved, RCTextStyle.path(directory), failed, skipped));
RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.CUSTOM);
RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.SERVER);
}
use of ivorius.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandExportStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
EntityPlayerMP player = getCommandSenderAsPlayer(commandSender);
String structureID = parameters.get().first().optional().orElse(null);
GenericStructure genericStructureInfo = getNewGenericStructure(commandSender, parameters.rc("from"));
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
genericStructureInfo.worldDataCompound = IvWorldData.capture(commandSender.getEntityWorld(), selectionOwner.getSelection(), true).createTagCompound();
PacketEditStructureHandler.openEditStructure(genericStructureInfo, structureID, player);
}
use of ivorius.reccomplex.commands.parameters.RCParameters 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.reccomplex.commands.parameters.RCParameters in project RecurrentComplex by Ivorforce.
the class CommandDecorateOne method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
WorldServer entityWorld = (WorldServer) commandSender.getEntityWorld();
BlockSurfacePos pos = parameters.iv().surfacePos(commandSender.getPosition(), false).require();
if (!WorldGenStructures.generateRandomStructureInChunk(entityWorld.rand, pos.chunkCoord(), entityWorld, entityWorld.getBiome(pos.blockPos(0))))
throw ServerTranslations.commandException("commands.rcdecorateone.none");
}
Aggregations