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.
This commit is contained in:
shedaniel
2024-12-04 02:23:19 +08:00
parent fc59510c0a
commit 689ba0b8b9
2 changed files with 31 additions and 1 deletions

View File

@@ -403,6 +403,30 @@ public class RunConfigSettings implements Named {
forgeTemplate("data");
}
/**
* Configure run config with the default data options.
*
* <p>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.
*
* <p>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.
*

View File

@@ -66,7 +66,13 @@ public record ForgeRunTemplate(
public static final Codec<Map<String, ForgeRunTemplate>> MAP_CODEC = Codec.unboundedMap(Codec.STRING, CODEC)
.xmap(
map -> {
final Map<String, ForgeRunTemplate> newMap = new HashMap<>(map);
final Map<String, ForgeRunTemplate> newMap = new HashMap<>();
// TODO: Remove this hack once we patch DLI to support clientData as env
for (Map.Entry<String, ForgeRunTemplate> 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