public interface IForgePacketBuffer
Modifier and Type | Method and Description |
---|---|
default PacketBuffer |
getBuffer() |
default FluidStack |
readFluidStack()
Reads a FluidStack from this buffer.
|
default <T extends IForgeRegistryEntry<T>> |
readRegistryId()
Reads an registry-entry from the specified buffer.
|
default <T extends IForgeRegistryEntry<T>> |
readRegistryIdSafe(java.lang.Class<? super T> registrySuperType)
Reads an registry-entry from the specified buffer.
|
default <T extends IForgeRegistryEntry<T>> |
readRegistryIdUnsafe(IForgeRegistry<T> registry)
Reads an integer value from the buffer, which will be interpreted as an registry-id in the given registry.
|
default void |
writeFluidStack(FluidStack stack)
Writes a FluidStack to the packet buffer, easy enough.
|
default <T extends IForgeRegistryEntry<T>> |
writeRegistryId(T entry)
Writes an given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id.
|
default void |
writeRegistryIdUnsafe(IForgeRegistry<?> registry,
ResourceLocation entryKey)
Writes the given entries integer id to the buffer.
|
default <T extends IForgeRegistryEntry<T>> |
writeRegistryIdUnsafe(IForgeRegistry<T> registry,
T entry)
Writes the given entries integer id to the buffer.
|
default PacketBuffer getBuffer()
default <T extends IForgeRegistryEntry<T>> void writeRegistryIdUnsafe(@Nonnull IForgeRegistry<T> registry, @Nonnull T entry)
T
- The type of the entry.registry
- The registry containing the given entryentry
- The entry who's registryName is to be writtendefault void writeRegistryIdUnsafe(@Nonnull IForgeRegistry<?> registry, @Nonnull ResourceLocation entryKey)
registry
- The registry containing the entry represented by this keyentryKey
- The registry-name of an entry in this IForgeRegistry
default <T extends IForgeRegistryEntry<T>> T readRegistryIdUnsafe(@Nonnull IForgeRegistry<T> registry)
registry
- The registry containing the entrydefault <T extends IForgeRegistryEntry<T>> void writeRegistryId(@Nonnull T entry)
writeRegistryIdUnsafe(IForgeRegistry, IForgeRegistryEntry)
this method checks every single step performed as well as
writing the registry-id to the buffer, in order to prevent any unexpected behaviour. Therefore this method is to be preferred whenever possible,
over using the unsafe methods.T
- The type of the registry-entryentry
- The entry to writejava.lang.NullPointerException
- if the entry was nulljava.lang.IllegalArgumentException
- if the the registry could not be found or the registry does not contain the specified valuedefault <T extends IForgeRegistryEntry<T>> T readRegistryId()
readRegistryIdSafe(Class)
for an safe version.T
- The type of the registry-entry. Notice that this should match the actual type written to the buffer.java.lang.NullPointerException
- if the registry could not be found.default <T extends IForgeRegistryEntry<T>> T readRegistryIdSafe(java.lang.Class<? super T> registrySuperType)
T
- The type of the registry-entry.java.lang.IllegalArgumentException
- if the retrieved entries registryType doesn't match the one passed in.java.lang.NullPointerException
- if the registry could not be found.default void writeFluidStack(FluidStack stack)
stack
- FluidStack to be written to the packet buffer.default FluidStack readFluidStack()