Package net.minestom.server.utils
Class NBTUtils
java.lang.Object
net.minestom.server.utils.NBTUtils
public final class NBTUtils
extends java.lang.Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NBTUtils.EnchantmentSetter
-
Method Summary
Modifier and Type Method Description static java.lang.Object
fromNBT(org.jglrxavpok.hephaistos.nbt.NBT nbt)
Converts a nbt object to its raw value.static void
loadAllItems(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> items, Inventory destination)
Loads all the items from the 'items' list into the given inventorystatic void
loadDataIntoItem(ItemStack item, org.jglrxavpok.hephaistos.nbt.NBTCompound nbt)
static void
loadEnchantments(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> enchantments, NBTUtils.EnchantmentSetter setter)
static ItemStack
readItemStack(BinaryReader reader)
static void
saveAllItems(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> list, Inventory inventory)
static void
saveDataIntoNBT(ItemStack itemStack, org.jglrxavpok.hephaistos.nbt.NBTCompound itemNBT)
static org.jglrxavpok.hephaistos.nbt.NBT
toNBT(java.lang.Object value, java.lang.Class type, boolean supportDataType)
Converts an object into itsNBT
equivalent.static void
writeEnchant(org.jglrxavpok.hephaistos.nbt.NBTCompound nbt, java.lang.String listName, java.util.Map<Enchantment,java.lang.Short> enchantmentMap)
static void
writeItemStack(BinaryWriter packet, ItemStack itemStack)
-
Method Details
-
loadAllItems
public static void loadAllItems(@NotNull org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> items, @NotNull Inventory destination)Loads all the items from the 'items' list into the given inventory- Parameters:
items
- the items to savedestination
- the inventory destination
-
saveAllItems
public static void saveAllItems(@NotNull org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> list, @NotNull Inventory inventory) -
writeEnchant
public static void writeEnchant(@NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbt, @NotNull java.lang.String listName, @NotNull java.util.Map<Enchantment,java.lang.Short> enchantmentMap) -
readItemStack
-
loadDataIntoItem
public static void loadDataIntoItem(@NotNull ItemStack item, @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbt) -
loadEnchantments
public static void loadEnchantments(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> enchantments, NBTUtils.EnchantmentSetter setter) -
writeItemStack
-
saveDataIntoNBT
public static void saveDataIntoNBT(@NotNull ItemStack itemStack, @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound itemNBT) -
toNBT
@Nullable public static org.jglrxavpok.hephaistos.nbt.NBT toNBT(@NotNull java.lang.Object value, @NotNull java.lang.Class type, boolean supportDataType)Converts an object into itsNBT
equivalent.If
type
is not a primitive type or primitive array andsupportDataType
is true, the data will be encoded with the appropriateDataType
into a byte array.- Parameters:
value
- the value to converttype
- the type of the value, used to know whichDataType
to use ifvalue
is not a primitive typesupportDataType
- true to allow using aDataType
to encodevalue
into a byte array if not a primitive type- Returns:
- the converted value, null if
type
is not a primitive type andsupportDataType
is false
-
fromNBT
public static java.lang.Object fromNBT(@NotNull org.jglrxavpok.hephaistos.nbt.NBT nbt)Converts a nbt object to its raw value.Currently support number, string, byte/int/long array.
- Parameters:
nbt
- the nbt tag to convert- Returns:
- the value representation of a tag
- Throws:
java.lang.UnsupportedOperationException
- if the tag type is not supported
-