Started by
Mike1237
on
Topic category: Help with Minecraft modding (Java Edition)
I would like to add health to the block, so that when damage is inflicted, a couple of health points are taken from the block and so that when the health level of the block reaches 0, it disappears.
Edited by Mike1237 on Sun, 04/30/2023 - 15:51
I can think of a few ways to do this.
The first is to make an entity, set its hitbox to solid, and use Blockbench to make a custom texture exactly 16x16x16 pixels. You can then give this entity health. It is also advisable to disable AI so it doesn't get affected by gravity, unless that's something you want.
The second option is to make an NBT tag to keep track of health. (You'll need to enable block entity for this to work!) Then, make a procedure that is invoked upon a block's destruction. First, check if the block is the right type. Then, have it check to see how much health is left. If the answer is more than 1, it will decrease health by one and cancel the event trigger.
The first option requires Blockbench, but it comes with the red flash and damage sounds like real damage. The second option doesn't require Blockbench work, but it's a bit more complex on the procedure side.