Reformat JSON by wrapping CachedOutput

Rather than mixing-in to CachedOutput, we just wrap our DataProviders to
use a custom CachedOutput which reformats the JSON before writing. This
allows us to drop mixins for common+non-client code.
This commit is contained in:
Jonathan Coates
2024-01-21 17:50:59 +00:00
parent 1788afacfc
commit 359c8d6652
9 changed files with 69 additions and 69 deletions
-2
View File
@@ -58,7 +58,6 @@ minecraft {
"--existing", project(":common").file("src/main/resources/"),
"--existing", file("src/main/resources/"),
)
property("cct.pretty-json", "true")
}
fun RunConfig.configureForGameTest() {
@@ -110,7 +109,6 @@ mixin {
add(sourceSets.main.get(), "computercraft.refmap.json")
add(sourceSets.client.get(), "client-computercraft.refmap.json")
config("computercraft.mixins.json")
config("computercraft-client.mixins.json")
config("computercraft-client.forge.mixins.json")
}
@@ -51,12 +51,12 @@ public class Generators {
) implements DataProviders.GeneratorSink {
@Override
public <T extends DataProvider> T add(DataProvider.Factory<T> factory) {
return generator.addProvider(factory);
return generator.addProvider(p -> new PrettyDataProvider<>(factory.create(p))).provider();
}
@Override
public <T> void addFromCodec(String name, PackType type, String directory, Codec<T> codec, Consumer<BiConsumer<ResourceLocation, T>> output) {
generator.addProvider(out -> {
add(out -> {
Map<ResourceLocation, T> map = new HashMap<>();
output.accept(map::put);
return new JsonCodecProvider<>(out, existingFiles, ComputerCraftAPI.MOD_ID, JsonOps.INSTANCE, type, directory, codec, map);