Can I make an invisible block which only people with a specific item can go through?

Can I make an invisible block which only people with a specific item can go through? - A Person Buying From a Grocery

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 :)



Best Answer

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 http://minecraft.gamepedia.com/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.




Pictures about "Can I make an invisible block which only people with a specific item can go through?"

Can I make an invisible block which only people with a specific item can go through? - Person Wearing Black and White Nike Sneakers
Can I make an invisible block which only people with a specific item can go through? - Little Boy Carrying Can
Can I make an invisible block which only people with a specific item can go through? - Woman in Brown Long-sleeved Shirt Wearing Eyeglasses Holding Paint Brush



How do I make certain blocks invisible?

So what you do is place your block (I made a doorway to demonstrate) and then use the bonemeal on the grass block in the doorway (or next to your block) so a tall grass will appear on it then place the ladder in the tall grass. When you do this it creates a invisible block.

How do you make items that can only be placed on certain blocks Minecraft?

Players on Minecraft's Java Edition have a simple command that will enable them to get invisible item frames. All they need to do is open their chat console and type "/give @p item_frame{EntityTag:{Invisible:1b}}" which should place the item within the player's inventory, allowing them to place it wherever they wish.



HOW TO MAKE GHOST/INVISIBLE BLOCKS - MINECRAFT




More answers regarding can I make an invisible block which only people with a specific item can go through?

Answer 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).

Answer 3

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)

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Julia Avamotive, Marsel Hasanllari, Dazzle Jam, Andrea Piacquadio