# NBTElementHelper.NBTListHelper

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

**Since:** 1.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](NBTElementHelper.md).

## Constructors

### new NBTElementHelper.NBTListHelper {#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_constructor-CollectionTag-}

```js
new NBTElementHelper.NBTListHelper(CollectionTag base)
```

Wraps the supplied collection tag without copying it.

**Parameters:**
- `base`: the collection tag to wrap

## Methods

### asUUID {#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_asUUID-}

```js
asUUID(): UUID
```

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

**Since:** 1.8.3

### get {#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_get-int-}

```js
get(int index): NBTElementHelper<?>
```

Returns the element at the zero-based index. An index outside the collection throws
[IndexOutOfBoundsException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IndexOutOfBoundsException.html).

**Parameters:**
- `index`: zero-based index

**Returns:** the element at that index

**Since:** 1.5.1

### getHeldType {#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_getHeldType-}

```js
getHeldType(): int
```

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

**Since:** 1.5.1

### isPossiblyUUID {#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_isPossiblyUUID-}

```js
isPossiblyUUID(): boolean
```

Returns whether this tag is a four-entry int array, the shape accepted by [asUUID()](#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_asUUID-).

**Returns:** `true` if this is a four-entry int array; `false` otherwise

**Since:** 1.8.3

### length {#com.jsmacrosce.jsmacros.client.api.helper.NBTElementHelper.NBTListHelper_length-}

```js
length(): int
```

Returns the number of elements in this list or array.

**Returns:** the number of elements

**Since:** 1.5.1
