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> T
Reads an registry-entry from the specified buffer.default <T> T
readRegistryIdSafe
(Class<? super T> registrySuperType) Reads an registry-entry from the specified buffer.default <T> T
readRegistryIdUnsafe
(@NotNull 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> void
writeRegistryId
(@NotNull IForgeRegistry<T> registry, T entry) Writes a given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id.default void
writeRegistryIdUnsafe
(@NotNull IForgeRegistry<?> registry, @NotNull ResourceLocation entryKey) Writes the given entries integer id to the buffer.default <T> void
writeRegistryIdUnsafe
(@NotNull IForgeRegistry<T> registry, T entry) Writes the given entries integer id to the buffer.
-
Method Details
-
self
-
writeRegistryIdUnsafe
default <T> void writeRegistryIdUnsafe(@NotNull @NotNull IForgeRegistry<T> registry, @NotNull 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(@NotNull @NotNull IForgeRegistry<?> registry, @NotNull @NotNull 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
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 a given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id. In contrast towriteRegistryIdUnsafe(IForgeRegistry, Object)
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:
registry
- The registry containing the entryentry
- The entry to write- Throws:
NullPointerException
- if the registry or entry was nullIllegalArgumentException
- if the registry does not contain the specified value
-
readRegistryId
default <T> T 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
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.
-