Class NbtOps
java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.DynamicOps<net.minecraft.nbt.Tag>
com.github.darksoulq.abyssallib.common.serialization.ops.NbtOps
An implementation of
DynamicOps for Minecraft's NBT Tag structure.
This class facilitates the direct serialization of objects into native NBT tags (CompoundTag, ListTag, IntTag, etc.) without intermediate JSON conversion.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.nbt.TagcreateBoolean(boolean value) Creates aByteTagrepresenting a boolean value.net.minecraft.nbt.TagcreateDouble(double value) Creates aDoubleTagfrom a double value.net.minecraft.nbt.TagcreateFloat(float value) Creates aFloatTagfrom a float value.net.minecraft.nbt.TagcreateInt(int value) Creates anIntTagfrom an integer value.net.minecraft.nbt.TagcreateList(List<net.minecraft.nbt.Tag> elements) Creates aListTagfrom a list of tags.net.minecraft.nbt.TagcreateLong(long value) Creates aLongTagfrom a long value.net.minecraft.nbt.TagCreates aCompoundTagfrom a map of tags.net.minecraft.nbt.TagcreateString(String value) Creates aStringTagfrom a string value.net.minecraft.nbt.Tagempty()Returns an empty tag representing no value (EndTag).getBooleanValue(net.minecraft.nbt.Tag input) Retrieves a boolean value from a tag.getDoubleValue(net.minecraft.nbt.Tag input) Retrieves a double value from a tag.getFloatValue(net.minecraft.nbt.Tag input) Retrieves a float value from a tag.getIntValue(net.minecraft.nbt.Tag input) Retrieves an integer value from a tag.getList(net.minecraft.nbt.Tag input) Retrieves a list of tags from a tag.getLongValue(net.minecraft.nbt.Tag input) Retrieves a long value from a tag.getMap(net.minecraft.nbt.Tag input) Retrieves a map of tags from a tag.getStringValue(net.minecraft.nbt.Tag input) Retrieves a string value from a tag.
-
Field Details
-
INSTANCE
Singleton instance of NbtOps.
-
-
Method Details
-
createString
Creates aStringTagfrom a string value.- Specified by:
createStringin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- The string to wrap.- Returns:
- The resulting StringTag.
-
createInt
public net.minecraft.nbt.Tag createInt(int value) Creates anIntTagfrom an integer value.- Specified by:
createIntin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- The integer to wrap.- Returns:
- The resulting IntTag.
-
createLong
public net.minecraft.nbt.Tag createLong(long value) Creates aLongTagfrom a long value.- Specified by:
createLongin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- The long to wrap.- Returns:
- The resulting LongTag.
-
createFloat
public net.minecraft.nbt.Tag createFloat(float value) Creates aFloatTagfrom a float value.- Specified by:
createFloatin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- The float to wrap.- Returns:
- The resulting FloatTag.
-
createDouble
public net.minecraft.nbt.Tag createDouble(double value) Creates aDoubleTagfrom a double value.- Specified by:
createDoublein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- The double to wrap.- Returns:
- The resulting DoubleTag.
-
createBoolean
public net.minecraft.nbt.Tag createBoolean(boolean value) Creates aByteTagrepresenting a boolean value.- Specified by:
createBooleanin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
value- The boolean to wrap (1 for true, 0 for false).- Returns:
- The resulting ByteTag.
-
createList
Creates aListTagfrom a list of tags.- Specified by:
createListin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
elements- The tags to include in the list.- Returns:
- A ListTag containing the elements.
-
createMap
Creates aCompoundTagfrom a map of tags.Keys in the map must be convertible to strings.
- Specified by:
createMapin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
map- The map of key-value tags.- Returns:
- A CompoundTag containing the map entries.
-
getStringValue
Retrieves a string value from a tag.- Specified by:
getStringValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the string if present.
-
getIntValue
Retrieves an integer value from a tag.- Specified by:
getIntValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the integer if present.
-
getLongValue
Retrieves a long value from a tag.- Specified by:
getLongValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the long if present.
-
getFloatValue
Retrieves a float value from a tag.- Specified by:
getFloatValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the float if present.
-
getDoubleValue
Retrieves a double value from a tag.- Specified by:
getDoubleValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the double if present.
-
getBooleanValue
Retrieves a boolean value from a tag.Typically parses a ByteTag where 0 is false and non-zero is true.
- Specified by:
getBooleanValuein classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the boolean if present.
-
getList
Retrieves a list of tags from a tag.- Specified by:
getListin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the list if the tag is a list type.
-
getMap
public Optional<Map<net.minecraft.nbt.Tag, net.minecraft.nbt.Tag>> getMap(net.minecraft.nbt.Tag input) Retrieves a map of tags from a tag.- Specified by:
getMapin classDynamicOps<net.minecraft.nbt.Tag>- Parameters:
input- The tag to inspect.- Returns:
- An Optional containing the map if the tag is a compound type.
-
empty
public net.minecraft.nbt.Tag empty()Returns an empty tag representing no value (EndTag).- Specified by:
emptyin classDynamicOps<net.minecraft.nbt.Tag>- Returns:
- The singleton EndTag instance.
-