Package forestry.api.core
Record Class Product
java.lang.Object
java.lang.Record
forestry.api.core.Product
- Record Components:
item- The item this product represents.count- The count the produced stack should have.tag- The NBT tagchance-
- All Implemented Interfaces:
IProduct
public record Product(net.minecraft.world.item.Item item, int count, @Nullable net.minecraft.nbt.CompoundTag tag, float chance)
extends Record
implements IProduct
Default implementation of
IProduct. Used in most cases.-
Field Summary
FieldsFields inherited from interface forestry.api.core.IProduct
ITEM_ONLY_STRATEGY -
Constructor Summary
ConstructorsConstructorDescriptionProduct(net.minecraft.world.item.Item item, int count, net.minecraft.nbt.CompoundTag tag, float chance) Creates an instance of aProductrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfloatchance()Returns the value of thechancerecord component.intcount()Returns the value of thecountrecord component.net.minecraft.world.item.ItemStackfinal booleanIndicates whether some other object is "equal to" this one.static ProductfromNetwork(net.minecraft.network.FriendlyByteBuf buffer) final inthashCode()Returns a hash code value for this object.net.minecraft.world.item.Itemitem()Returns the value of theitemrecord component.static Productof(net.minecraft.world.item.Item item) static Productof(net.minecraft.world.item.Item item, int amount, float chance) net.minecraft.nbt.CompoundTagtag()Returns the value of thetagrecord component.static voidfinal StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface forestry.api.core.IProduct
createRandomStack
-
Field Details
-
CODEC
-
-
Constructor Details
-
Product
public Product(net.minecraft.world.item.Item item, int count, @Nullable net.minecraft.nbt.CompoundTag tag, float chance) Creates an instance of aProductrecord class.
-
-
Method Details
-
createStack
public net.minecraft.world.item.ItemStack createStack()- Specified by:
createStackin interfaceIProduct- Returns:
- A new stack of this product. If your product is dynamic, return a "default" nonempty stack.
-
of
-
of
-
toNetwork
-
fromNetwork
-
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
public net.minecraft.world.item.Item item()Returns the value of theitemrecord component. -
count
public int count()Returns the value of thecountrecord component.- Returns:
- the value of the
countrecord component
-
tag
@Nullable public net.minecraft.nbt.CompoundTag tag()Returns the value of thetagrecord component.- Returns:
- the value of the
tagrecord component
-
chance
public float chance()Returns the value of thechancerecord component.
-