Class AbstractTokenFactory<I>
java.lang.Object
com.minecolonies.api.colony.requestsystem.token.AbstractTokenFactory<I>
- All Implemented Interfaces:
IFactory<I,,StandardToken> ITokenFactory<I,StandardToken>
- Direct Known Subclasses:
InitializedTokenFactory,RandomSeededTokenFactory,StandardTokenFactory
public abstract class AbstractTokenFactory<I>
extends Object
implements ITokenFactory<I,StandardToken>
An abstract implementation of the
ITokenFactory interface that handles serialization etc.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull StandardTokendeserialize(@NotNull IFactoryController controller, @NotNull net.minecraft.nbt.CompoundTag nbt) Method to deserialize a given constructable.deserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) Method to deserialize a given constructable.@NotNull com.google.common.reflect.TypeToken<StandardToken>Method to get the type this factory can produce.@NotNull net.minecraft.nbt.CompoundTagserialize(@NotNull IFactoryController controller, @NotNull StandardToken request) Method to serialize a given constructable.voidserialize(IFactoryController controller, StandardToken input, net.minecraft.network.FriendlyByteBuf packetBuffer) Method to serialize a given constructable.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.requestsystem.factory.IFactory
getFactoryInputType, getSerializationIdMethods inherited from interface com.minecolonies.api.colony.requestsystem.token.ITokenFactory
getNewInstance, getNewInstance
-
Field Details
-
NBT_MSB
- See Also:
-
NBT_LSB
- See Also:
-
-
Constructor Details
-
AbstractTokenFactory
public AbstractTokenFactory()
-
-
Method Details
-
getFactoryOutputType
Description copied from interface:IFactoryMethod to get the type this factory can produce.- Specified by:
getFactoryOutputTypein interfaceIFactory<I,StandardToken> - Returns:
- The type of request this factory can produce.
-
serialize
@NotNull public @NotNull net.minecraft.nbt.CompoundTag serialize(@NotNull @NotNull IFactoryController controller, @NotNull @NotNull StandardToken request) Method to serialize a given constructable.- Specified by:
serializein interfaceIFactory<I,StandardToken> - Parameters:
controller- The controller that can be used to serialize complicated types.request- The request to serialize.- Returns:
- The serialized data of the given requets.
-
deserialize
@NotNull public @NotNull StandardToken deserialize(@NotNull @NotNull IFactoryController controller, @NotNull @NotNull net.minecraft.nbt.CompoundTag nbt) Method to deserialize a given constructable.- Specified by:
deserializein interfaceIFactory<I,StandardToken> - Parameters:
controller- The controller that can be used to deserialize complicated types.nbt- The data of the request that should be deserialized.- Returns:
- The request that corresponds with the given data in the nbt
-
serialize
public void serialize(IFactoryController controller, StandardToken input, net.minecraft.network.FriendlyByteBuf packetBuffer) Description copied from interface:IFactoryMethod to serialize a given constructable.- Specified by:
serializein interfaceIFactory<I,StandardToken> - Parameters:
controller- The controller that can be used to serialize complicated types.input- The request to serialize.packetBuffer- The buffer to serialize into.
-
deserialize
public StandardToken deserialize(IFactoryController controller, net.minecraft.network.FriendlyByteBuf buffer) throws Throwable Description copied from interface:IFactoryMethod to deserialize a given constructable.- Specified by:
deserializein interfaceIFactory<I,StandardToken> - Parameters:
controller- The controller that can be used to deserialize complicated types.buffer- The data buffer of the request that should be deserialized.- Returns:
- The request that corresponds with the given data in the nbt
- Throws:
Exception- if somethings goes wrong during the deserialization.Throwable
-