In Minecraft 1.9 how do I clear an item from every inventory slot except for armor?

In Minecraft 1.9 how do I clear an item from every inventory slot except for armor? - Top view of metal pendulum device placed on white table in psychiatrical clinic

I tried to figure it out and the only solution I could come up with was a command block for each slot. I'm currently making a one command where it will force armor on you but I want to make it so if you try to take it off it removes from your inventory.



Best Answer

There is no way to remove items if they are moved with the cursor, as far as I am aware, due to the fact that it doesn't have a slot id.

However clearing all other slots of a specific item and killing all dropped items is possible, using /replaceitem. This would require 36 command blocks to clear items from every slot in the inventory apart from armor, 37 if you include offhand.

Inventory

/replaceitem entity @a slot.inventory.# minecraft:air

Replace # with a number from 0 to 26, with 0 being top-left slot and 26 being bottom right slot of the inventory. This does not include the hotbar

Hotbar

/replaceitem entity @a slot.hotbar.# minecraft:air

Replace # with a number from 0 to 8, 0 being far left hotbar slot, 8 being far right. This does not include offhand

Offhand

/replaceitem entity @a slot.weapon.offhand minecraft:air


To clear the entire inventory, use /clear <player>


I know its a late answer, but this will work. It may cause a bit of lag. You will not be able to use any other items, unless you find a way of specifying what item to replace. I have tested /clear for its maxCount parameter, but it specifies the maximum amount to be cleared, not the maximum items left.

Good luck!




Pictures about "In Minecraft 1.9 how do I clear an item from every inventory slot except for armor?"

In Minecraft 1.9 how do I clear an item from every inventory slot except for armor? - Blackboard surrounded with cones and pebbles
In Minecraft 1.9 how do I clear an item from every inventory slot except for armor? - Unrecognizable black man washing windshield in daytime
In Minecraft 1.9 how do I clear an item from every inventory slot except for armor? - Interior of modern kitchen in office



How do you delete specific items in Minecraft?

The kill command or \u201c/kill @e[type=item]\u201d can remove all the dropped items in the Minecraft world instantly. You'll need operator status and cheats to be enabled to use the kill command. If you want to clear all the dropped items within a specific radius, use the \u201c/kill @e[type=item, r=x]\u201d command.

What is the command to clear chunks in Minecraft?

You can use the /replaceitem command to instanty replace one item with another item. You can replace armor items worn, weapons held in your hands, items stored in chests and items in your inventory/hotbar. This is a great way to quickly put armor on a player during a Minecraft battle or change out a worn out weapon.



DETECT ANY ARMOR IN MINECRAFT | ANY ARMOR SET | DETECT ITEM IN INVENTORY (Minecraft Command Blocks)




More answers regarding in Minecraft 1.9 how do I clear an item from every inventory slot except for armor?

Answer 2

Maybe this will work: have 4 repeat, always active command blocks, each and every one having a /testfor command testing for all four armor pieces in your inventory, and then, right in front of those, conditional, chain, always active command blocks, that then remove the armor pieces.

Answer 3

Alternatively, you might be able to enchant the armor with the "Curse of Binding" making it impossible to remove in the first place.

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

Images: Skylar Kang, Brett Sayles, José Roberto Orpinelli Junior, Max Vakhtbovych