Common API - Crystal-Nest/harvest-with-ease GitHub Wiki

HarvestWithEaseAPI

In both Fabric and Forge the class HarvestWithEaseAPI is available.
It contains the following methods:

  • isCrop(Block)
    Returns whether the given Block is a crop, meaning it is either a subclass of CropBlock, NetherWartBlock, CocoaBlock or its resource location is one of the items inside the crops property of this mod configuration file.
    If you have a BlockState instance you can easily retrieve the Block it derives from by calling BlockState#getBlock().

  • getAge(BlockState)
    Returns the IntProperty age of the given crop.
    Note that is can throw NullPointerException, NoSuchElementException or ClassCastException if it was not possible to find the age property in the given BlockState, so each time you call this method you should wrap it in a try and catch block, handle the error and allow Minecraft to keep running (avoid crashes at all costs!).

  • isMature(BlockState) / isMature(BlockState, IntProperty)
    Returns whether the given crop is a mature crop by checking its age property against the given age property. When no age property is provided, the one present in the given BlockState is used instead.

  • isTallCrop(World, BlockState, BlockPos)
    Returns whether the given crop is a multi-block crop, which means a crop made of at least 2 vertically aligned blocks (e.g. Thermal Cultivation crops).

  • isTierForMultiHarvest(TieredItem)
    Returns whether the given tool has an high enough tier for multi-harvest.
    Note: this method only checks the tool tier, but does not check whether the tool is a hoe.

  • isTierIn(List<Tier>, String) / isTierIn(List<Tier>, ResourceLocation) / isTierIn(List<Tier>, Tier)
    Returns whether the given Tier is in the given list of tiers.
    Note: the ResourceLocation overload is available only on Forge/NeoForge.

  • getTierLevel(Tier) / getTierLevel(ResourceLocation) / getTierLevel(String)
    Returns the level of the given Tier.
    Note: the ResourceLocation overload is available only on Forge/NeoForge.

  • matchesTier(String, Tier)
    Returns whether the given String matches the given Tier.

⚠️ **GitHub.com Fallback** ⚠️