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
This is not possible, see MC-64634. Via Grum's comment, explaining that this will not work for various blocks:
Using it for anything other than the original block might make it not work.
It doesn't work for the ones without blockmodels.
Since banners do not have a block model, it cannot be rendered with the falling_block
entity. Hoppers, on the other hand, do have a block model, and so will render properly.
Best Answer
I will use armour stands in this answer, because I am more familiar with them. It should be pretty easy to switch everything to AECs, if you want that.
There are multiple ways to kill everything except for one entity in a given space, the easiest one is to just tag an arbitrary one (
limit=1
) and then kill all without that tag.But in your case this constant summoning and killing is actually not required and causes way more lag than necessary. Instead you could check whether an entity already exists in that space before summoning a new armour stand or AEC there. So a VeinMiner/TreeCapitator-like system could for example work like this:
Summon an armour stand at the manually broken block (you seem to have already figured out that part):
I will use the tag "vein" for all armour stands that are used in this VeinMiner-like system.
Then repeatedly execute a function as/at all VeinMiner armour stands that have not summoned new armour stands around them yet:
The function looks like this:
Explanation: At each of the 26 blocks around the armour stand, a new armour stand is summoned only if there is an oak log there and not another VeinMiner armour stand already. Finally, the armour stand tags itself with "done" so that it doesn't need to check around it anymore in the following iterations.
This already automatically deals with loops and never summons any more armour stand than necessary.
You can stop the iteration when no more armour stands with the tag "
vein
" and without the tag "done
" exist anymore (or after a certain number of repetitions, in case you apply it to e.g. stone in a default world).Using a function is actually required in this case. If you first summoned armour stands around all without the "done" tag and then tagged everything with "done", you would also tag the new ones. If you first tagged all with "done" and then summoned new armour stands around all without the tag "done", then of course nothing would happen, because there would be none without the tag left.
Alternatively you would need yet another tag for armour stands that got created in the current round.
Note that a check for
distance=0
does not always work correctly due to the bug MC-88533, so I'm using a radius of 0.1 here.