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.

  • Can't you just spam that replaceitem command on a repeating command block? – pppery Apr 15 '17 at 13:11
  • @ppperry Then a player can remove it and use it for other purposes. Thank you for the suggestion though. – Jacques Marais Apr 15 '17 at 17:15
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)

| improve this answer | |

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.