Class NbtOps
java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.DynamicOps<net.minecraft.nbt.Tag>
com.github.darksoulq.abyssallib.common.serialization.ops.NbtOps
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.nbt.Tagcopy(net.minecraft.nbt.Tag input) Creates a deep copy of a tag.net.minecraft.nbt.TagcreateBoolean(boolean value) Creates a boolean tag (stored as a byte).net.minecraft.nbt.TagcreateByte(byte value) Creates a byte tag.net.minecraft.nbt.TagcreateDouble(double value) Creates a double tag.net.minecraft.nbt.TagcreateFloat(float value) Creates a float tag.net.minecraft.nbt.TagcreateInt(int value) Creates an int tag.net.minecraft.nbt.TagcreateList(List<net.minecraft.nbt.Tag> elements) Creates a list tag.net.minecraft.nbt.TagcreateLong(long value) Creates a long tag.net.minecraft.nbt.TagCreates a compound tag from key-value pairs.net.minecraft.nbt.TagcreateShort(short value) Creates a short tag.net.minecraft.nbt.TagcreateString(String value) Creates a string tag.net.minecraft.nbt.Tagempty()Returns the empty NBT value.getBooleanValue(net.minecraft.nbt.Tag input) Extracts a boolean value from a tag.getDoubleValue(net.minecraft.nbt.Tag input) Extracts a double value from a tag.getFloatValue(net.minecraft.nbt.Tag input) Extracts a float value from a tag.getIntValue(net.minecraft.nbt.Tag input) Extracts an integer value from a tag.getKeys(net.minecraft.nbt.Tag input) Returns keys from a compound tag.getList(net.minecraft.nbt.Tag input) Extracts a list from a tag.getLongValue(net.minecraft.nbt.Tag input) Extracts a long value from a tag.getMap(net.minecraft.nbt.Tag input) Extracts a map from a compound tag.getNumberValue(net.minecraft.nbt.Tag input) Extracts a numeric value from a tag.getStringValue(net.minecraft.nbt.Tag input) Extracts a string value from a tag.size(net.minecraft.nbt.Tag input) Returns the size of a list or compound tag.Methods inherited from class DynamicOps
compressMaps, convertTo, edit, edit, emptyList, emptyMap, exists, exists, mergeToList, mergeToMap, query, query, remove, remove, set, set
-
Field Details
-
INSTANCE
Singleton instance ofNbtOps.
-
-
Method Details
-
createString
Creates a string tag.- Specified by:
createStringin classDynamicOps<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:
createBytein classDynamicOps<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:
createShortin classDynamicOps<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:
createIntin classDynamicOps<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:
createLongin classDynamicOps<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:
createFloatin classDynamicOps<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:
createDoublein classDynamicOps<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:
createBooleanin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- boolean value- Returns:
- ByteTag representing true/false
-
createList
Creates a list tag.- Specified by:
createListin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
elements- list of tags- Returns:
- ListTag containing elements
-
createMap
Creates a compound tag from key-value pairs.- Specified by:
createMapin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
map- map of tags- Returns:
- CompoundTag representing the map
-
getStringValue
Extracts a string value from a tag.- Specified by:
getStringValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional string value
-
getNumberValue
Extracts a numeric value from a tag.- Specified by:
getNumberValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional number value
-
getIntValue
Extracts an integer value from a tag.- Specified by:
getIntValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional integer value
-
getLongValue
Extracts a long value from a tag.- Specified by:
getLongValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional long value
-
getFloatValue
Extracts a float value from a tag.- Specified by:
getFloatValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional float value
-
getDoubleValue
Extracts a double value from a tag.- Specified by:
getDoubleValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional double value
-
getBooleanValue
Extracts a boolean value from a tag.- Specified by:
getBooleanValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional boolean value
-
getList
Extracts a list from a tag.- Specified by:
getListin classDynamicOps<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:
getMapin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- optional map of tags
-
getKeys
Returns keys from a compound tag.- Specified by:
getKeysin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- input tag- Returns:
- iterable of keys
-
size
Returns the size of a list or compound tag.- Specified by:
sizein classDynamicOps<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:
copyin classDynamicOps<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:
emptyin classDynamicOps<net.minecraft.nbt.Tag>- Returns:
- EndTag instance
-