Interface DataComponentHolderResource<T>

Type Parameters:
T - The type of the backing registry entry.
All Superinterfaces:
DataComponentGetter, DataComponentHolder, IDataComponentHolderExtension, RegisteredResource<T>, Resource
All Known Implementing Classes:
FluidResource, ItemResource

public interface DataComponentHolderResource<T> extends RegisteredResource<T>, DataComponentHolder
Helper interface for resources backed by a registry entry and which also hold data component values.

Note that empty resources never have any data components, and methods that modify data components will simply return the empty resource instance again.

  • Method Details

    • isComponentsPatchEmpty

      boolean isComponentsPatchEmpty()
      Checks if the resource's data component holder has no patches applied to it. Equivalent to checking if the patch is empty, but more efficient.
    • withMergedPatch

      Returns an instance of the resource with the desired patch applied on top of the existing one.
      Parameters:
      patch - The patch added to the new resource instance.
      Returns:
      an instance of the resource with the desired patch applied on top of the existing one
    • with

      <D> DataComponentHolderResource<T> with(DataComponentType<D> type, D data)
      Returns a resource with the data component set to the given value.
      Type Parameters:
      D - the type of data component
      Parameters:
      type - the type of data component
      data - the data to set
      Returns:
      a resource with the data component set to the given value
    • without

      Returns a resource without the data component, i.e. with the data component explicitly removed.
      Parameters:
      type - the type of data component
      Returns:
      a resource without the data component, i.e. with the data component explicitly removed
    • getComponentsPatch

      DataComponentPatch getComponentsPatch()
      Patches currently applied to the resource's data component holder.
    • with

      default <D> DataComponentHolderResource<T> with(Supplier<? extends DataComponentType<D>> type, D data)
      Returns a resource with the data component set to the given value.
      Type Parameters:
      D - the type of data component
      Parameters:
      type - the supplier for the type of data component
      data - the data to set
      Returns:
      a resource with the data component set to the given value
    • without

      default DataComponentHolderResource<T> without(Supplier<? extends DataComponentType<?>> type)
      Returns a resource without the data component, i.e. with the data component explicitly removed.
      Parameters:
      type - the supplier for the type of data component
      Returns:
      a resource without the data component, i.e. with the data component explicitly removed