Skip to content

Commit

Permalink
[1.21.x] Allow changing datagen indent width (#1687)
Browse files Browse the repository at this point in the history
The width can be changed by using `DataProvider.INDENT_WIDTH`
  • Loading branch information
Shadows-of-Fire authored Nov 18, 2024
1 parent 0d3c57d commit 402a980
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion patches/net/minecraft/data/DataProvider.java.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
--- 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<String> FIXED_ORDER_FIELDS = Util.make(new Object2IntOpenHashMap<>(), p_236070_ -> {
+ // Neo: conditions go first
+ p_236070_.put("neoforge:conditions", -1);
+ p_236070_.put("neoforge:ingredient_type", 0);
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);
}

0 comments on commit 402a980

Please sign in to comment.