Class DataComponentMap.Builder
java.lang.Object
fr.fidorial.item.data.DataComponentMap.Builder
- Enclosing class:
DataComponentMap
Accumulates several component changes without allocating a patch per step.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()remove(DataComponentType<?> type) reset(DataComponentType<?> type) set(DataComponentType<T> type, T value) setIfPresent(DataComponentType<T> type, @Nullable T value) Sets a component only whenvalueis non-null.
-
Method Details
-
set
- Type Parameters:
T- the component's value type- Parameters:
type- the component to setvalue- the value to set it to- Returns:
- this builder
-
setIfPresent
Sets a component only whenvalueis non-null.- Type Parameters:
T- the component's value type- Parameters:
type- the component to setvalue- the value, ornullto leave the component untouched- Returns:
- this builder
-
remove
- Parameters:
type- the component whose default to remove- Returns:
- this builder
-
reset
- Parameters:
type- the component to stop patching- Returns:
- this builder
-
build
- Returns:
- the built patch, or
DataComponentMap.EMPTYwhen nothing was set
-