Package net.minestom.server.component
Interface DataComponentMap
- All Superinterfaces:
DataComponent.Holder
Represents any container of DataComponent
s.
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)
.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
static interface
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DataComponentMap.Builder
builder()
static @NotNull DataComponentMap
diff
(@NotNull DataComponentMap prototype, @NotNull DataComponentMap patch) <T> T
get
(@NotNull DataComponentMap prototype, @NotNull DataComponent<T> component) Does a 'patch'ed get against the given prototype.boolean
has
(@NotNull DataComponentMap prototype, @NotNull DataComponent<?> component) Does a 'patch'ed has against the given prototype.static @NotNull BinaryTagSerializer
<DataComponentMap> nbtType
(@NotNull IntFunction<DataComponent<?>> idToType, @NotNull Function<String, DataComponent<?>> nameToType) Creates a network type for the given component type.static @NotNull BinaryTagSerializer
<DataComponentMap> patchNbtType
(@NotNull IntFunction<DataComponent<?>> idToType, @NotNull Function<String, DataComponent<?>> nameToType) Creates a network type for the given component type.static NetworkBuffer.Type
<DataComponentMap> patchNetworkType
(@NotNull IntFunction<DataComponent<?>> idToType) Creates a network type for the given component type.@NotNull DataComponentMap
remove
(@NotNull DataComponent<?> component) Removes the component from the map (or patch).default @NotNull DataComponentMap
set
(@NotNull DataComponent<Unit> component) <T> @NotNull DataComponentMap
set
(@NotNull DataComponent<T> component, T value) Adds the component, overwriting any prior value if present.@NotNull DataComponentMap.Builder
@NotNull DataComponentMap.PatchBuilder
Methods inherited from interface net.minestom.server.component.DataComponent.Holder
get, get, has
-
Field Details
-
EMPTY
-
-
Method Details
-
builder
-
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 tocomponent
- 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 tocomponent
- 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
-
remove
Removes the component from the map (or patch).- Parameters:
component
- The component to remove- Returns:
- A new map with the component removed
-
toBuilder
-
toPatchBuilder
-