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 Details

    • self

      private FriendlyByteBuf 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 entry
      entry - 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 key
      entryKey - The registry-name of an entry in this IForgeRegistry
    • readRegistryIdUnsafe

      default <T> T readRegistryIdUnsafe(@NotNull @NotNull 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

      default <T> void writeRegistryId(@NotNull @NotNull IForgeRegistry<T> registry, @NotNull T entry)
      Writes a given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id. In contrast to writeRegistryIdUnsafe(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 entry
      entry - The entry to write
      Throws:
      NullPointerException - if the registry or entry was null
      IllegalArgumentException - 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 - see readRegistryIdSafe(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> 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

      default void writeFluidStack(FluidStack stack)
      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

      default FluidStack readFluidStack()
      Reads a FluidStack from this buffer.