Record Class CropOverride
java.lang.Object
java.lang.Record
net.darkhax.botanypots.common.api.data.components.CropOverride
- Record Components:
crop- The crop to use instead of the default recipe-based lookup.
This item component allows specific items to define a crop that differs from their default recipe-based behavior. For
example, a specific dirt item with this override could grow diamonds while all other instances are not valid seeds
and have no crop.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<CropOverride> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, CropOverride> static final net.darkhax.bookshelf.common.api.function.CachedSupplier<net.minecraft.core.component.DataComponentType<CropOverride>> static final net.minecraft.resources.ResourceLocation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncrop()Returns the value of thecroprecord component.final booleanIndicates whether some other object is "equal to" this one.static Optional<CropOverride> get(net.minecraft.world.item.ItemStack stack) Gets the override value for an item if one exists.final inthashCode()Returns a hash code value for this object.static voidApplies a crop override to the specified item.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
-
STREAM
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,CropOverride> STREAM -
TYPE_ID
public static final net.minecraft.resources.ResourceLocation TYPE_ID -
TYPE
public static final net.darkhax.bookshelf.common.api.function.CachedSupplier<net.minecraft.core.component.DataComponentType<CropOverride>> TYPE
-
-
Constructor Details
-
CropOverride
Creates an instance of aCropOverriderecord class.- Parameters:
crop- the value for thecroprecord component
-
-
Method Details
-
get
Gets the override value for an item if one exists.- Parameters:
stack- The stack to query.- Returns:
- The current crop override as an optional. If an override is specified the optional will be present, otherwise it will be empty.
-
set
Applies a crop override to the specified item.- Parameters:
stack- The item to apply the override to.crop- The crop to attach as an override.
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
crop
Returns the value of thecroprecord component.- Returns:
- the value of the
croprecord component
-