All Implemented Interfaces:
CacheableRecipe, net.minecraft.world.item.crafting.Recipe<BotanyPotContext>
Direct Known Subclasses:
BlockDerivedCrop

public class BasicCrop extends Crop implements CacheableRecipe
  • Field Details

    • DIRT

      public static final net.minecraft.world.item.crafting.Ingredient DIRT
    • CODEC

      public static final com.mojang.serialization.MapCodec<BasicCrop> CODEC
    • STREAM

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BasicCrop> STREAM
    • SERIALIZER

      public static final net.minecraft.world.item.crafting.RecipeSerializer<BasicCrop> SERIALIZER
    • TOOLTIP_WRONG_SOIL

      public static final net.minecraft.network.chat.Component TOOLTIP_WRONG_SOIL
  • Constructor Details

  • Method Details

    • getBasicProperties

      public BasicCrop.Properties getBasicProperties()
    • matches

      public boolean matches(@NotNull @NotNull BotanyPotContext input, @NotNull @NotNull net.minecraft.world.level.Level level)
      Specified by:
      matches in interface net.minecraft.world.item.crafting.Recipe<BotanyPotContext>
    • couldMatch

      public boolean couldMatch(net.minecraft.world.item.ItemStack candidate, BotanyPotContext context, net.minecraft.world.level.Level level)
      Description copied from class: BotanyPotRecipe
      Tests if the recipe is valid for the current context.
      Specified by:
      couldMatch in class BotanyPotRecipe
      Parameters:
      candidate - The item to test.
      context - The current context.
      level - The current game level.
      Returns:
      If the recipe is valid.
    • onHarvest

      public void onHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops)
      Description copied from class: Crop
      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.
      Specified by:
      onHarvest in class Crop
      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 List<Display> getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level)
      Description copied from class: Crop
      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.
      Specified by:
      getDisplayState in class Crop
      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 int getRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level)
      Description copied from class: Crop
      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.
      Specified by:
      getRequiredGrowthTicks in class 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 boolean isGrowthSustained(BotanyPotContext context, net.minecraft.world.level.Level level)
      Description copied from class: Crop
      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.
      Specified by:
      isGrowthSustained in class Crop
      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.
    • canBeCached

      public boolean canBeCached()
      Description copied from interface: CacheableRecipe
      Determines if recipe can be cached based on the deserialized contents of the recipe. For example, imagine a recipe with an optional list of non-cacheable conditions. If this list is not present or empty, the recipe could be cached when it otherwise could not.
      Specified by:
      canBeCached in interface CacheableRecipe
      Returns:
      If the recipe can be cached.
    • isCacheKey

      public boolean isCacheKey(net.minecraft.world.item.ItemStack stack)
      Description copied from interface: CacheableRecipe
      Determines if a given item would be a valid cache key for this recipe. Recipes can have more than one valid key.

      Implementations should only check intrinsic properties of the stack like the item id, tags, and the type of the item. Properties like data components should not be checked as these are not intrinsic to the item. An ItemStack is only provided in this context because it is needed to test Ingredient.

      Specified by:
      isCacheKey in interface CacheableRecipe
      Parameters:
      stack - The item to test.
      Returns:
      If the item is a valid cache key for this recipe.
    • getSerializer

      @NotNull public @NotNull net.minecraft.world.item.crafting.RecipeSerializer<?> getSerializer()
      Specified by:
      getSerializer in interface net.minecraft.world.item.crafting.Recipe<BotanyPotContext>
    • hoverTooltip

      public void hoverTooltip(net.minecraft.world.item.ItemStack stack, BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.network.chat.Component> tooltipLines)
      Description copied from class: BotanyPotRecipe
      Populates a tooltip when the item is hovered in a botany pot.
      Overrides:
      hoverTooltip in class BotanyPotRecipe
      Parameters:
      stack - The ItemStack being hovered.
      context - The context of the current situation.
      level - The current game level.
      tooltipLines - The list of tooltips being displayed.
    • isValidSoil

      public boolean isValidSoil(net.minecraft.world.item.ItemStack stack)