Offroaders123 / NBTify

A library to read and write NBT files on the web!
http://npm.im/nbtify
MIT License
42 stars 5 forks source link

Boolean Primitive Writing #15

Closed Offroaders123 closed 1 year ago

Offroaders123 commented 1 year ago

Handling the JavaScript Boolean primitives as acceptable values when writing to raw NBT. They will be coerced to Byte tags first on the writing side, then also the reading side, so there will have to be a second layer to declare whether or not that key should be converted to a Boolean manually, or not. This is likely where the Minecraft type definitions and classes can handle that part of it. *Edit: #6

Offroaders123 commented 1 year ago

Supported! It was surprisingly easy to add, actually.

And a note about the last part of the issue message, you'd only have to convert the ByteTag to a boolean if you actually want the primitive true or false values back. If you type it as BooleanTag from the library, it can be any of the combinations that may happen, boolean | ByteTag<0 | 1>. So if you write your NBT object editing code to handle both boolean primitives, or the ByteTag value version, then you don't have to convert anything! It's still a boolean either way, just possibly not always the boolean primitive, specifically.