hohserg.elegant.networking.api.ElegantNetworking Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elegant-networking-1.16 Show documentation
Show all versions of elegant-networking-1.16 Show documentation
This is a runtime library of ElegantNetworking for MinecraftForge 1.16
The newest version!
package hohserg.elegant.networking.api;
import hohserg.elegant.networking.impl.ISerializerBase;
import hohserg.elegant.networking.impl.Registry;
public class ElegantNetworking {
/**
* Gives a serializer for requested type.
* Serializer generally is pair of functions:
*
* {@code A => ByteBuf }
* {@code ByteBuf => A }
*
* @param requested type
* @param serializable class of requested type
* @return serializer
*/
public static ISerializerBase getByteBufSerializerFor(Class serializable) {
return Registry.getSerializerFor(serializable);
}
/**
* Gives a nbt serializer for requested type.
* NbtSerializer is tetrad of functions:
*
* {@code A => NBTTagCompound }
* {@code NBTTagCompound => A }
*
* {@code A => NBTTagByteArray }
* {@code NBTTagByteArray => A }
*
* Useful for capability storage, world save data and etc
*
* @param requested type
* @param serializable class of requested type
* @return serializer
*/
public static NbtSerializer getNbtSerializerFor(Class serializable) {
ISerializerBase serializer = getByteBufSerializerFor(serializable);
return new NbtSerializer<>(serializer);
}
}