Getting Started (Tutorial)
Step 1: Add BlockHardness to your project
Step 2: The player needs the miner fatigue potion effect for this plugin to work! Because of this, you'll need to give it to them when they join, or whenever you want them to have a custom block breaking speed. IT NEEDS TO BE MINER FATIGUE LEVEL -1!!
Keep in mind the BlockHardness library was designed for my CustomDrops plugin which handles custom drops which is why it doesn't support many regular dropping options like fortune, tools, etc. You're meant to handle that in your own plugin if you wish to do so.
Step 3: Now that your player has MinerFatigue LEVEL -1, you have to listen to the BlockHardnessBlockInteractEvent to start the mining process with your desired speed. Example of how I use it in my CustomDrops Plugin:
Method BreakPlayer#startMining(Block block, double breakSpeedInSeconds, boolean dropVanillaBlock).
Param 1: The block you want to start mining
Param 2: The speed at which the block should be mined at
Param 3: If the block should drop itself when broken For example, my CustomDrops plugin uses it but has conditions to limit whether or not a player can mine with certain permissions, what speed the player will mine based on their tool, fortune multiplier if tool has fortune, etc.
Optional Step 4: You can also listen to the CustomHardnessBlockBreakEvent. This event is fired when a block is done being mined at a custom speed. I use this event to drop custom drops in my CustomDrops plugin. You can do whatever you want with it though. For example, OreRegenerator uses this event to add regeneration support to CustomHardness blocks because they don't fire a BlockBreakEvent.
Last updated