Package net.minecraft.world.item.trading
Record Class ItemCost
java.lang.Object
java.lang.Record
net.minecraft.world.item.trading.ItemCost
public record ItemCost(Holder<Item> item, int count, DataComponentPredicate components, ItemStack itemStack)
extends Record
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec
<ItemCost> private final DataComponentPredicate
The field for thecomponents
record component.private final int
The field for thecount
record component.The field for theitem
record component.private final ItemStack
The field for theitemStack
record component.static final StreamCodec
<RegistryFriendlyByteBuf, Optional<ItemCost>> static final StreamCodec
<RegistryFriendlyByteBuf, ItemCost> -
Constructor Summary
ConstructorDescriptionItemCost
(Holder<Item> p_331233_, int p_334492_, DataComponentPredicate p_330788_) ItemCost
(Holder<Item> item, int count, DataComponentPredicate components, ItemStack itemStack) Creates an instance of aItemCost
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecomponents
record component.int
count()
Returns the value of thecount
record component.private static ItemStack
createStack
(Holder<Item> p_329043_, int p_329370_, DataComponentPredicate p_330789_) final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.item()
Returns the value of theitem
record component.Returns the value of theitemStack
record component.boolean
final String
toString()
Returns a string representation of this record class.
-
Field Details
-
item
The field for theitem
record component. -
count
private final int countThe field for thecount
record component. -
components
The field for thecomponents
record component. -
itemStack
The field for theitemStack
record component. -
CODEC
-
STREAM_CODEC
-
OPTIONAL_STREAM_CODEC
-
-
Constructor Details
-
ItemCost
-
ItemCost
-
ItemCost
-
ItemCost
public ItemCost(Holder<Item> item, int count, DataComponentPredicate components, ItemStack itemStack) Creates an instance of aItemCost
record class.- Parameters:
item
- the value for theitem
record componentcount
- the value for thecount
record componentcomponents
- the value for thecomponents
record componentitemStack
- the value for theitemStack
record component
-
-
Method Details
-
withComponents
-
createStack
private static ItemStack createStack(Holder<Item> p_329043_, int p_329370_, DataComponentPredicate p_330789_) -
test
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
item
Returns the value of theitem
record component.- Returns:
- the value of the
item
record component
-
count
public int count()Returns the value of thecount
record component.- Returns:
- the value of the
count
record component
-
components
Returns the value of thecomponents
record component.- Returns:
- the value of the
components
record component
-
itemStack
Returns the value of theitemStack
record component.- Returns:
- the value of the
itemStack
record component
-