From 402a980bbe8581e7679ce934fd90a4f6a69bce01 Mon Sep 17 00:00:00 2001 From: Brennan Ward Date: Sun, 17 Nov 2024 22:52:05 -0800 Subject: [PATCH] [1.21.x] Allow changing datagen indent width (#1687) The width can be changed by using `DataProvider.INDENT_WIDTH` --- .../net/minecraft/data/DataProvider.java.patch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/patches/net/minecraft/data/DataProvider.java.patch b/patches/net/minecraft/data/DataProvider.java.patch index 07f5c148607..05ad535d98a 100644 --- a/patches/net/minecraft/data/DataProvider.java.patch +++ b/patches/net/minecraft/data/DataProvider.java.patch @@ -1,8 +1,14 @@ --- a/net/minecraft/data/DataProvider.java +++ b/net/minecraft/data/DataProvider.java -@@ -28,6 +_,9 @@ +@@ -27,7 +_,15 @@ + import org.slf4j.Logger; public interface DataProvider { ++ /** ++ * Neo: Allows changing the indentation width used by {@link #saveStable}. ++ */ ++ java.util.concurrent.atomic.AtomicInteger INDENT_WIDTH = new java.util.concurrent.atomic.AtomicInteger(2); ++ ToIntFunction FIXED_ORDER_FIELDS = Util.make(new Object2IntOpenHashMap<>(), p_236070_ -> { + // Neo: conditions go first + p_236070_.put("neoforge:conditions", -1); @@ -10,3 +16,12 @@ p_236070_.put("type", 0); p_236070_.put("parent", 1); p_236070_.defaultReturnValue(2); +@@ -72,7 +_,7 @@ + + try (JsonWriter jsonwriter = new JsonWriter(new OutputStreamWriter(hashingoutputstream, StandardCharsets.UTF_8))) { + jsonwriter.setSerializeNulls(false); +- jsonwriter.setIndent(" "); ++ jsonwriter.setIndent(" ".repeat(java.lang.Math.max(0, INDENT_WIDTH.get()))); // Neo: Allow changing the indent width without needing to mixin this lambda. + GsonHelper.writeValue(jsonwriter, p_254542_, KEY_COMPARATOR); + } +