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
ConstructorsConstructorDescriptionDisplayContext(List<net.minecraft.world.item.ItemStack> inventory) Creates an instance of aDisplayContextrecord 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.@Nullable CropgetCrop()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 i) @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.@Nullable SoilgetSoil()net.minecraft.world.item.ItemStackGets the item in the soil slot.final inthashCode()Returns a hash code value for this object.List<net.minecraft.world.item.ItemStack> Returns the value of theinventoryrecord component.booleanDetermines if the action is happening on the server thread.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
-
DisplayContext
Creates an instance of aDisplayContextrecord class.- Parameters:
inventory- the value for theinventoryrecord component
-
-
Method Details
-
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.
-
getCrop
- Specified by:
getCropin interfaceBotanyPotContext
-
getSoil
- Specified by:
getSoilin interfaceBotanyPotContext
-
getItem
@NotNull public @NotNull net.minecraft.world.item.ItemStack getItem(int i) - Specified by:
getItemin interfacenet.minecraft.world.item.crafting.RecipeInput
-
size
public int size()- Specified by:
sizein interfacenet.minecraft.world.item.crafting.RecipeInput
-
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). -
inventory
Returns the value of theinventoryrecord component.- Returns:
- the value of the
inventoryrecord component
-