Interface TransferVariant<O>
- Type Parameters:
O- The type of the immutable object instance, for exampleItemorFluid.
- All Known Subinterfaces:
FluidVariant,ItemVariant
public interface TransferVariant<O>
An immutable association of an immutable object instance (for example
Item or Fluid) and data components.
This is exposed for convenience for code that needs to be generic across multiple transfer variants,
but note that a Storage is not necessarily bound to TransferVariant. Its generic parameter can be any immutable object.
Transfer variants must always be compared with equals, never by reference!
hashCode is guaranteed to be correct and constant time independently of the size of the components.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancomponentsMatch(net.minecraft.core.component.DataComponentPatch other) Return true if the tag of this variant matches the passed tag, and false otherwise.net.minecraft.core.component.DataComponentMapnet.minecraft.core.component.DataComponentPatchReturn the immutable object instance of this variant.default booleanReturn true if this variant has a component changes.booleanisBlank()Return true if this variant is blank, and false otherwise.default booleanReturntrueif the object of this variant matches the passed fluid.default TransferVariant<O> withComponentChanges(net.minecraft.core.component.DataComponentPatch changes) Creates a copy of this TransferVariant with the provided component changes applied.
-
Method Details
-
isBlank
boolean isBlank()Return true if this variant is blank, and false otherwise. -
getObject
O getObject()Return the immutable object instance of this variant. -
getComponents
net.minecraft.core.component.DataComponentPatch getComponents()- Returns:
- The
DataComponentPatchof this variant.
-
getComponentMap
net.minecraft.core.component.DataComponentMap getComponentMap()- Returns:
- The
DataComponentMapof this variant.
-
hasComponents
default boolean hasComponents()Return true if this variant has a component changes. -
componentsMatch
default boolean componentsMatch(net.minecraft.core.component.DataComponentPatch other) Return true if the tag of this variant matches the passed tag, and false otherwise.Note: True is returned if both tags are
null. -
isOf
Returntrueif the object of this variant matches the passed fluid. -
withComponentChanges
default TransferVariant<O> withComponentChanges(net.minecraft.core.component.DataComponentPatch changes) Creates a copy of this TransferVariant with the provided component changes applied.- Parameters:
changes- the changes to apply- Returns:
- the new variant with the changes applied
-