package xyz.papermodloader.tree.task;

import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.apache.commons.io.IOUtils;
import xyz.papermodloader.tree.Constants;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

public class MakeMinecraftTask extends DefaultTask {
    @TaskAction
    public void doTask() throws IOException {
        ZipFile merged = new ZipFile(Constants.DEOBF_MERGED_JAR_CACHE.get());
        ZipFile client = new ZipFile(Constants.CLIENT_JAR_CACHE.get());
        File libraryJar = Constants.MINECRAFT_LIBRARY_JAR_CACHE.get();
        if (!libraryJar.exists()) {
            libraryJar.createNewFile();
        }
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(libraryJar));
        Enumeration<? extends ZipEntry> entries = client.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.getName().startsWith("assets")) {
                out.putNextEntry(entry);
                IOUtils.copy(client.getInputStream(entry), out);
                out.closeEntry();
            }
        }
        entries = merged.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            out.putNextEntry(entry);
            IOUtils.copy(merged.getInputStream(entry), out);
            out.closeEntry();
        }
        out.close();
        merged.close();
    }
}

@@ -32,16 +32,56 @@
 .task;%0A%0A
+import org.apache.commons.io.FileUtils;%0A
 import o
@@ -1323,32 +1323,187 @@
     %7D%0A        %7D%0A
+        out.putNextEntry(new ZipEntry(%221.10.2.mappings%22));%0A        FileUtils.copyFile(Constants.MAPPINGS_FILE_CACHE.get(), out);%0A        out.closeEntry();%0A
         entries 

Package mappings file with minecraft jar