4

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?

1

It might be laggy, but you could try execute, clone, and testforblocks to detect changes in the player's environment.

1

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...

0

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 :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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