Interface DataComponentMap

All Superinterfaces:
DataComponent.Holder

@Experimental public sealed interface DataComponentMap extends DataComponent.Holder

Represents any container of DataComponents.

This type is capable of storing a patch of added and removed components on top of a 'prototype', or existing set of components. See diff(DataComponentMap, DataComponentMap).

  • Field Details

  • Method Details

    • builder

      @NotNull static DataComponentMap.Builder builder()
    • patchBuilder

      @NotNull static DataComponentMap.PatchBuilder patchBuilder()
    • nbtType

      @Internal @NotNull static @NotNull BinaryTagSerializer<DataComponentMap> nbtType(@NotNull @NotNull IntFunction<DataComponent<?>> idToType, @NotNull @NotNull Function<String,DataComponent<?>> nameToType)
      Creates a network type for the given component type. For internal use only, get the value from the target component class.
    • patchNetworkType

      @Internal @NotNull static NetworkBuffer.Type<DataComponentMap> patchNetworkType(@NotNull @NotNull IntFunction<DataComponent<?>> idToType)
      Creates a network type for the given component type. For internal use only, get the value from the target component class.
    • patchNbtType

      @Internal @NotNull static @NotNull BinaryTagSerializer<DataComponentMap> patchNbtType(@NotNull @NotNull IntFunction<DataComponent<?>> idToType, @NotNull @NotNull Function<String,DataComponent<?>> nameToType)
      Creates a network type for the given component type. For internal use only, get the value from the target component class.
    • diff

      @NotNull static @NotNull DataComponentMap diff(@NotNull @NotNull DataComponentMap prototype, @NotNull @NotNull DataComponentMap patch)
    • has

      boolean has(@NotNull @NotNull DataComponentMap prototype, @NotNull @NotNull DataComponent<?> component)
      Does a 'patch'ed has against the given prototype. That is, this map is treated as the primary source, but if unspecified, the given prototype is used as a fallback.
      Parameters:
      prototype - The prototype to fall back to
      component - The component to check
      Returns:
      True if the component is present (taking into account the prototype).
    • get

      @Nullable <T> T get(@NotNull @NotNull DataComponentMap prototype, @NotNull @NotNull DataComponent<T> component)
      Does a 'patch'ed get against the given prototype. That is, this map is treated as the primary source, but if unspecified, the given prototype is used as a fallback.
      Type Parameters:
      T - The type of the component
      Parameters:
      prototype - The prototype to fall back to
      component - The component to get
      Returns:
      The value of the component, or null if not present (taking into account the prototype).
    • set

      @NotNull <T> @NotNull DataComponentMap set(@NotNull @NotNull DataComponent<T> component, @NotNull T value)
      Adds the component, overwriting any prior value if present.
      Returns:
      A new map with the component set to the value
    • set

      @NotNull default @NotNull DataComponentMap set(@NotNull @NotNull DataComponent<Unit> component)
    • remove

      @NotNull @NotNull DataComponentMap remove(@NotNull @NotNull DataComponent<?> component)
      Removes the component from the map (or patch).
      Parameters:
      component - The component to remove
      Returns:
      A new map with the component removed
    • toBuilder

      @NotNull @NotNull DataComponentMap.Builder toBuilder()
    • toPatchBuilder

      @NotNull @NotNull DataComponentMap.PatchBuilder toPatchBuilder()