Skip to content

NBTElementHelper.NBTCompoundHelper ​

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

Since1.5.1

Wraps a compound tag and provides access to its keys and values.

js
const player = Player.getPlayer();  
if (player !== null) {
 const nbt = player.getMainHand().getNBT();  
 if (nbt instanceof NBTHelpers.Compound) {
   Chat.log(nbt.getKeys());  
 }
}

Available in scripts as NBTHelpers.Compound.

Nested type declared in NBTElementHelper.

Constructors ​

new NBTElementHelper.NBTCompoundHelper ​

new NBTElementHelper.NBTCompoundHelper(CompoundTag base)#
Wraps the supplied compound tag without copying it.

Parameters:

  • base: the compound tag to wrap

Methods ​

asString ​

asString(String key): StringSince1.5.1#
Returns the string value under key, or its textual representation for non-string tags.

Parameters:

  • key: the key to retrieve
Returns: the value's string or textual representation, or null if absent
asString(): StringSince1.5.1#
Returns the string value for string tags, or the tag's textual representation otherwise.
Returns: the string value or textual representation

get ​

get(String key): NBTElementHelper<?>Since1.5.1#
Returns the value under key, or null if absent.

Parameters:

  • key: the key to retrieve
Returns: the value, or null if absent

getKeys ​

getKeys(): Set<String>Since1.6.0#
Returns the compound's live key set.
Returns: the key set backed by the compound

getType ​

getType(String key): intSince1.8.4#
Returns the tag type id for the value under key, or -1 if absent.

Parameters:

  • key: the key to check
Returns: the value's tag type id, or -1 if absent
getType(): intSince1.5.1#
Returns this tag's Minecraft NBT type id; see the class documentation for the mapping.
Returns: this tag's NBT type id

has ​

has(String key): booleanSince1.5.1#
Returns whether this compound contains key.

Parameters:

  • key: the key to check
Returns: true if the key is present