-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.21.x] Allow changing datagen indent width (#1687)
The width can be changed by using `DataProvider.INDENT_WIDTH`
- Loading branch information
1 parent
0d3c57d
commit 402a980
Showing
1 changed file
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|