java.lang.Object
net.darkhax.botanypots.common.api.data.recipes.BotanyPotRecipe
net.darkhax.botanypots.common.api.data.recipes.crop.Crop
All Implemented Interfaces:
net.minecraft.world.item.crafting.Recipe<BotanyPotContext>
Direct Known Subclasses:
BasicCrop

public abstract class Crop extends BotanyPotRecipe
Represents a type of crop that can grow in the botany pot.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<RecipeCache<Crop>>
     
    static final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<Map<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.RecipeHolder<Crop>>>
     
    static final Supplier<net.minecraft.world.item.crafting.RecipeType<Crop>>
     

    Fields inherited from interface net.minecraft.world.item.crafting.Recipe

    CODEC, STREAM_CODEC
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canHarvest(BotanyPotContext context, net.minecraft.world.level.Level level)
    Checks if the crop can be harvested.
    static @Nullable net.minecraft.world.item.crafting.RecipeHolder<Crop>
    getCrop(net.minecraft.world.level.Level level, BotanyPotContext context, net.minecraft.world.item.ItemStack stack)
    Gets the crop that best represents an item.
    abstract List<Display>
    getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level)
    Gets the display states that should be rendered for the crop.
    int
    getLightLevelEmitted(BotanyPotContext context, net.minecraft.world.level.Level level)
    Gets the light level emitted by the crop.
    abstract int
    getRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level)
    The amount of ticks required for the crop to grow under normal circumstance.
    @NotNull net.minecraft.world.item.crafting.RecipeType<?>
     
    abstract boolean
    isGrowthSustained(BotanyPotContext context, net.minecraft.world.level.Level level)
    Checks if the crop can still grow under the current circumstances.
    void
    onGrowthTick(BotanyPotContext context, net.minecraft.world.level.Level level)
    Invoked every tick while the crop is in a pot and the growth of the crop is sustained.
    abstract void
    onHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops)
    Handles the harvesting logic for the crop.
    void
    onTick(BotanyPotContext context, net.minecraft.world.level.Level level)
    Invoked every tick while the crop is in a pot.

    Methods inherited from class net.darkhax.botanypots.common.api.data.recipes.BotanyPotRecipe

    assemble, canCraftInDimensions, couldMatch, getResultItem, hoverTooltip, isSpecial, recipeCodec, recipeStream, showNotification

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

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

    getGroup, getIngredients, getRemainingItems, getSerializer, getToastSymbol, isIncomplete, matches
  • Field Details

    • TYPE

      public static final Supplier<net.minecraft.world.item.crafting.RecipeType<Crop>> TYPE
    • RECIPES

      public static final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<Map<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.RecipeHolder<Crop>>> RECIPES
    • CACHE

      public static final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<RecipeCache<Crop>> CACHE
  • Constructor Details

    • Crop

      public Crop()
  • Method Details

    • onHarvest

      public abstract void onHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops)
      Handles the harvesting logic for the crop. This is invoked when the crop is harvested by a player or through some automatic action like a hopping botany pot.
      Parameters:
      context - Additional context about the pot that is growing the crop and how the crop was harvested.
      level - The world in which the crop was harvested.
      drops - Collects items that were dropped as a result of harvesting the crop. For example, this may drop the items into the world or insert them into the pots inventory depending on how the crop was harvested.
    • getDisplayState

      public abstract List<Display> getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level)
      Gets the display states that should be rendered for the crop. When multiple displays are returned they will be rendered in bottom up order. For example if the crop is a 2 block tall multi-block you could return the lower block as the first display and the top block as the second display.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
      Returns:
      A list of display states to render for the crop.
    • getRequiredGrowthTicks

      public abstract int getRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level)
      The amount of ticks required for the crop to grow under normal circumstance. The result should not include fertilizer, soil growth modifiers, or any other modifier that is not inherent to the crop.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
      Returns:
      The base amount of ticks required to grow the crop.
    • isGrowthSustained

      public abstract boolean isGrowthSustained(BotanyPotContext context, net.minecraft.world.level.Level level)
      Checks if the crop can still grow under the current circumstances. This will be used to revalidate if the crop can continue to grow in the pot or if it is invalid. Crops that have reached max age should still have their growth sustained.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
      Returns:
      If the crop can still grow under the current circumstances.
    • getLightLevelEmitted

      public int getLightLevelEmitted(BotanyPotContext context, net.minecraft.world.level.Level level)
      Gets the light level emitted by the crop.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
      Returns:
      The light level emitted by the crop.
    • onTick

      public void onTick(BotanyPotContext context, net.minecraft.world.level.Level level)
      Invoked every tick while the crop is in a pot. This can be used for adding tick based effects to your crop, like a random chance to spawn a mob, mutate, or wither.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
    • onGrowthTick

      public void onGrowthTick(BotanyPotContext context, net.minecraft.world.level.Level level)
      Invoked every tick while the crop is in a pot and the growth of the crop is sustained.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
    • canHarvest

      public boolean canHarvest(BotanyPotContext context, net.minecraft.world.level.Level level)
      Checks if the crop can be harvested. This can be used to add harvest conditions that are unrelated to the standard growth logic, like only allowing the crop to be harvested at night.
      Parameters:
      context - Additional context about the pot that is growing the crop.
      level - The world the crop is growing in.
      Returns:
      If the crop can be harvested.
    • getType

      @NotNull public @NotNull net.minecraft.world.item.crafting.RecipeType<?> getType()
    • getCrop

      @Nullable public static @Nullable net.minecraft.world.item.crafting.RecipeHolder<Crop> getCrop(net.minecraft.world.level.Level level, BotanyPotContext context, net.minecraft.world.item.ItemStack stack)
      Gets the crop that best represents an item.
      Parameters:
      level - The current game level.
      context - The current game context.
      stack - The item to lookup.
      Returns:
      The crop that best represents the item.