Interface Transition.TransitionSerializer<T extends Transition>
- Enclosing interface:
Transition
public static interface Transition.TransitionSerializer<T extends Transition>
A transition serializer, representing a transition type.
-
Method Summary
Modifier and TypeMethodDescriptionfromJSON(com.google.gson.JsonObject json) Loads a transition from a JSON object.fromNetwork(net.minecraft.network.FriendlyByteBuf buf) Recreates a transition from network, matching its server-side version as close as possible.static <T extends Transition>
Transition.TransitionSerializer<T> of(Function<net.minecraft.network.FriendlyByteBuf, T> network, Function<com.google.gson.JsonObject, T> json) A helper method to create a segment serializer from 2 functions.
-
Method Details
-
fromNetwork
Recreates a transition from network, matching its server-side version as close as possible.- Parameters:
buf- the buffer to read from. The data in this buffer is enough to fully recreate the original segment type.- Returns:
- a transition reconstructed from network
-
fromJSON
Loads a transition from a JSON object. The object created from here is stored on the server, and then serialized to network to be reconstructed on the client.- Parameters:
json- the JSON object with settings for this transition type. It may not be enough to create a meaningful object.- Returns:
- a transition created from given JSON.
- Throws:
IllegalArgumentException- if there's not enough data to create a transition, or it is invalid
-
of
static <T extends Transition> Transition.TransitionSerializer<T> of(Function<net.minecraft.network.FriendlyByteBuf, T> network, Function<com.google.gson.JsonObject, T> json) A helper method to create a segment serializer from 2 functions.- Type Parameters:
T- the class for the segment type- Parameters:
network- afromNetwork(FriendlyByteBuf)implementationjson- afromJSON(JsonObject)implementation- Returns:
- a segment serializer for the given type
- See Also:
-