1

Check for specific player holding specific named item in a specific set of coordinates

Dotoran's Avatar Dotoran5/31/18 9:42 am
1 emeralds 300 4
6/7/2018 3:24 pm
ShelLuser's Avatar ShelLuser
Hey guys, I had an idea for a server I'm a mod on, but can't get it to work.

Here's what I have to work with. We have an area at spawn that uses command blocks to render the area in Adventure mode, so player's can't break blocks within the area. They must travel at least 250 blocks away before being set to Survival mode. I want to create a post office/vault type system as a way for players to give other players items without them being taken by other players.

I had the idea of making a structure that had chests for each player. A player could place items into this chest that then get sucked out using hoppers beneath into another chest that the named player could come retrieve at a later date. My need is for a command block that could check when the named player comes into the post office. Here's what I'd need the command block/s to do:

1. Recognize when a specific NAMED player is standing at a specific set of coordinates.
2. Be holding a specific, named item in their inventory (this would act as the key to gain entry).

If that player is standing in the correct position, while HOLDING the named item (key), it would teleport them DOWN 3 blocks into a room only they had access to. This would give them access to the lower chest to retrieve items they were given by other players, as well as retrieving items from other chests (making it a vault system) as well.

By selecting away from the key item, a button press down here would teleport them back up to the starting position for exit from the post office.

From the reading I've done, I think this could be done with a single command block using a series of execute commands, but I've had absolutely no luck doing this. I can give examples of what I've already tried, but they've all failed miserably, so I'm asking opening for a command that DOES work, versus starting a chain of this is why your command doesn't work, etc.

Thanks in advance for any help you might be able to give.

Dave Weeks, aka Dotoran
Posted by Dotoran's Avatar
Dotoran
Level 1 : New Miner
0

Create an account or sign in to comment.

4

1
06/07/2018 3:24 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
I wouldn't chain execute commands. That only overcomplicates things which won't help you if you ever need to edit or change this. Also: it's going to be a lot of work because you'd need a setup for every single player who has a PO box.

Two command blocks should solve it...

repeating:

testfor @p[x=-195,y=56,z=100,r=1,name=ShelLuser] {Inventory:[{id:"minecraft:paper"}]}

chained, conditional and always active command block:

tp @p[name=ShelLuser] <your coords>

That should handle the teleport part. You can make the Inventory NBT setup as complex as you want it. For example by applying named items (which would match the lock on the chest).
1
05/31/2018 6:03 pm
Level 1 : New Miner
Dotoran
Dotoran's Avatar
Hey guys. Thanks for the replies. Let me reply to SUPERION first. By named player, I mean a specific player by IGN, so for example, when Dotoran is standing in a specific spot holding a specific named item, do your thing.

Garlic, let me read your response again... OK, no, what you're referring to is NOT what I am in need of. In my idea, YOU would be the ONLY person to gain entrance to the little rooms below. I don't want a method where you can share out keys to other players, as that eliminates the whole security piece at all, as anyone could be granted entrance if they had the right key. I also don't want the idea of a player entering a room where they see a gazillion chests. I want to build a nice looking structure with little cubbies, one per player, that each player would have as their own.

With my idea, the security would be superior:

1. It would have to be YOU, the specific player, Dotoran in this example.
2. You'd have to have the correct ITEM in your hand.
3. That item would have to be NAMED the correct name (using the anvil; no need for oddball characters)
4. If they chose an item with need of a data/damage tag, like a specific kind of wood block, or a specific colored wool block, etc. they'd then have a 4-level security keeping their valuables safe.

They could then make multiple keys and store them wherever they wanted to, or make one at a time, replacing them if lost. Because the test would initially be checking for the specific user, Dotoran, before continuing to check for the proper key, it wouldn't matter if someone found and stole my key, as it wouldn't work for them.

Hope that makes sense...

Dotoran
1
05/31/2018 5:11 pm
Level 31 : Artisan Engineer
garlicbreathinator
garlicbreathinator's Avatar
The command that you described would be pretty simple, but first you might want to consider some alternatives to the method you are currently trying to use. The first problem is that My recommendation is to teleport all players that walk into the post office to a room full of "PO box" chests, each one uses the "Lock" data tag linked to custom items (with weird characters and/or color codes so that you can't name an item in the anvil). Each chest requires a specific key to open, and contains a stack of it's keys in it for the player that owns it to give out to friends/teammates.

This completely eliminates the need to use commands to maintain it. If you still want to try your original method, let me know the mc version you need it for and I'll write the commands for you.
1
05/31/2018 4:25 pm
Level 29 : Expert Engineer
SUPERIONtheKnight
SUPERIONtheKnight's Avatar
I'm afraid I don't understand what you mean by a "named player", can you clarify this for me?
~SUPERIONtheKnight
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome