Try:
/execute <selector> ~ ~ ~ fill <relative coordinates> air 0 replace wool
[EDIT]
If you are wanting the block to disappear after a certain amount of time, say, 30 redstone ticks (60 game ticks), you could summon a WitherSkull
below the player and use the execute command on it.
To make the block disappear, you would add a new scoreboard command, lifetime
, for instance, and run /scoreboard players add @e[type=WitherSkull] lifetime 1
with a setblock or fill clock, then execute another fill command on every wither skull with a certain lifetime value, like:
/execute @e[type=WitherSkull,score_lifetime_min=31] ~ ~ ~ /fill ~ ~ ~ ~ ~ ~ wool 0 replace air
.
Then, you would kill the wither skull: /kill @e[type=WitherSkull,score_lifetime_min=35]
.
Here is a screenshot of what I did:
Assuming you have the "sentry gun" shooting arrows, you would use the command:
/summon Arrow x y z {damage:1,Motion:[x.0,y.0,z.0]}
You would have to plug into the first set of coordinates where you want the arrows to be shooting from, and the direction the arrows are shooting in the second. TIP: The higher the number you set for your direction (second set of coordinates, the faster the arrow will travel! You can set anything for the damage (except dont get too crazy :P)
As for your "Tool Box" Idea, you can do the test for command on a redstone ticker:
testfor @e[x,y,z,r,type=Item] {Item:{id:minecraft:iron_block}}
(Unfortunately, you cant test for a custom named block/entity - at least to my knowledge) Run a comparator out of this command block, to another command block (does not NEED to be a command block). This will start a fast ticking redstone clock on another command block. This command block will have the command:
testfor @e[x,y+1,z,r,type=Item] {Item:{id:minecraft: ... }}
Make sure that the coordinates you plug into the last testfor command have y+1 the y coordinate of the testfor command before that. This means it will test for the item on top of your "tool box". Run a comparator out of that command block to start the /summon Arrow command, or in other words, start up your sentry!
(The arrows are seen only as little black dots in this photo, but thats because I have the speed ramped up :)
Basically, its a system of Testing positive for an iron block at x y z - starting ticker to test for ... entity at x y+1 z - testing positive for ... entity at x y+1 z - starting ticker to shoot "sentry gun"
Hope this helps
Best Answer
Note: this Answer is based off the assumption that you are making that structure using a command or making it yourself. Sorry if this is not correct.
A) Marking the structure:
First, whenever that structure is spawned, summon an armorstand in one of those blocks with the NBT tags Invisible, CustomName and Marker. (Ex.
/summon ArmorStand x y z {Marker:1b, Invisible:1b, CustomName:bob}
)B) marking the player as near the structure:
Make a dummy scoreboard (example name:nearS) Now add this command to a 20 t/s clock:
execute @a ~ ~ ~ execute @e[type=ArmorStand,name=bob,r=1] ~ ~ ~ scoreboard players set @p nearS 1
and this command also on that clock:scoreboard players set @a nearS 0
(making 20 tick/s clock) Then, you can distinguish which players are near it and which are not by their number on the scoreboard nearS.