From 689ba0b8b9e303d54b5663ba670eb7bda21d11dd Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 4 Dec 2024 02:23:19 +0800 Subject: [PATCH] Include a very bad workaround for NeoForge 1.21.4, we will revert this once we fix DLI DLI fails to parse the launch.cfg with clientDataArgs as keys when reading as client, since it would try to recognise what DataArgs is, when it is not even its entry. This is a temporary fix. --- .../configuration/ide/RunConfigSettings.java | 24 +++++++++++++++++++ .../providers/forge/ForgeRunTemplate.java | 8 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java b/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java index 64498e73..60b7e2c7 100644 --- a/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java +++ b/src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java @@ -403,6 +403,30 @@ public class RunConfigSettings implements Named { forgeTemplate("data"); } + /** + * Configure run config with the default data options. + * + *

This method can only be used on NeoForge. + */ + @ApiStatus.Experimental + public void clientData() { + ModPlatform.assertForgeLike(getExtension(), () -> "RunConfigSettings.clientData() is only usable on NeoForge."); + environment("dataClient"); + forgeTemplate("dataClient"); + } + + /** + * Configure run config with the default data options. + * + *

This method can only be used on NeoForge. + */ + @ApiStatus.Experimental + public void serverData() { + ModPlatform.assertForgeLike(getExtension(), () -> "RunConfigSettings.serverData() is only usable on NeoForge."); + environment("dataServer"); + forgeTemplate("dataServer"); + } + /** * Applies a Forge run config template to these settings. * diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/forge/ForgeRunTemplate.java b/src/main/java/net/fabricmc/loom/configuration/providers/forge/ForgeRunTemplate.java index 624a2630..ce01ce1c 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/forge/ForgeRunTemplate.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/forge/ForgeRunTemplate.java @@ -66,7 +66,13 @@ public record ForgeRunTemplate( public static final Codec> MAP_CODEC = Codec.unboundedMap(Codec.STRING, CODEC) .xmap( map -> { - final Map newMap = new HashMap<>(map); + final Map newMap = new HashMap<>(); + + // TODO: Remove this hack once we patch DLI to support clientData as env + for (Map.Entry entry : map.entrySet()) { + String name = entry.getKey().replaceAll("clientData", "dataClient").replaceAll("serverData", "dataServer"); + newMap.put(name, entry.getValue()); + } // Iterate through all templates and fill in empty names. // The NeoForge format doesn't include the name property, so we'll use the map keys