KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
679 stars 105 forks source link

NBT: NumberBinaryTag should have access to Number #1087

Open davidmayr opened 5 days ago

davidmayr commented 5 days ago

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 commented 5 days ago

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 commented 5 days ago

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