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
You said in the comments that you have multiple "guards" that each shoot at targets, potentially at the same time. That complicates the matter a bit, compared to this answer.
You need the scoreboards x
, y
and z
, all of type dummy
.
As a first step whenever you want something to fire I suggested creating a dummy entity that you can rotate towards the target, but I guess rotating the shooting entities themselves is probably better in your case:
execute as @e[shooter>] at @s run tp @s ~ ~ ~ facing entity @e[<selector for target>,limit=1]
Then you do basically the same as in my other answer, except that some things have to be done relative to the shooter, because just tagging the arrows doesn't work if there are multiple at the same time.
execute as @e[<shooter>] at @s run summon arrow ^ ^ ^1 {NoGravity:1}
execute as @e[type=arrow] store result score @s x run data get entity @s Pos[0] 10
execute as @e[type=arrow] store result score @s y run data get entity @s Pos[1] 10
execute as @e[type=arrow] store result score @s z run data get entity @s Pos[2] 10
execute as @e[type=armor_stand] store result score @s x run data get entity @s Pos[0] 10
execute as @e[type=armor_stand] store result score @s y run data get entity @s Pos[1] 10
execute as @e[type=armor_stand] store result score @s z run data get entity @s Pos[2] 10
execute as @e[type=armor_stand] at @s positioned ^ ^ ^1 run scoreboard players operation @e[type=arrow,distance=0] x -= @s x
execute as @e[type=armor_stand] at @s positioned ^ ^ ^1 run scoreboard players operation @e[type=arrow,distance=0] y -= @s y
execute as @e[type=armor_stand] at @s positioned ^ ^ ^1 run scoreboard players operation @e[type=arrow,distance=0] z -= @s z
execute as @e[type=arrow] store result entity @s Motion[0] double 0.1 run scoreboard players get @s x
execute as @e[type=arrow] store result entity @s Motion[1] double 0.1 run scoreboard players get @s y
execute as @e[type=arrow] store result entity @s Motion[2] double 0.1 run scoreboard players get @s z
You'll probably also want to tag the arrows in some way, so that you don't set their Motion
to 0 in the last step if they were fired from a bow or if you've already applied the motion to them (except if you want that).
Keep in mind that arrows lose a bit of speed over time, so it would at some point stop in midair. And the target can of course move. You can also adjust the scale factors (10
and 0.1
) if you want the arrows to be faster.
Best Answer
The
/summon
command is only usable on entity, like mobs, FallingSand/FallingGravel, arrows, etc. The biggest problem with that command is that you can only summon one entity at the time. If you want to summon multiple entity without repeating the command for each entity, you should use command block loop.Anyways, the most simple way to cover your "sculpture" is to use the fill command following those simple step:
Cover your "sculpture" with a layer of sand, using that type of command:
Replace the sand you just place with grass, using that type of command:
Be careful if there is sand blocks in you "sculpture", you better use gravel if you don't want them to be replaced.