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

      default <T extends IForgeRegistryEntry<T>> void writeRegistryId(@Nonnull T entry)
      Writes an given registry-entry's integer id to the specified buffer in combination with writing the containing registry's id. In contrast to 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.
      Type Parameters:
      T - The type of the registry-entry
      Parameters:
      entry - The entry to write
      Throws:
      NullPointerException - if the entry was null
      IllegalArgumentException - if the the registry could not be found or the registry does not contain the specified value
    • readRegistryId

      default <T extends IForgeRegistryEntry<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 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

      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.