0

I'm creating an adventure map for Minecraft and I need to use the /execute command with command blocks to detect when a player has thrown a Bottle O' Enchanting (Exp Bottle). If that has happened, the command teleports the player to the coordinates 0 0 0.

I tried the following command but it didn't work: /execute @e[type=ThrownExpBottle] ~ ~ ~ tp @p 0 0 0

2
  • Have you made any attempt to solve this yourself? Arqade works better when we have a problem where someone is stuck with something they're trying to get working. You get targeted answers for the specific part you're stuck, and Arqade gets more useful questions. Everybody wins!
    – Frank
    Oct 4, 2015 at 13:07
  • @Frank I tried the following command but it didn't work: /execute @e[type=ThrownExpBottle] ~ ~ ~ tp @p 0 0 0
    – m654
    Oct 4, 2015 at 13:16

1 Answer 1

4

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.

9
  • I don't know why, but this didn't seem to work. Neither of the command blocks had any output. I try to throw a bottle but I don't get teleported anywhere. (The coordinates are ~ ~5 ~)
    – m654
    Oct 4, 2015 at 16:16
  • Are you sure, that you have the first command block running on a clock? You can test that by typing say hello into it. If it spams your chat, then it's working.
    – Lars
    Oct 4, 2015 at 16:19
  • I'm completely sure It's running on a clock. I build a simple comparator clock.
    – m654
    Oct 5, 2015 at 16:14
  • Hmm... What version are you using? If you upload your world somewhere I'll look into it.
    – Lars
    Oct 5, 2015 at 16:21
  • I'm using 1.8.8. If you'll wait a second I'll upload it somewhere
    – m654
    Oct 5, 2015 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .