Closed Shadows-of-Fire closed 4 days ago
Last commit published: 0b751ef163406e0651c7c8238c409457b2d624b6.
Since Gson already takes a string for its indent, why not do the same for this?
I used an atomic int here because the field is in an interface (meaning it has to be final
) and I wanted to keep anything centralized.
So why not AtomicReference<String>
?
I don't think anyone needs to be using non-spaces as the indentation. There's the possibility someone wants to use tabs, but in the name of whole ecosystem consistency, use of spaces everywhere is likely to shake out as the best case.
Additionally, INTENT_WIDTH.set(4)
is less error prone than INDENT.set(" ")
. A reader can immediately know the number of spaces when reading the code without having to count them.
I don't think bringing up consistency is fair, as this PR generally reduces that, but the readability point is fair.
🚀 This PR has been released as NeoForge version 21.3.32-beta
.
Not sure if helpful, but if people do want to use tabs (or format the JSON in another way), you can wrap the CachedOutput
instance to reformat the files before writing them. It's a bit of a hack, but saves mixins in awkward places :).
Pretty straightforward. I wanted to do this, was going to do it with a mixin, and then saw that the location is in a lambda. I didn't want to spin up a coremod for it and deal with the mess that is lambda-mixins, so I figured why not just patch the thing in.
Modders can set the value by calling
DataProvider.INDENT_WIDTH.set(...)
. I'll backport this to 1.21.1 after this PR is complete.