Common API - Nyphet/harvest-with-ease GitHub Wiki
HarvestWithEaseAPI
In both Fabric and Forge the class HarvestWithEaseAPI
is available.
It contains the following 2 methods:
isCrop(Block)
Returns whether the givenBlock
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 aBlockState
instance you can easily retrieve theBlock
it derives from by callingBlockState#getBlock()
.getAge(BlockState)
Returns theIntegerProperty
age of the given crop.
Note that is can throwNullPointerException
,NoSuchElementException
orClassCastException
if it was not possible to find the age property in the givenBlockState
, 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).