All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hohserg.elegant.networking.api.ElegantNetworking Maven / Gradle / Ivy

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy