Interface DataComponentHolder

All Known Implementing Classes:
DataComponentEditor, ItemDefinition, ItemStack

public interface DataComponentHolder
Something that carries a patch over an item's default components.
Since:
0.1.0
  • Method Details

    • components

      DataComponentMap components()
      Returns:
      the patch this holder carries
      Since:
      0.1.0
    • get

      default <T> @Nullable T get(DataComponentType<T> type)
      Reads a component off this holder.
      Type Parameters:
      T - the component's value type
      Parameters:
      type - the component to read
      Returns:
      the value, or null
      Since:
      0.1.0
    • getOrDefault

      default <T> T getOrDefault(DataComponentType<T> type, T fallback)
      Type Parameters:
      T - the component's value type
      Parameters:
      type - the component to read
      fallback - returned when the component is unset
      Returns:
      the value, or fallback
      Since:
      0.1.0
    • has

      default boolean has(DataComponentType<?> type)
      Parameters:
      type - the component to test
      Returns:
      true when this holder patches it
      Since:
      0.1.0