Interface IFactoryController

All Known Implementing Classes:
StandardFactoryController

public interface IFactoryController
Interface used to describe classes that function as Factory controllers.
  • Method Summary

    Modifier and Type
    Method
    Description
    <Output> Output
    deserialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer)
    Method used to quickly read an object from a given ByteBuf
    default <Output> Collection<Output>
    deserializeList(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.ListTag listTag)
    Deserialize a collection from nbt util.
    <Output> Output
    deserializeTag(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound)
    Method used to quickly deserialize a object if it is known to this controller.
    <Input> IFactory<Input,?>
    getFactoryForInput(@NotNull com.google.common.reflect.TypeToken<? extends Input> clazz)
    Method used to get a factory for a given input class.
    default <Input> IFactory<Input,?>
    getFactoryForInput(@NotNull String className)
    Method used to get a factory for a given input class name.
    <Input, Output>
    IFactory<Input,Output>
    getFactoryForIO(@NotNull com.google.common.reflect.TypeToken<? extends Input> inputTypeToken, @NotNull com.google.common.reflect.TypeToken<? extends Output> outputTypeToken)
    Method to get a factory for a given combination of input and output types.
    default <Output> IFactory<?,Output>
    Method used to get a factory for a given Output class name.
    <Output> IFactory<?,Output>
    getFactoryForOutput(@NotNull com.google.common.reflect.TypeToken<? extends Output> clazz)
    Method used to get a factory for a given output class.
    default <Output> IFactory<?,Output>
    getFactoryForOutput(@NotNull String className)
    Method used to get a factory for a given Output class name.
    <Output> IFactory<?,Output>
    Method used to get a factory for a given output class.
    <Output> Output
    getNewInstance(@NotNull com.google.common.reflect.TypeToken<? extends Output> requestedType)
    Method used to create a new instance of the given output.
    <Input, Output>
    Output
    getNewInstance(@NotNull com.google.common.reflect.TypeToken<? extends Output> requestedType, Input input, @NotNull Object... context)
    Method used to create a new instance of the given input.
    <Input, Output>
    void
    registerNewFactory(@NotNull IFactory<Input,Output> factory)
    Method used to register a new factory to this controller.
    <Output> void
    registerNewTypeOverrideHandler(@NotNull ITypeOverrideHandler<Output> overrideHandler)
    Method used to register a TypeOverride handler.
    <Output> void
    serialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer, Output object)
    Method used to quickly write an object into the given ByteBuf.
    default <Output> net.minecraft.nbt.Tag
    serializeList(net.minecraft.core.HolderLookup.Provider provider, Collection<Output> list)
    Serialize a collection to nbt util.
    <Output> net.minecraft.nbt.CompoundTag
    serializeTag(net.minecraft.core.HolderLookup.Provider provider, Output object)
    Method used to quickly serialize a object if it is known to this controller.
  • Method Details

    • getFactoryForInput

      default <Input> IFactory<Input,?> getFactoryForInput(@NotNull @NotNull String className) throws IllegalArgumentException
      Method used to get a factory for a given input class name.
      Type Parameters:
      Input - The type of input for the requested factory.
      Parameters:
      className - The class name of the input type of the requested factory.
      Returns:
      The factory that can handle the given input class.
      Throws:
      IllegalArgumentException - is thrown when the given input name is unknown to this Factory Controller.
    • getFactoryForInput

      <Input> IFactory<Input,?> getFactoryForInput(@NotNull @NotNull com.google.common.reflect.TypeToken<? extends Input> clazz) throws IllegalArgumentException
      Method used to get a factory for a given input class.
      Type Parameters:
      Input - The type of input for the requested factory.
      Parameters:
      clazz - The class of the input type of the requested factory.
      Returns:
      The factory that can handle the given input class.
      Throws:
      IllegalArgumentException - is thrown when the given input class is unknown to this Factory Controller.
    • getFactoryForIO

      <Input, Output> IFactory<Input,Output> getFactoryForIO(@NotNull @NotNull com.google.common.reflect.TypeToken<? extends Input> inputTypeToken, @NotNull @NotNull com.google.common.reflect.TypeToken<? extends Output> outputTypeToken) throws IllegalArgumentException
      Method to get a factory for a given combination of input and output types.
      Type Parameters:
      Input - The input type of the factory
      Output - The output type of the factory.
      Parameters:
      inputTypeToken - The input type of the factory.
      outputTypeToken - The output type of the factory.
      Returns:
      A factory that takes the input type and produces the output type.
      Throws:
      IllegalArgumentException - Thrown when no factory exists for the combination of input and output.
    • getFactoryForOutput

      default <Output> IFactory<?,Output> getFactoryForOutput(@NotNull @NotNull String className) throws IllegalArgumentException
      Method used to get a factory for a given Output class name.
      Type Parameters:
      Output - The type of Output for the requested factory.
      Parameters:
      className - The class name of the Output type of the requested factory.
      Returns:
      The factory that can handle the given Output class.
      Throws:
      IllegalArgumentException - is thrown when the given Output name is unknown to this Factory Controller.
    • getFactoryForOutput

      default <Output> IFactory<?,Output> getFactoryForOutput(short id) throws IllegalArgumentException
      Method used to get a factory for a given Output class name.
      Type Parameters:
      Output - The type of Output for the requested factory.
      Parameters:
      id - The class id of the Output type of the requested factory.
      Returns:
      The factory that can handle the given Output class.
      Throws:
      IllegalArgumentException - is thrown when the given Output name is unknown to this Factory Controller.
    • getFactoryForOutput

      <Output> IFactory<?,Output> getFactoryForOutput(@NotNull @NotNull com.google.common.reflect.TypeToken<? extends Output> clazz) throws IllegalArgumentException
      Method used to get a factory for a given output class.
      Type Parameters:
      Output - The type of output for the requested factory.
      Parameters:
      clazz - The class of the output type of the requested factory.
      Returns:
      The factory that can handle the given output class.
      Throws:
      IllegalArgumentException - is thrown when the given output class is unknown to this Factory Controller.
    • getFactoryForSerializationId

      <Output> IFactory<?,Output> getFactoryForSerializationId(short id) throws IllegalArgumentException
      Method used to get a factory for a given output class.
      Type Parameters:
      Output - The type of output for the requested factory.
      Parameters:
      id - The id of the output type of the requested factory.
      Returns:
      The factory that can handle the given output class.
      Throws:
      IllegalArgumentException - is thrown when the given output class is unknown to this Factory Controller.
    • registerNewFactory

      <Input, Output> void registerNewFactory(@NotNull @NotNull IFactory<Input,Output> factory) throws IllegalArgumentException
      Method used to register a new factory to this controller.
      Type Parameters:
      Input - The type of input the factory accepts.
      Output - The type of output the factory produces.
      Parameters:
      factory - The new factory.
      Throws:
      IllegalArgumentException - if there is already a factory registered with either the given input and/or the given output.
    • serializeTag

      <Output> net.minecraft.nbt.CompoundTag serializeTag(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull Output object) throws IllegalArgumentException
      Method used to quickly serialize a object if it is known to this controller.
      Type Parameters:
      Output - the output type.
      Parameters:
      object - The object to serialize.
      Returns:
      An NBTTag containing a serialized version of the given object.
      Throws:
      IllegalArgumentException - is thrown when the output type is unknown to this controller.
    • serializeList

      default <Output> net.minecraft.nbt.Tag serializeList(@NotNull net.minecraft.core.HolderLookup.Provider provider, Collection<Output> list)
      Serialize a collection to nbt util.
      Type Parameters:
      Output - the thing being serialized.
      Parameters:
      list - the collection to serialize.
      Returns:
      an nbt tag.
    • deserializeTag

      <Output> Output deserializeTag(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound) throws IllegalArgumentException
      Method used to quickly deserialize a object if it is known to this controller.
      Type Parameters:
      Output - The type of object to deserialize.
      Parameters:
      compound - The data to deserialize an object from.
      Returns:
      The deserialized version of the given data.
      Throws:
      IllegalArgumentException - is thrown when the type stored in the data is unknown to this controller.
    • deserialize

      <Output> Output deserialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer) throws IllegalArgumentException
      Method used to quickly read an object from a given ByteBuf
      Type Parameters:
      Output - The type to read.
      Parameters:
      buffer - The buffer to read from.
      Returns:
      An instance of the given output type, with its stored data from the buffer.
      Throws:
      IllegalArgumentException - is thrown when the requested type is unknown to this controller.
    • deserializeList

      default <Output> Collection<Output> deserializeList(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.ListTag listTag)
      Deserialize a collection from nbt util.
      Type Parameters:
      Output - the thing being serialized.
      Parameters:
      listTag - the nbt tag to deserialize from.
      Returns:
      a collection.
    • serialize

      <Output> void serialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer, @NotNull Output object) throws IllegalArgumentException
      Method used to quickly write an object into the given ByteBuf.
      Type Parameters:
      Output - The type of the object to write.
      Parameters:
      buffer - The buffer to write into.
      object - The object to write.
      Throws:
      IllegalArgumentException - is thrown when the given output type is unknown to this controller.
    • getNewInstance

      <Input, Output> Output getNewInstance(@NotNull @NotNull com.google.common.reflect.TypeToken<? extends Output> requestedType, @NotNull Input input, @NotNull @NotNull Object... context) throws IllegalArgumentException, ClassCastException
      Method used to create a new instance of the given input.
      Type Parameters:
      Input - The type of input.
      Output - The type of output.
      Parameters:
      requestedType - The typetoken for the requested type.
      input - The input to process.
      context - The context for the creation.
      Returns:
      The output from the factory, created by the given input and output.
      Throws:
      IllegalArgumentException - thrown when the output and input do not match a factory known to this controller.
      ClassCastException - thrown when a Factory is known for the given input, but does not produce the given output.
    • getNewInstance

      <Output> Output getNewInstance(@NotNull @NotNull com.google.common.reflect.TypeToken<? extends Output> requestedType) throws IllegalArgumentException, ClassCastException
      Method used to create a new instance of the given output.
      Type Parameters:
      Output - The type of output.
      Parameters:
      requestedType - The typetoken of the requested type.
      Returns:
      The output from the factory, created by the given input and output.
      Throws:
      IllegalArgumentException - thrown when the output and input do not match a factory known to this controller.
      ClassCastException - thrown when a Factory is known for the given input, but does not produce the given output.
    • registerNewTypeOverrideHandler

      <Output> void registerNewTypeOverrideHandler(@NotNull @NotNull ITypeOverrideHandler<Output> overrideHandler)
      Method used to register a TypeOverride handler. Useful if the Client side has a different Handler. Or if an upgrade between version is needed.
      Type Parameters:
      Output - The output type that the handler converts to.
      Parameters:
      overrideHandler - The override handler to register.