Interface IForgeFriendlyByteBuf
- All Known Implementing Classes:
FriendlyByteBuf
public interface IForgeFriendlyByteBuf
Extension-Interface providing methods for writing registry-id's instead of their registry-names.
-
Method Summary
Modifier and TypeMethodDescriptiondefault FluidStack
Reads a FluidStack from this buffer.default <T extends IForgeRegistryEntry<T>>
TReads an registry-entry from the specified buffer.default <T extends IForgeRegistryEntry<T>>
TreadRegistryIdSafe(Class<? super T> registrySuperType)
Reads an registry-entry from the specified buffer.default <T extends IForgeRegistryEntry<T>>
TreadRegistryIdUnsafe(IForgeRegistry<T> registry)
Reads an integer value from the buffer, which will be interpreted as an registry-id in the given registry.private FriendlyByteBuf
self()
default void
writeFluidStack(FluidStack stack)
Writes a FluidStack to the packet buffer, easy enough.default <T extends IForgeRegistryEntry<T>>
voidwriteRegistryId(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>>
voidwriteRegistryIdUnsafe(IForgeRegistry<T> registry, T entry)
Writes the given entries integer id to the buffer.
-
Method Details
-
self
-
writeRegistryIdUnsafe
default <T extends IForgeRegistryEntry<T>> void writeRegistryIdUnsafe(@Nonnull IForgeRegistry<T> registry, @Nonnull T entry)Writes the given entries integer id to the buffer. Notice however that this will only write the id of the given entry and will not check whether it actually exists in the given registry. Therefore no safety checks can be performed whilst reading it and if the entry is not in the registry a default value will be written.- Type Parameters:
T
- The type of the entry.- Parameters:
registry
- The registry containing the given entryentry
- The entry who's registryName is to be written
-
writeRegistryIdUnsafe
default void writeRegistryIdUnsafe(@Nonnull IForgeRegistry<?> registry, @Nonnull ResourceLocation entryKey)Writes the given entries integer id to the buffer. Notice however that this will only write the id of the given entry and will not check whether it actually exists in the given registry. Therefore no safety checks can be performed whilst reading it and if the entry is not in the registry a default value will be written.- Parameters:
registry
- The registry containing the entry represented by this keyentryKey
- The registry-name of an entry in thisIForgeRegistry
-
readRegistryIdUnsafe
default <T extends IForgeRegistryEntry<T>> T readRegistryIdUnsafe(@Nonnull IForgeRegistry<T> registry)Reads an integer value from the buffer, which will be interpreted as an registry-id in the given registry. Notice that if there is no value in the specified registry for the read id, that the registry's default value will be returned.- Parameters:
registry
- The registry containing the entry
-
writeRegistryId
Writes an given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id. In contrast towriteRegistryIdUnsafe(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.- Type Parameters:
T
- The type of the registry-entry- Parameters:
entry
- The entry to write- Throws:
NullPointerException
- if the entry was nullIllegalArgumentException
- if the the registry could not be found or the registry does not contain the specified value
-
readRegistryId
Reads an registry-entry from the specified buffer. Notice however that the type cannot be checked without providing an additional class parameter - seereadRegistryIdSafe(Class)
for an safe version.- Type Parameters:
T
- The type of the registry-entry. Notice that this should match the actual type written to the buffer.- Throws:
NullPointerException
- if the registry could not be found.
-
readRegistryIdSafe
default <T extends IForgeRegistryEntry<T>> T readRegistryIdSafe(Class<? super T> registrySuperType)Reads an registry-entry from the specified buffer. This method also verifies, that the value read is of the appropriate type.- Type Parameters:
T
- The type of the registry-entry.- Throws:
IllegalArgumentException
- if the retrieved entries registryType doesn't match the one passed in.NullPointerException
- if the registry could not be found.
-
writeFluidStack
Writes a FluidStack to the packet buffer, easy enough. If EMPTY, writes a FALSE. This behavior provides parity with the ItemStack method in PacketBuffer.- Parameters:
stack
- FluidStack to be written to the packet buffer.
-
readFluidStack
Reads a FluidStack from this buffer.
-