Interface UpgradeSerialiser<T extends UpgradeBase>

Type Parameters:
T - The upgrade that this class can serialise and deserialise.
All Known Subinterfaces:
PocketUpgradeSerialiser<T>, TurtleUpgradeSerialiser<T>

public interface UpgradeSerialiser<T extends UpgradeBase>
Base interface for upgrade serialisers. This should generally not be implemented directly, instead implementing one of TurtleUpgradeSerialiser or PocketUpgradeSerialiser.

However, it may sometimes be useful to implement this if you have some shared logic between upgrade types.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    fromJson(net.minecraft.resources.ResourceLocation id, com.google.gson.JsonObject object)
    Read this upgrade from a JSON file in a datapack.
    fromNetwork(net.minecraft.resources.ResourceLocation id, net.minecraft.network.FriendlyByteBuf buffer)
    Read this upgrade from a network packet, sent from the server.
    void
    toNetwork(net.minecraft.network.FriendlyByteBuf buffer, T upgrade)
    Write this upgrade to a network packet, to be sent to the client.
  • Method Details

    • fromJson

      T fromJson(net.minecraft.resources.ResourceLocation id, com.google.gson.JsonObject object)
      Read this upgrade from a JSON file in a datapack.
      Parameters:
      id - The ID of this upgrade.
      object - The JSON object to load this upgrade from.
      Returns:
      The constructed upgrade, with a UpgradeBase.getUpgradeID() equal to id.
      See Also:
      • For additional JSON helper methods.
    • fromNetwork

      T fromNetwork(net.minecraft.resources.ResourceLocation id, net.minecraft.network.FriendlyByteBuf buffer)
      Read this upgrade from a network packet, sent from the server.
      Parameters:
      id - The ID of this upgrade.
      buffer - The buffer object to read this upgrade from.
      Returns:
      The constructed upgrade, with a UpgradeBase.getUpgradeID() equal to id.
    • toNetwork

      void toNetwork(net.minecraft.network.FriendlyByteBuf buffer, T upgrade)
      Write this upgrade to a network packet, to be sent to the client.
      Parameters:
      buffer - The buffer object to write this upgrade to
      upgrade - The upgrade to write.