Record Class Plant

java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.plant.Plant
Record Components:
growthType - The GrowthType to use. This dictates most of the plant's logic.
allStates - A RuleTest for all states of the plant.
seed - The seed ItemStack to use. This is used e.g. for replanting.
crop - The crop ItemStack to use. This is used e.g. for harvest bonuses.
tool - The tool ItemStack to use when harvesting.

public record Plant(GrowthType growthType, net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest allStates, Optional<net.minecraft.world.item.ItemStackTemplate> seed, Optional<net.minecraft.world.item.ItemStackTemplate> crop, Optional<net.minecraft.world.item.ItemStackTemplate> tool) extends Record
Represents a plant. Plants are used by certain mod mechanics, such as the Harvest component or Dryads growing certain crops.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<net.minecraft.core.Holder<Plant>>
     
    static final com.mojang.serialization.Codec<Plant>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Plant(GrowthType growthType, net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest allStates, Optional<net.minecraft.world.item.ItemStackTemplate> seed, Optional<net.minecraft.world.item.ItemStackTemplate> crop, Optional<net.minecraft.world.item.ItemStackTemplate> tool)
    Creates an instance of a Plant record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest
    Returns the value of the allStates record component.
    createContext(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.item.ItemStack tool)
     
    Optional<net.minecraft.world.item.ItemStackTemplate>
    Returns the value of the crop record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the growthType record component.
    final int
    Returns a hash code value for this object.
    Optional<net.minecraft.world.item.ItemStackTemplate>
    Returns the value of the seed record component.
    Optional<net.minecraft.world.item.ItemStackTemplate>
    Returns the value of the tool record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • DIRECT_CODEC

      public static final com.mojang.serialization.Codec<Plant> DIRECT_CODEC
    • CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.core.Holder<Plant>> CODEC
  • Constructor Details

    • Plant

      public Plant(GrowthType growthType, net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest allStates, Optional<net.minecraft.world.item.ItemStackTemplate> seed, Optional<net.minecraft.world.item.ItemStackTemplate> crop, Optional<net.minecraft.world.item.ItemStackTemplate> tool)
      Creates an instance of a Plant record class.
      Parameters:
      growthType - the value for the growthType record component
      allStates - the value for the allStates record component
      seed - the value for the seed record component
      crop - the value for the crop record component
      tool - the value for the tool record component
  • Method Details

    • createContext

      public GrowthContext createContext(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.item.ItemStack tool)
      Parameters:
      player - The ServerPlayer to use.
      level - The ServerLevel to use.
      pos - The BlockPos to use.
      state - The BlockState to use.
      tool - The ItemStack to use.
      Returns:
      A new GrowthContext.
    • 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.
    • growthType

      public GrowthType growthType()
      Returns the value of the growthType record component.
      Returns:
      the value of the growthType record component
    • allStates

      public net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest allStates()
      Returns the value of the allStates record component.
      Returns:
      the value of the allStates record component
    • seed

      public Optional<net.minecraft.world.item.ItemStackTemplate> seed()
      Returns the value of the seed record component.
      Returns:
      the value of the seed record component
    • crop

      public Optional<net.minecraft.world.item.ItemStackTemplate> crop()
      Returns the value of the crop record component.
      Returns:
      the value of the crop record component
    • tool

      public Optional<net.minecraft.world.item.ItemStackTemplate> tool()
      Returns the value of the tool record component.
      Returns:
      the value of the tool record component