Detect broken blocks that don't drop items
I'm trying to make certain aspects of survival more "painfully realistic" using command blocks. One of those things is that I'd like mining through stone (or other hard objects) with your bare hands to inflict damage on you. I thought this would be as easy as setting up a stat.mineBlock score and, whenever someone mines stone, if they have an empty hand, give them instant damage effects. Unfortunately, it seems the mineBlock stat only increments if the block drops an item, and mining stone with your hands doesn't drop any items. Is there another way to go about detecting when a player has destroyed a block, even if it doesn't drop any items?
Best Answer
It might be laggy, but you could try execute, clone, and testforblocks to detect changes in the player's environment.
Pictures about "Detect broken blocks that don't drop items"



How do you detect the A block is broken in Minecraft?
According to the fandom page on /clone you can test whether a player has broken any blocks by /cloning the region the player is in to another location far away, then /cloning the same region. If any blocks have changed, it should result in the number of blocks that were changed.Can you locate certain blocks in Minecraft?
The blank is for the particular block you are looking for. Let's say you're lost in the Nether and need to find your Nether Portal, you could type : /locateblock obsidian, and get the coordinates for the nearest obsidian, most likely being your, said, Portal.BLOCK BREAKING DETECTION!? -- Command Block Tutorial
More answers regarding detect broken blocks that don't drop items
Answer 2
Testing for a player in a spesific coordinate
Set up a dummy objective:
/scoreboard objectives add NotHoldingItem dummy
On a clock (or just before you want to use the testfor), in this order, run the following commands:
scoreboard players set @a NotHoldingItem 1
scoreboard players set @a NotHoldingItem 0 {SelectedItem:{id:minecraft:iron_pickaxe}}
The commands above set everyone's NotHoldingItem score to 1, and then set it back to 0 for everyone holding the item, leaving only people not holding the item with a NotHoldingItem score of 1.
You can then test for people who have a NotHoldingItem score of 1 (do not have the pickaxe) near a certain block:
/testfor @a[x, y, z, score_NotHoldingItem_min=1]
Testing if where a player is looking at
The first value is the horizontal rotation (ry).
Horizontal rotation values vary from -180.0 (facing due north), to -90.0 (facing due east), to 0.0 (facing due south), to 90.0 (facing due west), to 179.9 (just west of due north) before wrapping back to -180.0 (thus horizontal rotation values increase with rotation to the right, or clockwise viewed from above).
The second value is the vertical rotation (rx).
Vertical rotation values vary from -90.0 facing straight up to 90.0 facing straight down (thus vertical rotation values increase with rotation downwards).
So to test for someone looking 45° upwards (±10) and to the northeast (=135±22)
testfor @a[ry=-113,rym=-157,rx=55,rxm=35]
for a player looking south you can do something like:
testfor @a[ry=22,rym=-22]
Combining these
when you would comebine these two testfors after having setup the scoreboard, you can simply use these to test for a player standing on a certain block and if the blocks he is looking at is the block you want to check.
testfor @a[x,y,z,rx,ry,rxm,rym,score_notHoldingItem_min=1]
Problem
this means you need two command blocks for each point of view to each block. In other words: you don't have enough space in a minecraft world to test each posibility. for testing one block within a void area (an area in which there are no blocks exept the one you want to test) you need to have 2 comand blocks for each block in a 9x9x9 box in which the block to be testet is in the middle
((9x9x9)-1)x2 Command blocks = 1456 command blocks
I think this awnsers you question as a: No, you can't do that...
Answer 3
The closest thing I could think of is if you use a stone monster egg block instead of regular stone. You could set a command block up to a clock that kills silverfish every time they spawn. Then, if the kill command is executed (you can test for this by putting a comparator next to the command block), you can deal damage to the player.
This wouldn't really work as well since the monster egg blocks have a different durability than regular stone, but I'm pretty sure this is the only way possible as of now. Mojang, pls fix your objectives :(
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Joshua Miranda, Sharon McCutcheon, Pixabay, Vivien Pintácsi
