Common API - Nyphet/harvest-with-ease GitHub Wiki
In both Fabric and Forge the class
HarvestWithEaseAPI is available.
It contains the following 2 methods:
Returns whether the given
Blockis 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
BlockStateinstance you can easily retrieve the
Blockit derives from by calling
IntegerPropertyage of the given crop.
Note that is can throw
ClassCastExceptionif 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!).
isTallCrop(Level, 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).