I want to have a redstone timer that has a signal into a command block, with /execute @a ~ ~ ~ testforblocks <Coordinate 1> <Coordinate 2> <Relative Position>
and then a compartor, testing if a structure 1 X away from the player (I may make it 2) is the same as a structure I built somewhere else. (A chest with a sign on top of it reading “[Case]” and then having 2 iron blocks next to the chest) Then, the chest will fill with random loot, and the iron and sign disappear. I know how to do the random loot, and how to make the blocks disappear, but using /execute
will only test if A player is next to the structure. How do I tell the players that are near the structure from the players that aren't?
1 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.
-
I am having a player build it anywhere in the world, and testing it from a pre-made structure, so an armor stand probably wouldn't work... Commented Aug 28, 2015 at 0:39
-
/testfor @a[x=nx , y=ny , z=nz, r=radius]
where nx, ny, nz is the location center of the area you want to test for presence, and r is the radius out from <nx, ny, nz> that you want to test in.