Skip to content

NBTElementHelper.NBTListHelper ​

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

Since1.5.1

Provides indexed access to list and array tags, and converts four-int arrays to UUIDs.

js
const player = Player.getPlayer();  
if (player !== null) {
 const nbt = player.getMainHand().getNBT();  
 if (nbt instanceof NBTHelpers.List) {
   Chat.log(`${nbt.length()} entries, held type ${nbt.getHeldType()}`);  
 }
}

Available in scripts as NBTHelpers.List.

Nested type declared in NBTElementHelper.

Constructors ​

new NBTElementHelper.NBTListHelper ​

new NBTElementHelper.NBTListHelper(CollectionTag base)#
Wraps the supplied collection tag without copying it.

Parameters:

  • base: the collection tag to wrap

Methods ​

asUUID ​

asUUID(): UUIDSince1.8.3#
Returns the UUID represented by a four-entry int array, or null for other tags.
Returns: the UUID, or null if this is not a four-entry int array

get ​

get(int index): NBTElementHelper<?>Since1.5.1#
Returns the element at the zero-based index. An index outside the collection throws IndexOutOfBoundsException.

Parameters:

  • index: zero-based index
Returns: the element at that index

getHeldType ​

getHeldType(): intSince1.5.1#
Returns the component type id for byte, int, and long arrays. For lists, returns TAG_COMPOUND regardless of their elements.
Returns: the array component type id, or TAG_COMPOUND for a list

isPossiblyUUID ​

isPossiblyUUID(): booleanSince1.8.3#
Returns whether this tag is a four-entry int array, the shape accepted by asUUID().
Returns: true if this is a four-entry int array; false otherwise

length ​

length(): intSince1.5.1#
Returns the number of elements in this list or array.
Returns: the number of elements