use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.
the class CommandSetProperty method execute.
@Override
public void execute(MockWorld world, ICommandSender sender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
PositionedBlockExpression matcher = parameters.get("exp").orElse("").to(RCP::expression, new PositionedBlockExpression(RecurrentComplex.specialRegistry)).require();
String propertyName = parameters.get(0).require();
String propertyValue = parameters.get(1).require();
RCP.Shape shape = parameters.get("shape").to(RCP::shape).optional().orElse(RCP.Shape.cube);
Consumer<BlockPos> consumer = (BlockPos pos) -> {
PositionedBlockExpression.Argument at = PositionedBlockExpression.Argument.at(world, pos);
if (matcher.test(at))
TransformerProperty.withProperty(at.state, propertyName, propertyValue).ifPresent(state -> world.setBlockState(pos, state, 3));
};
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(sender, null, true);
RCCommands.assertSize(sender, selectionOwner);
CommandFill.runShape(shape, selectionOwner.getSelection(), consumer);
}
use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.
the class CommandVisitFiles method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(ResourceDirectory.ACTIVE);
OpenGlHelper.openFile(directory.toFile());
}
use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.
the class CommandEditStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(commandSender);
Parameters parameters = Parameters.of(args, expect()::declare);
ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
String structureID = parameters.get("id").optional().orElse(parameters.get(0).require());
GenericStructure base = parameters.get(0).to(p -> RCP.genericStructure(p, false)).require();
GenericStructure from = parameters.get("from").to(p -> RCP.genericStructure(p, false)).optional().orElse(base);
if (base != from) {
from = from.copyAsGenericStructure();
from.worldDataCompound = base.worldDataCompound.copy();
}
PacketEditStructureHandler.openEditStructure(entityPlayerMP, from, entityPlayerMP.getPosition(), structureID, directory);
}
use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.
the class CommandExportStructure 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);
ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
String structureID = parameters.get("id").optional().orElse(parameters.get(0).optional().orElse(null));
GenericStructure from = parameters.get(0).to(RCP::structureFromBlueprint, commandSender).require();
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
from.worldDataCompound = IvWorldData.capture(commandSender.getEntityWorld(), selectionOwner.getSelection(), true).createTagCompound();
PacketEditStructureHandler.openEditStructure(player, from, selectionOwner.getSelection().getLowerCorner(), structureID, directory);
}
use of ivorius.reccomplex.commands.parameters.RCP in project RecurrentComplex by Ivorforce.
the class CommandMapStructure method map.
@Nonnull
public static MapResult map(String structureID, @Nullable ResourceDirectory directory, ICommandSender commandSender, CommandVirtual command, String[] args, boolean inform) throws CommandException {
GenericStructure structure = Parameter.makeUp(null, 0, structureID).to(RCP::structure).require().copyAsGenericStructure();
if (structure == null) {
if (inform)
throw RecurrentComplex.translations.commandException("commands.structure.notGeneric", structureID);
return MapResult.SKIPPED;
}
IvWorldData worldData = structure.constructWorldData();
MockWorld world = new MockWorld.WorldData(worldData);
try {
command.execute(world, new SelectingSender(commandSender, BlockPos.ORIGIN, worldData.blockCollection.area().getHigherCorner()), args);
} catch (MockWorld.VirtualWorldException ex) {
throw RecurrentComplex.translations.commandException("commands.rcmap.nonvirtual.arguments");
}
structure.worldDataCompound = worldData.createTagCompound();
if (directory == null)
return MapResult.SUCCESS;
return PacketSaveStructureHandler.write(commandSender, structure, structureID, directory, true, inform) ? MapResult.SUCCESS : MapResult.FAILED;
}
Aggregations