Search in sources :

Example 6 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure 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);
}
Also used : GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) PacketEditStructureHandler(ivorius.reccomplex.network.PacketEditStructureHandler) ivorius.mcopts.commands.parameters(ivorius.mcopts.commands.parameters) RCConfig(ivorius.reccomplex.RCConfig) CommandExpecting(ivorius.mcopts.commands.CommandExpecting) RCE(ivorius.reccomplex.commands.parameters.expect.RCE) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) Expect(ivorius.mcopts.commands.parameters.expect.Expect) ICommandSender(net.minecraft.command.ICommandSender) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 7 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure 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);
}
Also used : Parameters(ivorius.mcopts.commands.parameters.Parameters) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 8 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.

the class CommandImportStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    String structureID = parameters.get(0).require();
    Structure<?> structure = parameters.get(0).to(RCP::structure).require();
    WorldServer world = parameters.get("dimension").to(MCP.dimension(server, sender)).require();
    AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(AxisAlignedTransform2D.ORIGINAL);
    BlockPos pos = parameters.get(MCP.pos("x", "y", "z", sender.getPosition(), false)).require();
    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 (parameters.has("select"))
        RCCommands.select(sender, RCBlockAreas.from(boundingBox));
}
Also used : OperationGenerateStructure(ivorius.reccomplex.operation.OperationGenerateStructure) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 9 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.

the class CommandLookupStructure method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    String id = parameters.get(0).require();
    GenericStructure structure = parameters.get(0).to(p -> RCP.genericStructure(p, false)).require();
    Metadata metadata = structure.metadata;
    boolean hasWeblink = !metadata.weblink.trim().isEmpty();
    ITextComponent weblink = hasWeblink ? new TextComponentString(RCStrings.abbreviateFormatted(metadata.weblink, 30)) : RecurrentComplex.translations.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(RecurrentComplex.translations.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(RecurrentComplex.translations.format("commands.rclookup.reply.comment", metadata.comment));
}
Also used : GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) TextFormatting(net.minecraft.util.text.TextFormatting) ClickEvent(net.minecraft.util.text.event.ClickEvent) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) RCStrings(ivorius.reccomplex.utils.RCStrings) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) ivorius.mcopts.commands.parameters(ivorius.mcopts.commands.parameters) RCConfig(ivorius.reccomplex.RCConfig) CommandExpecting(ivorius.mcopts.commands.CommandExpecting) RCE(ivorius.reccomplex.commands.parameters.expect.RCE) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) RCP(ivorius.reccomplex.commands.parameters.RCP) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) Expect(ivorius.mcopts.commands.parameters.expect.Expect) ICommandSender(net.minecraft.command.ICommandSender) HoverEvent(net.minecraft.util.text.event.HoverEvent) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) Metadata(ivorius.reccomplex.world.gen.feature.structure.generic.Metadata) HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Metadata(ivorius.reccomplex.world.gen.feature.structure.generic.Metadata) ITextComponent(net.minecraft.util.text.ITextComponent) TextComponentString(net.minecraft.util.text.TextComponentString) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 10 with GenericStructure

use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure 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;
}
Also used : IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) IvWorldData(ivorius.ivtoolkit.tools.IvWorldData) MockWorld(ivorius.ivtoolkit.world.MockWorld) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) RCP(ivorius.reccomplex.commands.parameters.RCP) Nonnull(javax.annotation.Nonnull)

Aggregations

GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)19 BlockPos (net.minecraft.util.math.BlockPos)7 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)6 StructureGenerator (ivorius.reccomplex.world.gen.feature.StructureGenerator)6 WorldServer (net.minecraft.world.WorldServer)6 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)5 Parameters (ivorius.mcopts.commands.parameters.Parameters)5 RCP (ivorius.reccomplex.commands.parameters.RCP)5 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 OperationGenerateStructure (ivorius.reccomplex.operation.OperationGenerateStructure)4 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)3 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)3 RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)3 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BlockPositions (ivorius.ivtoolkit.blocks.BlockPositions)2 MockWorld (ivorius.ivtoolkit.world.MockWorld)2 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)2 ivorius.mcopts.commands.parameters (ivorius.mcopts.commands.parameters)2