Search in sources :

Example 26 with RCParameters

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));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockSurfaceArea(ivorius.ivtoolkit.blocks.BlockSurfaceArea) WorldServer(net.minecraft.world.WorldServer) ChunkPos(net.minecraft.util.math.ChunkPos) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure)

Example 27 with RCParameters

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));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Operation(ivorius.reccomplex.operation.Operation) RCCommands(ivorius.reccomplex.commands.RCCommands) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Nullable(javax.annotation.Nullable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) Operation(ivorius.reccomplex.operation.Operation)

Example 28 with RCParameters

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()));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) Placer(ivorius.reccomplex.world.gen.feature.structure.Placer) WorldServer(net.minecraft.world.WorldServer) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 29 with RCParameters

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);
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 30 with RCParameters

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));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)39 BlockPos (net.minecraft.util.math.BlockPos)17 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)14 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)11 RCConfig (ivorius.reccomplex.RCConfig)8 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)8 ServerTranslations (ivorius.reccomplex.utils.ServerTranslations)8 Nullable (javax.annotation.Nullable)8 CommandException (net.minecraft.command.CommandException)8 ICommandSender (net.minecraft.command.ICommandSender)8 MinecraftServer (net.minecraft.server.MinecraftServer)8 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)7 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)7 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)7 List (java.util.List)7 WorldServer (net.minecraft.world.WorldServer)7 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)6 MockWorld (ivorius.ivtoolkit.world.MockWorld)6 CommandVirtual (ivorius.reccomplex.commands.CommandVirtual)6 RCCommands (ivorius.reccomplex.commands.RCCommands)6