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
ConstructorsConstructorDescriptionBlockEntityContext(BotanyPotBlockEntity pot, @Nullable net.minecraft.world.entity.player.Player player, @Nullable net.minecraft.world.InteractionHand hand) Creates an instance of aBlockEntityContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.level.storage.loot.LootParamscreateLootParams(@Nullable net.minecraft.world.level.block.state.BlockState state) Creates loot table parameters for generating loot from a loot table.final booleanIndicates whether some other object is "equal to" this one.net.minecraft.world.item.ItemStackGets the item in the harvest tool slot.net.minecraft.world.item.ItemStackGets the item used by the player if one was used.@NotNull net.minecraft.world.item.ItemStackgetItem(int slotId) @Nullable net.minecraft.world.entity.player.PlayerGets the relevant player if one is available.intDetermines the total amount of growth ticks required for the crop to fully mature based on the current conditions.net.minecraft.world.item.ItemStackGets the item in the seed slot.net.minecraft.world.item.ItemStackGets the item in the soil slot.@Nullable net.minecraft.world.InteractionHandhand()Returns the value of thehandrecord component.final inthashCode()Returns a hash code value for this object.booleanDetermines if the action is happening on the server thread.@Nullable net.minecraft.world.entity.player.Playerplayer()Returns the value of theplayerrecord component.pot()Returns the value of thepotrecord component.voidrunFunction(net.minecraft.resources.ResourceLocation functionId) Runs an MCFunction file based on the provided ID.intsize()final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 aBlockEntityContextrecord class.
-
-
Method Details
-
getItem
@NotNull public @NotNull net.minecraft.world.item.ItemStack getItem(int slotId) - Specified by:
getItemin interfacenet.minecraft.world.item.crafting.RecipeInput
-
size
public int size()- Specified by:
sizein interfacenet.minecraft.world.item.crafting.RecipeInput
-
getSoilItem
public net.minecraft.world.item.ItemStack getSoilItem()Description copied from interface:BotanyPotContextGets the item in the soil slot.- Specified by:
getSoilItemin interfaceBotanyPotContext- Returns:
- The item in the soil slot.
-
getSeedItem
public net.minecraft.world.item.ItemStack getSeedItem()Description copied from interface:BotanyPotContextGets the item in the seed slot.- Specified by:
getSeedItemin interfaceBotanyPotContext- Returns:
- The item in the seed slot.
-
getHarvestItem
public net.minecraft.world.item.ItemStack getHarvestItem()Description copied from interface:BotanyPotContextGets the item in the harvest tool slot. This is not the same as the players held item.- Specified by:
getHarvestItemin interfaceBotanyPotContext- 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:BotanyPotContextCreates 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:
createLootParamsin interfaceBotanyPotContext- 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:BotanyPotContextRuns 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:
runFunctionin interfaceBotanyPotContext- Parameters:
functionId- The ID of the MCFunction to run.
-
getPlayer
@Nullable public @Nullable net.minecraft.world.entity.player.Player getPlayer()Description copied from interface:BotanyPotContextGets the relevant player if one is available.- Specified by:
getPlayerin interfaceBotanyPotContext- Returns:
- The relevant player if one is available.
-
getInteractionItem
public net.minecraft.world.item.ItemStack getInteractionItem()Description copied from interface:BotanyPotContextGets the item used by the player if one was used.- Specified by:
getInteractionItemin interfaceBotanyPotContext- Returns:
- The item the player used to interact.
-
getRequiredGrowthTicks
public int getRequiredGrowthTicks()Description copied from interface:BotanyPotContextDetermines the total amount of growth ticks required for the crop to fully mature based on the current conditions.- Specified by:
getRequiredGrowthTicksin interfaceBotanyPotContext- Returns:
- The total amount of growth ticks required to grow the crop.
-
isServerThread
public boolean isServerThread()Description copied from interface:BotanyPotContextDetermines if the action is happening on the server thread. It does not matter if the server is integrated or dedicated.- Specified by:
isServerThreadin interfaceBotanyPotContext- Returns:
- If the action is happening on a server thread.
-
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). -
pot
Returns the value of thepotrecord component.- Returns:
- the value of the
potrecord component
-
player
@Nullable public @Nullable net.minecraft.world.entity.player.Player player()Returns the value of theplayerrecord component.- Returns:
- the value of the
playerrecord component
-
hand
@Nullable public @Nullable net.minecraft.world.InteractionHand hand()Returns the value of thehandrecord component.- Returns:
- the value of the
handrecord component
-