Class NbtOps

java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.DynamicOps<net.minecraft.nbt.Tag>
com.github.darksoulq.abyssallib.common.serialization.ops.NbtOps

public class NbtOps extends DynamicOps<net.minecraft.nbt.Tag>
A DynamicOps implementation for Minecraft's NBT Tag system.

This implementation enables direct serialization and deserialization of values using native NBT structures (CompoundTag, ListTag, numeric tags, etc.) without intermediate conversion layers.

  • Field Details

    • INSTANCE

      public static final NbtOps INSTANCE
      Singleton instance of NbtOps.
  • Method Details

    • createString

      public net.minecraft.nbt.Tag createString(String value)
      Creates a string tag.
      Specified by:
      createString in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - string value
      Returns:
      StringTag wrapping the value
    • createByte

      public net.minecraft.nbt.Tag createByte(byte value)
      Creates a byte tag.
      Specified by:
      createByte in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - byte value
      Returns:
      ByteTag wrapping the value
    • createShort

      public net.minecraft.nbt.Tag createShort(short value)
      Creates a short tag.
      Specified by:
      createShort in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - short value
      Returns:
      ShortTag wrapping the value
    • createInt

      public net.minecraft.nbt.Tag createInt(int value)
      Creates an int tag.
      Specified by:
      createInt in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - int value
      Returns:
      IntTag wrapping the value
    • createLong

      public net.minecraft.nbt.Tag createLong(long value)
      Creates a long tag.
      Specified by:
      createLong in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - long value
      Returns:
      LongTag wrapping the value
    • createFloat

      public net.minecraft.nbt.Tag createFloat(float value)
      Creates a float tag.
      Specified by:
      createFloat in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - float value
      Returns:
      FloatTag wrapping the value
    • createDouble

      public net.minecraft.nbt.Tag createDouble(double value)
      Creates a double tag.
      Specified by:
      createDouble in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - double value
      Returns:
      DoubleTag wrapping the value
    • createBoolean

      public net.minecraft.nbt.Tag createBoolean(boolean value)
      Creates a boolean tag (stored as a byte).
      Specified by:
      createBoolean in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      value - boolean value
      Returns:
      ByteTag representing true/false
    • createList

      public net.minecraft.nbt.Tag createList(List<net.minecraft.nbt.Tag> elements)
      Creates a list tag.
      Specified by:
      createList in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      elements - list of tags
      Returns:
      ListTag containing elements
    • createMap

      public net.minecraft.nbt.Tag createMap(Map<net.minecraft.nbt.Tag, net.minecraft.nbt.Tag> map)
      Creates a compound tag from key-value pairs.
      Specified by:
      createMap in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      map - map of tags
      Returns:
      CompoundTag representing the map
    • getStringValue

      public Optional<String> getStringValue(net.minecraft.nbt.Tag input)
      Extracts a string value from a tag.
      Specified by:
      getStringValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional string value
    • getNumberValue

      public Optional<Number> getNumberValue(net.minecraft.nbt.Tag input)
      Extracts a numeric value from a tag.
      Specified by:
      getNumberValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional number value
    • getIntValue

      public Optional<Integer> getIntValue(net.minecraft.nbt.Tag input)
      Extracts an integer value from a tag.
      Specified by:
      getIntValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional integer value
    • getLongValue

      public Optional<Long> getLongValue(net.minecraft.nbt.Tag input)
      Extracts a long value from a tag.
      Specified by:
      getLongValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional long value
    • getFloatValue

      public Optional<Float> getFloatValue(net.minecraft.nbt.Tag input)
      Extracts a float value from a tag.
      Specified by:
      getFloatValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional float value
    • getDoubleValue

      public Optional<Double> getDoubleValue(net.minecraft.nbt.Tag input)
      Extracts a double value from a tag.
      Specified by:
      getDoubleValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional double value
    • getBooleanValue

      public Optional<Boolean> getBooleanValue(net.minecraft.nbt.Tag input)
      Extracts a boolean value from a tag.
      Specified by:
      getBooleanValue in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional boolean value
    • getList

      public Optional<List<net.minecraft.nbt.Tag>> getList(net.minecraft.nbt.Tag input)
      Extracts a list from a tag.
      Specified by:
      getList in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional list of tags
    • getMap

      public Optional<Map<net.minecraft.nbt.Tag, net.minecraft.nbt.Tag>> getMap(net.minecraft.nbt.Tag input)
      Extracts a map from a compound tag.
      Specified by:
      getMap in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional map of tags
    • getKeys

      public Optional<Iterable<String>> getKeys(net.minecraft.nbt.Tag input)
      Returns keys from a compound tag.
      Specified by:
      getKeys in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      iterable of keys
    • size

      public OptionalInt size(net.minecraft.nbt.Tag input)
      Returns the size of a list or compound tag.
      Specified by:
      size in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      optional size
    • copy

      public net.minecraft.nbt.Tag copy(net.minecraft.nbt.Tag input)
      Creates a deep copy of a tag.
      Specified by:
      copy in class DynamicOps<net.minecraft.nbt.Tag>
      Parameters:
      input - input tag
      Returns:
      copied tag
    • empty

      public net.minecraft.nbt.Tag empty()
      Returns the empty NBT value.
      Specified by:
      empty in class DynamicOps<net.minecraft.nbt.Tag>
      Returns:
      EndTag instance