Record Class DisplayContext

java.lang.Object
java.lang.Record
net.darkhax.botanypots.common.api.context.DisplayContext
Record Components:
inventory - A list of items simulating the inventory of a botany pot. This is not an actual inventory, only an immutable simulation.
All Implemented Interfaces:
BotanyPotContext, net.minecraft.world.item.crafting.RecipeInput

public record DisplayContext(List<net.minecraft.world.item.ItemStack> inventory) extends Record implements BotanyPotContext
Recipe context that is provided when a pot is not available. This context should only be used on the client in contexts like a JEI plugin.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DisplayContext(List<net.minecraft.world.item.ItemStack> inventory)
    Creates an instance of a DisplayContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.level.storage.loot.LootParams
    createLootParams(@Nullable net.minecraft.world.level.block.state.BlockState state)
    Creates loot table parameters for generating loot from a loot table.
    final boolean
    Indicates whether some other object is "equal to" this one.
    net.minecraft.world.item.ItemStack
    Gets the item in the harvest tool slot.
    net.minecraft.world.item.ItemStack
    Gets the item used by the player if one was used.
    @NotNull net.minecraft.world.item.ItemStack
    getItem(int i)
     
    @Nullable net.minecraft.world.entity.player.Player
    Gets the relevant player if one is available.
    int
    Determines the total amount of growth ticks required for the crop to fully mature based on the current conditions.
    net.minecraft.world.item.ItemStack
    Gets the item in the seed slot.
    net.minecraft.world.item.ItemStack
    Gets the item in the soil slot.
    final int
    Returns a hash code value for this object.
    List<net.minecraft.world.item.ItemStack>
    Returns the value of the inventory record component.
    boolean
    Determines if the action is happening on the server thread.
    void
    runFunction(net.minecraft.resources.ResourceLocation functionId)
    Runs an MCFunction file based on the provided ID.
    int
     
    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

    Methods inherited from interface net.minecraft.world.item.crafting.RecipeInput

    isEmpty
  • Constructor Details

    • DisplayContext

      public DisplayContext(List<net.minecraft.world.item.ItemStack> inventory)
      Creates an instance of a DisplayContext record class.
      Parameters:
      inventory - the value for the inventory record component
  • Method Details

    • getSoilItem

      public net.minecraft.world.item.ItemStack getSoilItem()
      Description copied from interface: BotanyPotContext
      Gets the item in the soil slot.
      Specified by:
      getSoilItem in interface BotanyPotContext
      Returns:
      The item in the soil slot.
    • getSeedItem

      public net.minecraft.world.item.ItemStack getSeedItem()
      Description copied from interface: BotanyPotContext
      Gets the item in the seed slot.
      Specified by:
      getSeedItem in interface BotanyPotContext
      Returns:
      The item in the seed slot.
    • getHarvestItem

      public net.minecraft.world.item.ItemStack getHarvestItem()
      Description copied from interface: BotanyPotContext
      Gets the item in the harvest tool slot. This is not the same as the players held item.
      Specified by:
      getHarvestItem in interface BotanyPotContext
      Returns:
      The item in the harvest tool slot.
    • createLootParams

      public net.minecraft.world.level.storage.loot.LootParams createLootParams(@Nullable @Nullable net.minecraft.world.level.block.state.BlockState state)
      Description copied from interface: BotanyPotContext
      Creates loot table parameters for generating loot from a loot table. Loot tables only exist on the server thread and parameters can not be constructed on a client thread.
      Specified by:
      createLootParams in interface BotanyPotContext
      Parameters:
      state - The state for the block_state parameter. Sometimes it is necessary to use a different block to get te right loot table results. For example, the wheat loot table checks the block id and age.
      Returns:
      Loot parameters based on the current context.
    • runFunction

      public void runFunction(net.minecraft.resources.ResourceLocation functionId)
      Description copied from interface: BotanyPotContext
      Runs an MCFunction file based on the provided ID. Functions can only be executed on the server thread, trying to do this on a client thread will cause issues.
      Specified by:
      runFunction in interface BotanyPotContext
      Parameters:
      functionId - The ID of the MCFunction to run.
    • getPlayer

      @Nullable public @Nullable net.minecraft.world.entity.player.Player getPlayer()
      Description copied from interface: BotanyPotContext
      Gets the relevant player if one is available.
      Specified by:
      getPlayer in interface BotanyPotContext
      Returns:
      The relevant player if one is available.
    • getInteractionItem

      public net.minecraft.world.item.ItemStack getInteractionItem()
      Description copied from interface: BotanyPotContext
      Gets the item used by the player if one was used.
      Specified by:
      getInteractionItem in interface BotanyPotContext
      Returns:
      The item the player used to interact.
    • getRequiredGrowthTicks

      public int getRequiredGrowthTicks()
      Description copied from interface: BotanyPotContext
      Determines the total amount of growth ticks required for the crop to fully mature based on the current conditions.
      Specified by:
      getRequiredGrowthTicks in interface BotanyPotContext
      Returns:
      The total amount of growth ticks required to grow the crop.
    • isServerThread

      public boolean isServerThread()
      Description copied from interface: BotanyPotContext
      Determines if the action is happening on the server thread. It does not matter if the server is integrated or dedicated.
      Specified by:
      isServerThread in interface BotanyPotContext
      Returns:
      If the action is happening on a server thread.
    • getItem

      @NotNull public @NotNull net.minecraft.world.item.ItemStack getItem(int i)
      Specified by:
      getItem in interface net.minecraft.world.item.crafting.RecipeInput
    • size

      public int size()
      Specified by:
      size in interface net.minecraft.world.item.crafting.RecipeInput
    • 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.
    • inventory

      public List<net.minecraft.world.item.ItemStack> inventory()
      Returns the value of the inventory record component.
      Returns:
      the value of the inventory record component