2

I am currently making a server, and I want to make an invisible block in which only people with a specific item can go through(in this case, a nametag called:key). Is there a command to do so? I am making a server, so plugins will do fine too :)

3
  • Would a teleporter that teleports people with the key in and out work? Commented Oct 15, 2015 at 22:22
  • 2
    Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!
    – Frank
    Commented Oct 15, 2015 at 22:40
  • @Studoku yes that would work Commented Oct 15, 2015 at 22:51

3 Answers 3

2

Best way I can think of is teleporting the player backwards if they don't have the key and are in the blocked off area. So you'd use an invisible armor stand to mark the places these "blocks" would be. Then create a scoreboard objective that indicates if the player has the key. Every tick of a fill clock (or, in the 1.9 snapshots, of a repeating command block), you'd reset everyone's score to 0, then set the score to 1 for players who have the correct item in their inventory, as checked by their Inventory data tag (see https://minecraft.wiki/w/Player.dat_format#NBT_structure for more information about the format of the Inventory tag). Then you execute on each of your "invisible block" armor stands to /tp every player in radius 0 with a score of 0 back a block or two.

2

How about you make a system that warns the player without the item required (using testfor and stuff) that they can't go through and tp them back if they get in the wanted area of yours.(sr for my english).

2
  • 1
    On a Q&A site, it isn't helpful at all if you provide your skype name to help the OP. People might come across that problem / question at some time later, searching for a solution and get to this website. If you're able to provide a solution via skype, why don't you do that right here?
    – Marco
    Commented Nov 3, 2015 at 18:43
  • Good point. Sorry for that. Commented Nov 4, 2015 at 11:11
1

If you were to use a command like so:

/testfor @p[r=2] {Inventory:[{tag:{display:{Name:"key"}}}]}

This will testfor if they have the item somewhere in there inventory

Then if you testfor the item in there inventory, and it activates true, have a sticky piston push a redstone block that changes there gamemode to spectator. Which will allow them to go through the wall: (Here you could use a barrier as your invisible block.)

/gamemode 3 @p

If they leave the radius of 2 then the /testfor command will read false which will deactivate the sticky piston, pulling the redstone block back to activate another command block with the command

/gamemode 2 @p

Or the gamemode you want. It should look like this.enter image description here

If you would like to test for the item in a certain slot in there inventory then you could use a command like this:

/testfor @p[r=2] {SelectedItemSlot:0,Inventory:[{Slot:0b,­tag:{display:{Name:"key"}}}]}

This will test for the "key" in there first slot of there inventory where they hold items.

/give (name) minecraft:barrier (for the invisible wall)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.