Record Class BlockEntityContext

java.lang.Object
java.lang.Record
net.darkhax.botanypots.common.api.context.BlockEntityContext
Record Components:
pot - The botany pot that is available.
player - An optional player that is relevant to the current context.
hand - The hand being used by the player, if one was used.
All Implemented Interfaces:
BotanyPotContext, net.minecraft.world.item.crafting.RecipeInput

public record BlockEntityContext(BotanyPotBlockEntity pot, @Nullable net.minecraft.world.entity.player.Player player, @Nullable net.minecraft.world.InteractionHand hand) extends Record implements BotanyPotContext
Recipe context that is provided when an actual botany pot is available.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockEntityContext(BotanyPotBlockEntity pot, @Nullable net.minecraft.world.entity.player.Player player, @Nullable net.minecraft.world.InteractionHand hand)
    Creates an instance of a BlockEntityContext 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 slotId)
     
    @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.
    @Nullable net.minecraft.world.InteractionHand
    Returns the value of the hand record component.
    final int
    Returns a hash code value for this object.
    boolean
    Determines if the action is happening on the server thread.
    @Nullable net.minecraft.world.entity.player.Player
    Returns the value of the player record component.
    pot()
    Returns the value of the pot record component.
    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

    • BlockEntityContext

      public BlockEntityContext(BotanyPotBlockEntity pot, @Nullable @Nullable net.minecraft.world.entity.player.Player player, @Nullable @Nullable net.minecraft.world.InteractionHand hand)
      Creates an instance of a BlockEntityContext record class.
      Parameters:
      pot - the value for the pot record component
      player - the value for the player record component
      hand - the value for the hand record component
  • Method Details

    • getItem

      @NotNull public @NotNull net.minecraft.world.item.ItemStack getItem(int slotId)
      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
    • 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.
    • 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.
    • pot

      public BotanyPotBlockEntity pot()
      Returns the value of the pot record component.
      Returns:
      the value of the pot record component
    • player

      @Nullable public @Nullable net.minecraft.world.entity.player.Player player()
      Returns the value of the player record component.
      Returns:
      the value of the player record component
    • hand

      @Nullable public @Nullable net.minecraft.world.InteractionHand hand()
      Returns the value of the hand record component.
      Returns:
      the value of the hand record component