Class SerializerTagKey<T>

java.lang.Object
net.darkhax.bookshelf.api.serialization.SerializerTagKey<T>
All Implemented Interfaces:
ISerializer<net.minecraft.tags.TagKey<T>>

public class SerializerTagKey<T> extends Object implements ISerializer<net.minecraft.tags.TagKey<T>>
  • Constructor Details

    • SerializerTagKey

      public SerializerTagKey(Function<net.minecraft.resources.ResourceLocation,net.minecraft.tags.TagKey<T>> tagGetter)
  • Method Details

    • fromJSON

      public net.minecraft.tags.TagKey<T> fromJSON(com.google.gson.JsonElement json)
      Description copied from interface: ISerializer
      Reads the value from a specific JSON element.
      Specified by:
      fromJSON in interface ISerializer<T>
      Parameters:
      json - The JSON element to read data from.
      Returns:
      The value that was read.
    • toJSON

      public com.google.gson.JsonElement toJSON(net.minecraft.tags.TagKey<T> toWrite)
      Description copied from interface: ISerializer
      Writes a value to a JSON element.
      Specified by:
      toJSON in interface ISerializer<T>
      Parameters:
      toWrite - The object to serialize into JSON data.
      Returns:
      The serialized JSON element.
    • fromByteBuf

      public net.minecraft.tags.TagKey<T> fromByteBuf(net.minecraft.network.FriendlyByteBuf buffer)
      Description copied from interface: ISerializer
      Reads a value from a byte buffer. This is commonly used for networking.
      Specified by:
      fromByteBuf in interface ISerializer<T>
      Parameters:
      buffer - The byte buffer to read from.
      Returns:
      The value that was read.
    • toByteBuf

      public void toByteBuf(net.minecraft.network.FriendlyByteBuf buffer, net.minecraft.tags.TagKey<T> toWrite)
      Description copied from interface: ISerializer
      Writes a value to a byte buffer. This is commonly used for networking.
      Specified by:
      toByteBuf in interface ISerializer<T>
      Parameters:
      buffer - The byte buffer to write to.
      toWrite - The value to write.
    • toNBT

      public net.minecraft.nbt.Tag toNBT(net.minecraft.tags.TagKey<T> toWrite)
      Description copied from interface: ISerializer
      Writes a value to a named binary tag (NBT).
      Specified by:
      toNBT in interface ISerializer<T>
      Parameters:
      toWrite - The value to write.
      Returns:
      The serialized NBT data.
    • fromNBT

      public net.minecraft.tags.TagKey<T> fromNBT(net.minecraft.nbt.Tag nbt)
      Description copied from interface: ISerializer
      Reads a value from a named binary tag (NBT).
      Specified by:
      fromNBT in interface ISerializer<T>
      Parameters:
      nbt - The tag to read data from.
      Returns:
      The value that was read from the data.