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.
-
Method Summary
Modifier and TypeMethodDescriptionfromJson(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.voidWrite this upgrade to a network packet, to be sent to the client.
-
Method Details
-
fromJson
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 toid. - 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 toid.
-
toNetwork
Write this upgrade to a network packet, to be sent to the client.- Parameters:
buffer- The buffer object to write this upgrade toupgrade- The upgrade to write.
-