How do i make a block that damages player?

Started by withermasterbmods on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do i make a block that damages player?

How do i make a block that very slowly damages player unless they have an item in their inventory?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If the block's collision box…
Sat, 10/07/2023 - 18:01

If the block's collision box is smaller than a regular block, (like honey or sweet berries), you can just have it trigger a damage procedure when the player collides inside the block. If it's a solid block, you can make a procedure that triggers on update tick, and runs an entity iterator centered on the block's position, (x + 0.5, y + 0.5, z + 0.5), with a 1.1 block radius. (Thus targeting anything touching the block.) 

Then just check if the target entity/entity iterator, (depending on your approach), has the desired item in their inventory. I'm pretty sure there's a function block to do this, but if there isn't, you should be able to use an itemstack iterator to check each inventory slot individually.