Skip to content

NBTElementHelper.NBTNumberHelper ​

com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTNumberHelper

Since1.5.1

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 ​

asByte(): byteSince1.5.1#
Returns this numeric tag converted to a byte.
Returns: the value converted to byte

asDouble ​

asDouble(): doubleSince1.5.1#
Returns this numeric tag converted to a double.
Returns: the value converted to double

asFloat ​

asFloat(): floatSince1.5.1#
Returns this numeric tag converted to a float.
Returns: the value converted to float

asInt ​

asInt(): intSince1.5.1#
Returns this numeric tag converted to an int.
Returns: the value converted to int

asLong ​

asLong(): longSince1.5.1#
Returns this numeric tag converted to a long.
Returns: the value converted to long

asNumber ​

asNumber(): NumberSince1.5.1#
Returns the boxed value in this tag's original numeric type.
Returns: the boxed numeric value in its original type

asShort ​

asShort(): shortSince1.5.1#
Returns this numeric tag converted to a short.
Returns: the value converted to short