Ayfri
11/29/2022, 12:14 PMput
functions set as operator fun
so we can have an even fancier syntax :)
Also create operator fun plus
for NbtListAyfri
01/02/2023, 3:21 PMAyfri
01/02/2023, 3:21 PMBen Woodworth
01/03/2023, 12:58 AMNbtCompound(mutableMap)
and modifying the mutableMap
. That might be a hack though (and also probably not the nicest to work with). I copied the behavior of the JsonObject
and that's how its constructor is implementedMutableMap<String, MyValueType>
(or just NbtTag
for the value type if you want to leave it open-ended). That might be an option depending on what you're doingMutableNbtTag
classes. I've got a good idea how that'd work if you want me to help with thatNbtTag
types mutable, and it's something I put a ton of thought into and don't plan on supporting for a few reasons. Mainly because I want to keep the scope of the library to serialization, so it makes sense to treat NbtTag
as a representation of the serialized data (and serialized data is immutable). Plus that's the way kotlinx.serialization does it. There's also a lot of ways/assumptions in implementing separate mutable NbtTag
classes which makes me hesitant to add them alongside the read-only ones in a general-purpose library like knbt (how copying should work, concurrency since the encoder assumes a lot about the data's immutability, ...). I think it makes more sense to leave it up to the person doing the serializing & avoid the added scopeJsonObject
, and JsonArray
then 100% I'll follow suit with knbt. I'm kinda curious of they have a rationale, and might be worth opening an issue if you want, even just as a question for the insightAyfri
01/03/2023, 6:14 PMMutableNbtCompound
so (because it's precisely a mutable compound that I need) and it works like a charm using internally a mutableMap
^^