Rotate Sponge schematic

Hello. Is there a way I can rotate a schemtic in the Sponge API? I need that for a plugin I am making

Assuming you want just the blocks from the schematics, you could iterate over each BlockVolume (which contain multiple blocks which you can then iterate over) which results in the BlockState of each block within the Volume. From there you know the position of block (from the iteration over the BlockVolume) and the blockstate, as well as the rotate position (the minimum blockposition). So you could then rotate the schematic that way. Ill provide some code in a min.

Edit:
Ive given examples on how to rotate, they are not correct (you can do the maths yourself) but this is how I would do it. I belive we talked on how to make a schematic file and the example I gave would only give a single BlockVolume, but my code support multiple. Also, this code isnt tested.

public static class BlockCollection {
    
    public static final int DEGREE_0 = 0;
    public static final int DEGREE_90 = 1;
    public static final int DEGREE_180 = 2;
    public static final int DEGREE_270 = 3;


    private Vector3i position;
    private Map<Vector3i, BlockState> map = new HashMap<>();
    
    public BlockCollection(int x, int y, int z){
        this(new Vector3i(x, y, z));
    }
    
    public BlockCollection(Vector3i vector3i){
        this.position = vector3i;
    }
    
    public Map<Vector3i, BlockState> getBlocks(){
        return this.map;
    }
    
    public void spawnBlocks(World world, int rotation){
        switch (rotation){
            case 0: 
                spawnBlocks(world, v -> v); 
                break;
            case 1:
                spawnBlocks(world, v -> {
                    Vector3i diff = v.min(this.position);
                    return this.position.add(new Vector3i(diff.getX(), diff.getY(), diff.getZ()));
                });
                break;
            case 2:
                spawnBlocks(world, v -> {
                    Vector3i diff = v.min(this.position);
                    return this.position.add(new Vector3i(diff.getX(), diff.getY(), diff.getZ()));
                });
                break;
            case 3:
                spawnBlocks(world, v -> {
                    Vector3i diff = v.min(this.position);
                    return this.position.add(new Vector3i(diff.getX(), diff.getY(), diff.getZ()));
                });
                break;
            default: throw new IllegalArgumentException("Unknown rotation");
        }
    }
    
    public void spawnBlocks(World world, Function<Vector3i, Vector3i> function){
        map.entrySet().forEach(e -> {
            world.setBlock(function.apply(e.getKey()), e.getValue());
        });
    }
    
}

public static Set<BlockCollection> toSetCollection(Schematic schematic){
    Set<BlockCollection> set = new HashSet<>();
    schematic.getBlockWorker().iterate((v, x, y, z) -> {
        BlockCollection collection = new BlockCollection(x, y, z);
        Vector3i max = v.getBlockMax();
        Vector3i min = v.getBlockMin();
        for(int x1 = min.getX(); x1 < max.getX(); x1++){
            for(int y1 = min.getY(); y1 < max.getY(); y1++){
                for(int z1 = min.getZ(); z1 < max.getZ(); z1++){
                    collection.map.put(new Vector3i(x1, y1, z1), v.getBlock(x1, y1, z1));
                }
            }
        }
        set.add(collection);
    });
    return set;
}