Interface IFarmable


public interface IFarmable
IFarmable describes a farmable resource, including its sapling/premature and mature versions, its saplings/seeds, and the harvested resources resulting from harvesting and collecting from windfall.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addGermlings(Consumer<net.minecraft.world.item.ItemStack> accumulator)
    Used by JEI to display the seeds/saplings/etc.
    default void
    addProducts(Consumer<net.minecraft.world.item.ItemStack> accumulator)
    Used by JEI to display the products of this farmable.
    getCropAt(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Used by farms to get crops of this farmable if the block at the position matches.
    boolean
    isGermling(net.minecraft.world.item.ItemStack stack)
    Used by the farm to check if an item can be used to plant this farmable.
    boolean
    isSaplingAt(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
    boolean
    isWindfall(net.minecraft.world.item.ItemStack stack)
    Used by the farm to pickup nearby products that might have fallen from decayed leaves.
    boolean
    plantSaplingAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack germling, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    Plants a sapling by manipulating the world.
  • Method Details

    • isSaplingAt

      boolean isSaplingAt(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Returns:
      true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop.
    • getCropAt

      @Nullable ICrop getCropAt(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Used by farms to get crops of this farmable if the block at the position matches.
      Parameters:
      level - The world.
      pos - The position to check for a mature crop. Can be different than the base position.
      state - The block state at the position.
      Returns:
      ICrop if the block at the given location is a harvestable and mature crop, null otherwise.
    • isGermling

      boolean isGermling(net.minecraft.world.item.ItemStack stack)
      Used by the farm to check if an item can be used to plant this farmable.
      Parameters:
      stack - A potential item to be input into the farm.
      Returns:
      true if the item is a valid seed/sapling/etc. for this farmable.
    • addGermlings

      default void addGermlings(Consumer<net.minecraft.world.item.ItemStack> accumulator)
      Used by JEI to display the seeds/saplings/etc. of this farmable.
      Parameters:
      accumulator - Accepts new item stacks for germlings.
    • addProducts

      default void addProducts(Consumer<net.minecraft.world.item.ItemStack> accumulator)
      Used by JEI to display the products of this farmable.
      Parameters:
      accumulator - Accepts new item stacks for products.
    • isWindfall

      boolean isWindfall(net.minecraft.world.item.ItemStack stack)
      Used by the farm to pickup nearby products that might have fallen from decayed leaves. For example, tree farms typically only harvest the trunks, which means that as the leaves decay, items will spawn that need to be collected by the farm as products of the tree.
      Returns:
      true if the item should be collected as windfall.
    • plantSaplingAt

      boolean plantSaplingAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack germling, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Plants a sapling by manipulating the world. The IFarmLogic should have verified the given location as valid. Called by the IFarmHousing which handles resources.
      Returns:
      true if a sapling was planted, false otherwise.