From 73c606bf8ea782ffd2fb35597a5991add8c78af7 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Tue, 5 Mar 2024 23:04:55 +0100 Subject: Add searge enricher --- src/main/java/moe/nea/zwirn/Zwirn.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main/java/moe/nea/zwirn/Zwirn.java') diff --git a/src/main/java/moe/nea/zwirn/Zwirn.java b/src/main/java/moe/nea/zwirn/Zwirn.java index 746c993..3612007 100644 --- a/src/main/java/moe/nea/zwirn/Zwirn.java +++ b/src/main/java/moe/nea/zwirn/Zwirn.java @@ -3,6 +3,10 @@ package moe.nea.zwirn; import net.fabricmc.stitch.commands.tinyv2.TinyFile; import org.jetbrains.annotations.NotNull; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; import java.util.List; public class Zwirn { @@ -17,6 +21,21 @@ public class Zwirn { return new TinyMerger(base, overlay, sharedNamespace).merge(); } + public static @NotNull TinyFile enrichSeargeWithMCP(@NotNull TinyFile searge, @NotNull Path mcpArchiveRoot) throws IOException { + if (!searge.getHeader().getNamespaces().equals(Arrays.asList("left", "right"))) + throw new IllegalArgumentException("Searge namespaces need to be left and right"); + var fields = mcpArchiveRoot.resolve("fields.csv"); + var methods = mcpArchiveRoot.resolve("methods.csv"); + var params = mcpArchiveRoot.resolve("params.csv"); + if (!Files.exists(fields)) + throw new IllegalArgumentException("Missing fields.csv"); + if (!Files.exists(methods)) + throw new IllegalArgumentException("Missing methods.csv"); + if (!Files.exists(params)) + throw new IllegalArgumentException("Missing params.csv"); + return new EnrichSeargeWithMCP(searge, fields, methods, params).mergeTinyFile(); + } + public static @NotNull TinyFile createOverlayTinyFile( @NotNull TinyFile base, @NotNull TinyFile overlay, @NotNull List<@NotNull String> retainedNamespaces, -- cgit