Interface DataComponentHolderResource<T>
- Type Parameters:
T- The type of the backing registry entry.
- All Superinterfaces:
DataComponentGetter,DataComponentHolder,IDataComponentHolderExtension,RegisteredResource<T>,Resource
- All Known Implementing Classes:
FluidResource,ItemResource
Helper interface for resources backed by a registry entry and which also hold data component values.
Note that empty resources never have any data components,
and methods that modify data components will simply return the empty resource instance again.
-
Method Summary
Modifier and TypeMethodDescriptionPatches currently applied to the resource's data component holder.booleanChecks if the resource's data component holder has no patches applied to it.default <D> DataComponentHolderResource<T> with(Supplier<? extends DataComponentType<D>> type, D data) Returns a resource with the data component set to the given value.with(DataComponentType<D> type, D data) Returns a resource with the data component set to the given value.Returns an instance of the resource with the desired patch applied on top of the existing one.default DataComponentHolderResource<T> without(Supplier<? extends DataComponentType<?>> type) Returns a resource without the data component, i.e. with the data component explicitly removed.without(DataComponentType<?> type) Returns a resource without the data component, i.e. with the data component explicitly removed.Methods inherited from interface net.minecraft.core.component.DataComponentGetter
get, getOrDefault, getTyped, hasMethods inherited from interface net.minecraft.core.component.DataComponentHolder
get, getAllOfType, getComponents, getOrDefault, hasMethods inherited from interface net.neoforged.neoforge.common.extensions.IDataComponentHolderExtension
addToTooltip, addToTooltip
-
Method Details
-
isComponentsPatchEmpty
boolean isComponentsPatchEmpty()Checks if the resource's data component holder has no patches applied to it. Equivalent to checking if thepatchis empty, but more efficient. -
withMergedPatch
Returns an instance of the resource with the desired patch applied on top of the existing one.- Parameters:
patch- The patch added to the new resource instance.- Returns:
- an instance of the resource with the desired patch applied on top of the existing one
-
with
Returns a resource with the data component set to the given value.- Type Parameters:
D- the type of data component- Parameters:
type- the type of data componentdata- the data to set- Returns:
- a resource with the data component set to the given value
-
without
Returns a resource without the data component, i.e. with the data component explicitly removed.- Parameters:
type- the type of data component- Returns:
- a resource without the data component, i.e. with the data component explicitly removed
-
getComponentsPatch
DataComponentPatch getComponentsPatch()Patches currently applied to the resource's data component holder. -
with
default <D> DataComponentHolderResource<T> with(Supplier<? extends DataComponentType<D>> type, D data) Returns a resource with the data component set to the given value.- Type Parameters:
D- the type of data component- Parameters:
type- the supplier for the type of data componentdata- the data to set- Returns:
- a resource with the data component set to the given value
-
without
Returns a resource without the data component, i.e. with the data component explicitly removed.- Parameters:
type- the supplier for the type of data component- Returns:
- a resource without the data component, i.e. with the data component explicitly removed
-