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

NBT: NumberBinaryTag should have access to Number #1087

Open
davidmayr opened this issue Jun 30, 2024 · 2 comments
Open

NBT: NumberBinaryTag should have access to Number #1087

davidmayr opened this issue Jun 30, 2024 · 2 comments

Comments

@davidmayr
Copy link

The NumberBinaryTag should have a simple way to get the java.lang.Number instance.

Why?
Having intValue(), floatValue() etc. is nice, however if you want to get the underlying number for further processing you would need to perform an instance of check on every single implementation to get the "real" number.

@RealBauHD
Copy link
Contributor

Don't quite understand your approach, all implementations store their number as a primitive data type, which is why issuing a Number object would lead to unnecessary overhead.
In addition, the Number object only has the exact same methods, which is why there is no basic number there either.

What exactly are you trying to do, maybe there is another approach?

@davidmayr
Copy link
Author

davidmayr commented Jun 30, 2024

Don't quite understand your approach, all implementations store their number as a primitive data type, which is why issuing a Number object would lead to unnecessary overhead.

That doesn't need to be changed. The Number wrapper could be created on demand.

What exactly are you trying to do, maybe there is another approach?

I'm looking to get the raw value of the binary tag for use in a conversion system (between nbt and raw types). Using any of the implementations like intValue() etc. would cast the number. The only proper way to get the actual value is to cast to each implementation (IntBinaryTag, LongBinaryTag, etc.) and get the value from there.
It works, but it is annoying. That's why I suggested that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants