NBTCompound

public class NBTCompound extends AbstractMap<K, V>

A map-like structure for storing NBT tags associated with unique UTF-8 (modified) names.

Nesting

If a compound is inside another compound, the inner one is considered to be "nested", and the outer one is its "parent". To access the nested compound's contents, you would first need to get it from its parent, check that it is not null, and then repeat for any further nested compounds. To avoid this, the implementation allows you to use dot-notation in these cases. More specifically, dot-notation is valid in methods that cannot alter the structure of the compound (and those that accept a tag name), like getter and contains methods.

Consider the following NBT data:


{
  user: {
    name: "User291",
    id: "ae630aa9-cdbb-4aaf-be42-868889585b4d",
    coins: 19531L,
    social_media: {
      discord: "Player291#4444",
      twitter: "User291",
      "i_have_a_dot_._in_me": true
    },
  }
}
In this case, to access the user's Discord username, we'd use the path
"user.social_media.discord"
To access the user's ID, we would use
"user.id"
And to access the entire user compound, just
"user"
If a tag's name has a literal dot (.) in it that does not indicate nesting, a backslash can be used to escape the character. This means using a double-backslash in string literals, such as
"user.social_media.i_have_a_dot_\\._in_me"

In any case, dot-notation is not required, and a compound's direct children can still be accessed normally using their respective names.

Author

Nullicorn

Constructors

Link copied to clipboard
public void NBTCompound()
Creates an empty NBT compound.

Functions

Link copied to clipboard
public void clear()
Link copied to clipboard
public V compute(K key, BiFunction<? extends Object, ? extends Object, ? extends V> remappingFunction)
Link copied to clipboard
public V computeIfAbsent(K key, Function<? extends Object, ? extends V> mappingFunction)
Link copied to clipboard
public V computeIfPresent(K key, BiFunction<? extends Object, ? extends Object, ? extends V> remappingFunction)
Link copied to clipboard
public boolean containsKey(Object key)
Same as containsTag(...), but true will be returned if any tag in the compound uses the key, regardless of the tag's type.
Link copied to clipboard
public boolean containsTag(String name, TagType type)
Link copied to clipboard
public boolean containsValue(Object value)
Link copied to clipboard
public static Map<K, V> copyOf<K, V>(Map<? extends K, ? extends V> map)
Link copied to clipboard
public static Map.Entry<K, V> entry<K, V>(K k, V v)
Link copied to clipboard
public Set<Map.Entry<String, Object>> entrySet()
Link copied to clipboard
public boolean equals(Object o)
Link copied to clipboard
public void forEach(BiConsumer<? extends Object, ? extends Object> action)
Link copied to clipboard
public Object get(Object name)
Retrieves the value of a tag inside the compound.
Link copied to clipboard
public byte getByte(String name, byte defaultValue)
Link copied to clipboard
public Array<byte> getByteArray(String name)
Link copied to clipboard
public NBTCompound getCompound(String name)
Link copied to clipboard
public double getDouble(String name, double defaultValue)
Link copied to clipboard
public float getFloat(String name, float defaultValue)
Link copied to clipboard
public int getInt(String name, int defaultValue)
Link copied to clipboard
public Array<int> getIntArray(String name)
Link copied to clipboard
public NBTList getList(String name)
Link copied to clipboard
public long getLong(String name, long defaultValue)
Link copied to clipboard
public Array<long> getLongArray(String name)
Link copied to clipboard
public Number getNumber(String name, Number defaultValue)
Link copied to clipboard
public V getOrDefault(Object key, V defaultValue)
Link copied to clipboard
public short getShort(String name, short defaultValue)
Link copied to clipboard
public String getString(String name)
Same as getString, but the default value is always null.
public String getString(String name, String defaultValue)
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public boolean isEmpty()
Link copied to clipboard
public Set<String> keySet()
Link copied to clipboard
public V merge(    K key,     V value,     BiFunction<? extends Object, ? extends Object, ? extends V> remappingFunction)
Link copied to clipboard
public static Map<K, V> of<K, V>()
Link copied to clipboard
public static Map<K, V> ofEntries<K, V>(Array<Map.Entry<? extends K, ? extends V>> entries)
Link copied to clipboard
public Object put(String name, Object value)
Link copied to clipboard
public void putAll(Map<? extends K, ? extends V> m)
Link copied to clipboard
public Object putIfAbsent(String name, Object value)
Link copied to clipboard
public Object remove(Object name)
public boolean remove(Object name, Object value)
Link copied to clipboard
public V replace(K key, V value)
public boolean replace(    K key,     V oldValue,     V newValue)
Link copied to clipboard
public void replaceAll(BiFunction<? extends Object, ? extends Object, ? extends V> function)
Link copied to clipboard
public int size()
Link copied to clipboard
public String toString()
Link copied to clipboard
public Collection<Object> values()