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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
static interface
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DataComponentMap.Builder
builder()
static @NotNull Codec
<DataComponentMap> codec
(@NotNull IntFunction<DataComponent<?>> idToType, @NotNull Function<String, DataComponent<?>> nameToType) Creates a network type for the given component type.static @NotNull DataComponentMap
diff
(@NotNull DataComponentMap prototype, @NotNull DataComponentMap patch) @NotNull Collection
<DataComponent.Value> entrySet()
<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.boolean
isEmpty()
static NetworkBuffer.Type
<DataComponentMap> networkType
(@NotNull IntFunction<DataComponent<?>> idToType) static @NotNull Codec
<DataComponentMap> patchCodec
(@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, boolean trusted) 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
-
networkType
@Internal @NotNull static NetworkBuffer.Type<DataComponentMap> networkType(@NotNull @NotNull IntFunction<DataComponent<?>> idToType) -
codec
@Internal @NotNull static @NotNull Codec<DataComponentMap> codec(@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, boolean trusted) Creates a network type for the given component type. For internal use only, get the value from the target component class. -
patchCodec
@Internal @NotNull static @NotNull Codec<DataComponentMap> patchCodec(@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) -
isEmpty
boolean isEmpty() -
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
-
entrySet
-
toBuilder
-
toPatchBuilder
-