Package forestry.api.farming
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 TypeMethodDescriptiondefault voidaddGermlings(Consumer<net.minecraft.world.item.ItemStack> accumulator) Used by JEI to display the seeds/saplings/etc.default voidaddProducts(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.booleanisGermling(net.minecraft.world.item.ItemStack stack) Used by the farm to check if an item can be used to plant this farmable.booleanisSaplingAt(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) booleanisWindfall(net.minecraft.world.item.ItemStack stack) Used by the farm to pickup nearby products that might have fallen from decayed leaves.booleanplantSaplingAt(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:
ICropif 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:
trueif the item is a valid seed/sapling/etc. for this farmable.
-
addGermlings
Used by JEI to display the seeds/saplings/etc. of this farmable.- Parameters:
accumulator- Accepts new item stacks for germlings.
-
addProducts
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:
trueif 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. TheIFarmLogicshould have verified the given location as valid. Called by theIFarmHousingwhich handles resources.- Returns:
trueif a sapling was planted, false otherwise.
-