Skip to content
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 Array Tags Type Validation #38

Open
Offroaders123 opened this issue Nov 7, 2023 · 0 comments
Open

SNBT Array Tags Type Validation #38

Offroaders123 opened this issue Nov 7, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Offroaders123
Copy link
Owner

Realized that currently I'm not validating the tag types present in ByteArray, IntArray, and LongArray tags when reading them from an SNBT string. I really need/want to rework my current SNBT parser, it's a bit haywire because I built it from a few different sources, and also made it my own. So it's kind of a monkey-patched mess a bit still hehe.

@Offroaders123 Offroaders123 added the bug Something isn't working label Nov 7, 2023
@Offroaders123 Offroaders123 self-assigned this Nov 7, 2023
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant