2

I want to add block breaking detection and right click detect to a datapack I’m working on. I want this to be multiplayer friendly and I need to know who broke the block.

To add right click detection is easy. I just have a scoreboard for using a carrot/fungi on a stick. Now, I want to add block break detection, but I also want to know where the event occurred as a part of the detection.

This is we’re I’m stuck. I can use raycasting for location, but I don’t know how to detect if there is a block that was broken. I can’t use a bunch of scoreboards for each individual block. I don’t know if I can use loot tables to add a player uuid to a special drop as nbt. Although for that method, it probably won’t work because in that same datapack I have a loot table for each block already.

I have to have right click detection and block break detection both using a carrot/fungi on a stick. So using used pickaxe/other tool scoreboard won’t work either. Raycasting also won’t work since it isn’t multiplayer friendly because you can’t detect who broke the block.

If you have any questions or if any of this is unclear please comment below. Thanks for helping.

2 Answers 2

1

I do not know if there is a good way of doing this but I have used a trick to detect block-breaking to replace them with water for an underwater map.

The trick uses the fact that Java Edition has three different types of air: blocks_air, cave_air and void_air (these are used for terrain generation). When you break a block it always gets replaced with the normal air. So I used a fill command executed around the player every tick to replace the normal air with water. Then if I wanted to have air I used cave_air which would not get replaced.

In your case you could replace the blocks with cave air instead of water then you can probably store the success of that fill function to a scoreboard to see if a block is broken.

Note that this would mean you need to convert the air to cave_air in the first place. You can probably do that by having like a hollow cube around the player bigger than its reach where you replace the air with cave_air.

This will tell you when a block is broken. Not what block, so you would have to keep track of what block a player is looking at at all times.

-1

You can Just make an scoreboard like "Minecraft.mined.diamonds" And you look at the player ho have the scores =1.. Look to dropped diamons around him, and execute at the diamonds.

1
  • The problem with using scoreboards to detect when a player broke a block, is it doesn't work in creative. This also could be flawed, as when you break a block, it's item dropped, gets thrown in a specific direction. Good idea, but this won't work for me. Commented Apr 9, 2021 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.