3

I am making an adventure map and because the new update buttons can be placed on top of and beneath blocks, I am having issues. This is a problem because I only give pressure plates and redstone when it is needed for a certain door.

If they have a button and need a pressure plate to open the door, players need to search elsewhere, but because they can put a button where a pressure plate would be, they bypass everything. Is there a way to use a command block to prevent players from placing a button on the floor?

3

First, place 4 repeating command blocks and two levers as shown:

Two sets of two command blocks, with each set powered by a lever

Next, type the following commands into each command block as numbered (replacing x1 y1 z1 and x2 y2 x2 with the co-ordinates of the two corners of your map):

1: /fill x1 y1 z1 x2 y2 x2 minecraft:air 0 replace minecraft:stone_button 5
2: /fill x1 y1 z1 x2 y2 x2 minecraft:air 0 replace minecraft:stone_button 0
3: /fill x1 y1 z1 x2 y2 x2 minecraft:air 0 replace minecraft:wooden_button 5
4: /fill x1 y1 z1 x2 y2 x2 minecraft:air 0 replace minecraft:wooden_button 0

These commands, when activated, will instantly replace any buttons in the specified area with the specified rotation with air.

To prevent buttons from being placed on top of blocks, turn on lever A. To prevent buttons from being placed underneath blocks, turn on lever B.

Demonstration (note that the buttons on top and on the bottom of the blocks are replaced, but not the ones on the sides):

Blocks instantly being replaced

  • Also a good option – BRHSM Apr 29 '17 at 7:45
2

You can set the player in adventure mode and allow the button to be placed on only certain blocks like:

give @p minecraft:stone_button  1 0 {CanPlaceOn:["minecraft:grass","minecraft:dirt"]}

Of course you can change the blocks the button can be placed on. Just make sure they can't be place on the blocks that surround the door.

For example if you want the door to be able to open with a button you can place a gold block next to it and allow buttons to be placed on them. If you don't want the player to be able to open the door with a gold block you can surround the door with iron blocks.

The command would then be:

give @p minecraft:stone_button  1 0 {CanPlaceOn:["minecraft:gold_block"]}

This will give the player a stone button which can only be placed on gold blocks

If you want to do the same for pressure plates you could use this command:

give @p minecraft:stone_pressure_plate  1 0 {CanPlaceOn:["minecraft:diamond_block"]}

This will give the player a pressure plate which can only be placed on diamond blocks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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