This can be done via the /fill command within /execute.
/execute @a ~ ~ ~ fill ~10 ~10 ~10 ~-10 ~-10 ~-10 pumpkin 0 replace dropper 1
/execute @a ~ ~ ~ fill ~10 ~10 ~10 ~-10 ~-10 ~-10 dropper 1 replace pumpkin 0
You don't have to use a pumpkin, any unused block will do.
Put these two commands separately on a fill clock and run a comparator out from either of the two command blocks with the commands in them. Whenever any player is within 10 blocks (including diagonals, unfortunately) of a dropper with the data value of 1 (was that facing down? I can't remember), the comparator will turn on. Whenever they move out of range, it will turn off. That's currently the closest you can get to what you asked.
Your command is working perfectly fine. Make sure it runs on a clock!
It has a couple flaws though:
- not multiplayer friendly: You would teleport every player, once a
bottle is in the air
- suspended player: The player will not
be able to move until the bottle hits the ground, as you're constantly teleporting him. This is especially bad if you happen to throw a bottle down a high cliff.
But here is an alternative solution, that is more reliable and multiplayer friendly!
The first thing you need to do, is to set up a scoreboard achievement: (type this in chat)
/scoreboard objectives add ExpThrown stat.useItem.minecraft.experience_bottle
This will count the number of times a player has thrown an experience bottle.
The next thing you want to do is to build a clock that activates a command block with the following command:
tp @a[score_ExpThrown_min=1] x y z
That is going to teleport all the players that have thrown an experience bottle to the specified coordinates (replace x, y and z).
Now, place a comparator facing away from that command block, into a new one with this command:
scoreboard players set @a[score_ExpThrown_min=1] ExpThrown 0
That will reset the objective, so that you only get teleported once.
Best Answer
The simple act of giving a fox a sweet berry cannot be detected. What you can do is either:
bred_animals
advancement trigger (archive) and a condition for the parent to be a fox (this does not detect giving a lone fox a sweet berry)used:sweet_berries
(archive) (this also detects eating sweet berries while standing near a fox)