Hi there,
I'm having some difficulty getting a block's actual harvest level - for context, I am implementing a ranged pickaxe which has a variable mining level depending on "oxidation".
To determine whether a block should be mined, I am using BlockState#getHarvestLevel(), however with certain blocks (e.g. glass and every block from other mods), it is returning -1, which I expect to be the value for unbreakable blocks e.g. bedrock, so I was checking against that.
Am I supposed to use a different method to get a block's harvest level? Or should I ignore the -1 check and simply hardcode in unbreakable blocks?
private boolean shouldMine(BlockState blockState)
{
int blockHardness = blockState.getHarvestLevel();
int oxidationStage = 0;
if (this.getItemStack().getItem() instanceof PickOnAStickItem)
{
PickOnAStickItem pickOnAStickItem = (PickOnAStickItem) this.getItemStack().getItem();
oxidationStage = pickOnAStickItem.oxidationStage;
}
return !blockState.isStickyBlock() &&
blockState.getPistonPushReaction() != PushReaction.PUSH_ONLY &&
blockState.getBlock() != Blocks.TARGET &&
blockHardness >= 0 &&
blockHardness <= 2 - oxidationStage;
}