Record Class TradeCost
java.lang.Object
java.lang.Record
net.minecraft.world.item.trading.TradeCost
- All Implemented Interfaces:
Validatable
public record TradeCost(Holder<Item> item, NumberProvider count, DataComponentExactPredicate components)
extends Record
implements Validatable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<TradeCost> private final DataComponentExactPredicateThe field for thecomponentsrecord component.private final NumberProviderThe field for thecountrecord component.The field for theitemrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionTradeCost(Holder<Item> item, NumberProvider count, DataComponentExactPredicate components) Creates an instance of aTradeCostrecord class.TradeCost(ItemLike item, NumberProvider count) -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecomponentsrecord component.count()Returns the value of thecountrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.item()Returns the value of theitemrecord component.toItemCost(LootContext lootContext, int additionalCost) final StringtoString()Returns a string representation of this record class.voidvalidate(ValidationContext context)
-
Field Details
-
item
-
count
The field for thecountrecord component. -
components
The field for thecomponentsrecord component. -
CODEC
-
-
Constructor Details
-
TradeCost
-
TradeCost
-
TradeCost
Creates an instance of aTradeCostrecord class.- Parameters:
item- the value for theitemrecord componentcount- the value for thecountrecord componentcomponents- the value for thecomponentsrecord component
-
-
Method Details
-
toItemCost
-
validate
- Specified by:
validatein interfaceValidatable
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
item
-
count
Returns the value of thecountrecord component.- Returns:
- the value of the
countrecord component
-
components
Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-