Interface PointProvider.PointSerializer<T extends PointProvider>
- Enclosing interface:
PointProvider
public static interface PointProvider.PointSerializer<T extends PointProvider>
An object that constructs point providers from JSON and network.
-
Method Summary
Modifier and TypeMethodDescriptionfromJSON(com.google.gson.JsonObject json) Reads a point from JSON.fromNetwork(net.minecraft.network.FriendlyByteBuf buf) Reconstructs a point from network, matching its server companion as closely as possible.static net.minecraft.world.phys.Vec3getPoint(PointProvider point, net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 startPosition) static <T extends PointProvider>
PointProvider.PointSerializer<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
Reconstructs a point from network, matching its server companion as closely 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 point reconstructed from network.
- See Also:
-
fromJSON
Reads a point from JSON. 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 representing this segment. It may not contain all the properties this segment has.- Returns:
- a point created from the given JSON object.
- Throws:
IllegalArgumentException- if there's not enough data to create a point, or it is invalid- See Also:
-
getPoint
static net.minecraft.world.phys.Vec3 getPoint(PointProvider point, net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 startPosition) -
of
static <T extends PointProvider> PointProvider.PointSerializer<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:
-