1

How to TP player who has a specific item?

seriouswarrior's Avatar seriouswarrior11/18/15 10:09 pm
11/20/2015 12:21 am
seriouswarrior's Avatar seriouswarrior
Okay, so I can't figure out how to do this. I'm making a map where a bunch of players are racing towards a specific item (a diamond) and, I want the single person who removes the item from the chest to be teleported to a specific location. I can't figure out a command (or combination of commands) to plug into a command block that could help me.

Testing for the closest player won't work either.

If anyone has any solutions, they are much appreciated! Thank you in advance!

-SW
Posted by seriouswarrior's Avatar
seriouswarrior
Level 39 : Artisan Fox
30

Create an account or sign in to comment.

13

seriouswarrior
11/20/2015 12:21 am
Level 39 : Artisan Fox
seriouswarrior's Avatar
Awesome! Thank you, ToadieOdie and Jmal116! Working like a charm!
1
ToadieOdie
11/19/2015 5:27 pm
Level 54 : Grandmaster Goblin
ToadieOdie's Avatar
Sorry, I forgot to mention that. Jmal116 is right. You can name your objectives whatever it is you wish them to be.

And thank you, Jmal116, for explaining what the "b" means inside the tag. This code isn't intuitive for me, so I feel like I'm working blind with it and the wikis I have found explain it like it is expected that you already understand most of it.
1
Jmal116
11/19/2015 5:55 pm
Level 33 : Artisan Engineer
Jmal116's Avatar
Agreed. Assuming you're using the minecraft wiki (this one) then it's mostly good as just a lookup type of thing, rather than a learning type of thing. Still very useful though once you get the hang of how to read it.
1
ToadieOdie
11/19/2015 3:54 pm
Level 54 : Grandmaster Goblin
ToadieOdie's Avatar
Sweet! Typing "Count:#b" into the code works. But why? What does the "b" mean inside the data tag?
1
Jmal116
11/19/2015 5:21 pm
Level 33 : Artisan Engineer
Jmal116's Avatar
The 'b' is short for byte, and it's the data type for that tag. Basically there's a small bug in the game where sometimes you have to specify that (like in this case). There are others like floats (f), shorts (s), strings, and probably a few others that I'm forgetting about.

Also just one more note about the scoreboard thing, you can have more than one objective with different names other than Science. Just change the name of the objective in the command ToadieOdie gave to whatever you want (no spaces) and it should work beautifully.
1
Bertiecrafter
11/19/2015 3:37 pm
Level 70 : Legendary Engineer
Bertiecrafter's Avatar
it should be /testfor @a {...}

replace {...} with the data displayed in my previous message.
Also... for both commands (testfor and scoreboard) you might need to put a "b" behind the number to indicate the data type...

so instead of Count:5, use Count:5b
1
ToadieOdie
11/19/2015 3:32 pm
Level 54 : Grandmaster Goblin
ToadieOdie's Avatar
I tried doing that with the /testfor command, but it returns the error that the player is not found. Is the syntax different for the /testfor command?
1
Bertiecrafter
11/19/2015 3:15 pm
Level 70 : Legendary Engineer
Bertiecrafter's Avatar
in the command:
scoreboard players set @a Science 1 {Inventory:[{id:"minecraft:diamond"}]}

change
{Inventory:[{id:"minecraft:diamond"}]}
into
{Inventory:[{id:"minecraft:diamond",Count:#}]}

e.g:
{Inventory:[{id:"minecraft:diamond",Count:5}]}
1
ToadieOdie
11/19/2015 3:06 pm
Level 54 : Grandmaster Goblin
ToadieOdie's Avatar
seriouswarriorHow would one create a scoreboard objective? I've implemented the commands into the map, and I get the error message: No objective was found by the name 'Science'. All I need is a command to set one of those up, and then if everything is right, it should work, right?


Type in the chat window:

/scoreboard objectives add Science dummy Science

to add this objective. Making it a "dummy" objective means that it can only be affected by commands.The first "Science" will be be your in system name for the objective while the second "Science" is the name that is displayed in whatever lists you have it displayed in if you choose to display it at all.

My only question that I would like to add to yours is how do you get it to test to see if the player is carrying a set number of items - say 5 diamonds instead of just at least 1?
1
seriouswarrior
11/19/2015 1:02 pm
Level 39 : Artisan Fox
seriouswarrior's Avatar
SoulOfShadows23What he means by "continually target them with the selector @a[score_Science_min=1] is, when every time you place a command like a testfor or set player objective, you add the selector with it.


Ahh, okay. Just one last thing:

Jmal116Assuming you have a scoreboard objective already created . . .


How would one create a scoreboard objective? I've implemented the commands into the map, and I get the error message: No objective was found by the name 'Science'. All I need is a command to set one of those up, and then if everything is right, it should work, right?
1
SoulOfShadows23
11/19/2015 4:38 am
Level 26 : Expert Nerd
SoulOfShadows23's Avatar
What he means by "continually target them with the selector @a[score_Science_min=1] is, when every time you place a command like a testfor or set player objective, you add the selector with it.
1
seriouswarrior
11/19/2015 12:37 am
Level 39 : Artisan Fox
seriouswarrior's Avatar
Jmal116You can use NBT data to detect when a players has a diamond in their inventory.


That sounds really cool! I'm just not familiar with anything like scoreboards, so when you say:
Jmal116Just continue to target them with the selector @a[score_Science_min=1]

what would the full command for that be that I have to continually target them with?
1
Jmal116
11/18/2015 10:21 pm
Level 33 : Artisan Engineer
Jmal116's Avatar
You can use NBT data to detect when a players has a diamond in their inventory. You can use that to give them a score, and from there you can do pretty much whatever you want with them.

Assuming you have a scoreboard objective already created (I'll be calling mine 'Science', because I can), you can run commands like these:scoreboard players set @a Science 1 {Inventory:[{id:"minecraft:diamond"}]}
tp @a[score_Science_min=1] x y z

Like I said, you can do pretty much anything once you get that score on there. Just continue to target them with the selector @a[score_Science_min=1], or whatever your objective is called. You can also add extra data to search for on the item if it has a custom name or something like that, but I'm not going to worry about that right now.

The other important thing is to remember to set everyone's score to 0 after each game:scoreboard players set @a Science 0
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome