NBTElementHelper.NBTNumberHelper
com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTNumberHelper
Wraps a numeric tag and provides conversions to primitive numeric types.
js
const player = Player.getPlayer();
if (player !== null) {
const nbt = player.getMainHand().getNBT();
if (nbt instanceof NBTHelpers.Number) {
Chat.log(`as int ${nbt.asInt()}, as double ${nbt.asDouble()}`);
}
}Available in scripts as NBTHelpers.Number.
Nested type declared in NBTElementHelper.
Constructors
new NBTElementHelper.NBTNumberHelper
new NBTElementHelper.NBTNumberHelper(NumericTag base)#Wraps the supplied numeric tag without copying it.
Parameters:
base: the numeric tag to wrap
Methods
asByte
Returns this numeric tag converted to a
byte.Returns: the value converted to
byteasDouble
Returns this numeric tag converted to a
double.Returns: the value converted to
doubleasFloat
Returns this numeric tag converted to a
float.Returns: the value converted to
floatasInt
Returns this numeric tag converted to an
int.Returns: the value converted to
intasLong
Returns this numeric tag converted to a
long.Returns: the value converted to
longasNumber
asShort
Returns this numeric tag converted to a
short.Returns: the value converted to
short