-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNBT Improved Error Parsing Messages #39
Labels
enhancement
New feature or request
Comments
Offroaders123
added a commit
that referenced
this issue
Nov 7, 2023
This is the real implementation for this. It actually didn't take too much to get it working! I'm not sure whether the SNBT parsing implementation should make it mandatory for Float and Double tags to have a decimal spot. Currently you don't need to have one for it to parse correctly. This change here now just ensures that the output SNBT will now always have decimal places for simple Float and Double values. #36 #38 #39 Offroaders123/Dovetail#5 https://stackoverflow.com/questions/175739/how-can-i-check-if-a-string-is-a-valid-number https://stackoverflow.com/questions/6134039/format-number-to-always-show-2-decimal-places (I thought it was going to be this one, but turns out it rounds the value, and forces the value to be within that length, unlike how I thought it was additive.) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed https://stackoverflow.com/questions/9838809/check-if-number-string-contains-decimal (I was going to use this next also, but then I realized that `Number.isInteger()` also covers the same thing, but with one less primitive type conversion, and a variable reference) https://www.youtube.com/watch?v=z1j3RI3ZpsQ (asmr :), sleepy programming made this commit message take longer to write than normal, was dozing off a little bit; man this time change is still hard, gaining an hour is hard too because when you want to go to bed/wake up, it's not time yet, so you have to wait another hour to get to your normal time)
Offroaders123
added a commit
that referenced
this issue
Nov 7, 2023
This actually worked out really well! Maybe I don't need to take the functional approach to organize things, the parameters still work great here too. I'm still up to trying to figure out that other approach though. To make the error show up in the test runner, you can make `listItemAssertion ` set to `false`, and it will show the error for trying to parse the broken file associated with that check. I'm still not totally sold on what to call the key for the RootTag, in the event that the root tag is indeed a ListTag. I still need to add this check, as well as these improved errors, to `#readArray()`, where each list item type can be validated as the correct type or not. #39 My eyes are getting so heavy/sleepy now, nearly done with these for the night.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A reference to the discussion from Offroaders123/Dovetail#5:
I think I can better accomplish this kind of handling if I bring the SNBT parser implementation back to a fully functional approach, rather than managing it with a class kind of thing. I can use callbacks of some sort which could allow the use of parameters that have the current key name and value or something like that, same with the current array index, item type, and other similar metadata-related things. It's like how you can use
[].map((item,index,array) => {})
to get information about the iteration, as well as the source data you're working with, right from the callback.Maybe I can look again into a more functional approach for the rest of the NBT reading and writing too, it doesn't have to be exclusively for SNBT handling. I do think the use of a class to manage the internal
ArrayBuffer
andDataView
references is a little simpler to understand than passing them around everywhere too though. So, we'll see about that one. I feel SNBT's work with string manipulation and appending is a bit more akin to simple return types though, hence why it works naturally with a functional approach. It's not as straightforward to do that for the NBT parsing/writing counterparts.The text was updated successfully, but these errors were encountered: