3

Is there a way to disallow players to remove a certain item from a certain inventory slot. What I have tried is to add a curse of binding to the item as following:

/replaceitem entity @p slot.hotbar.8 wool 1 0 {ench:[{id:10,lvl:1}]}

But as you may know, this only works for armor slots, not other inventory slots.

2
  • Can't you just spam that replaceitem command on a repeating command block?
    – pppery
    Commented Apr 15, 2017 at 13:11
  • @ppperry Then a player can remove it and use it for other purposes. Thank you for the suggestion though. Commented Apr 15, 2017 at 17:15

1 Answer 1

2

Killing items on the ground

setup a scoreboard :

/scoreboard objective add Item dummy Item

Inside repeating active commandblocks (one that executes a command every thick) use these 3 commands:

/replaceitem entity @p slot.hotbar.8 wool 1 0 

/scoreboard players set @e[type=Item] Item 1 {Item:{id:wool,Count:1,Damage:8}}

/kill @e[type=Item,score_Item_min=1]

The first command adds the item to a specific spot on the hotbar just like you're command but without the curse.

The second assigns any wool blocks with damage value 8 to the scoreboard and the third command kills all items assigned to the scoreboard.

deleting items from unwanted inventory slots

If you want to delete the item from another slot in the hotbar use this inside first command inside a active repeating commandblock.

/testfor @a {Inventory:[{Slot:0b,id:"minecraft:wool",Damage:8}]}

then add a comparator to that commandblock running into a normal command block executing:

/replaceitem entity @p slot.hotbar.1 air 

This you will have to setup for each slot in the inventory. Note that the slot number in the testfor is 1 less than the slot in the replaceitem (and note the b after it)

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.