Record Class SoilOverride

java.lang.Object
java.lang.Record
net.darkhax.botanypots.common.api.data.components.SoilOverride
Record Components:
soil - The soil to use instead of the default recipe-based lookup.

public record SoilOverride(Soil soil) extends Record
This item component allows specific items to define a soil that differs from their default recipe-based behavior. For example, a specific iron block could grow crops at 10x speed while normal iron blocks do not offer any speed modifier.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<SoilOverride>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,SoilOverride>
     
    static final net.darkhax.bookshelf.common.api.function.CachedSupplier<net.minecraft.core.component.DataComponentType<SoilOverride>>
     
    static final net.minecraft.resources.ResourceLocation
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a SoilOverride record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    get(net.minecraft.world.item.ItemStack stack)
    Gets the override value for an item if one exists.
    final int
    Returns a hash code value for this object.
    static void
    set(net.minecraft.world.item.ItemStack stack, Soil soil)
    Applies a soil override to the specified item.
    Returns the value of the soil record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<SoilOverride> CODEC
    • STREAM

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,SoilOverride> 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<SoilOverride>> TYPE
  • Constructor Details

    • SoilOverride

      public SoilOverride(Soil soil)
      Creates an instance of a SoilOverride record class.
      Parameters:
      soil - the value for the soil record component
  • Method Details

    • get

      public static Optional<SoilOverride> get(net.minecraft.world.item.ItemStack stack)
      Gets the override value for an item if one exists.
      Parameters:
      stack - The item to query.
      Returns:
      The current soil override as an optional. If an override is specified the optional will be present, otherwise it is empty.
    • set

      public static void set(net.minecraft.world.item.ItemStack stack, Soil soil)
      Applies a soil override to the specified item.
      Parameters:
      stack - The item to apply the override to.
      soil - The soil to attach as an override.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • soil

      public Soil soil()
      Returns the value of the soil record component.
      Returns:
      the value of the soil record component