How to add health for minecraft block?

Started by Mike1237 on

Topic category: Help with modding (Java Edition)

Last seen on 15:57, 17. Jul 2023
Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to add health for minecraft block?
Sun, 04/30/2023 - 15:51 (edited)

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
Last seen on 00:07, 8. Apr 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can think of a few ways to…
Sun, 04/30/2023 - 16:03

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.