How do I clear 2 items from my inventory, with one being a specific name?

How do I clear 2 items from my inventory, with one being a specific name? - Top view of metal pendulum device placed on white table in psychiatrical clinic

I am working on my VANILLA Minecraft server right now and I'm in a bit of a struggle. A player can purchase an iron sword called SLAYER Sword, and can also purchase a regular iron sword. A player can also sell an iron sword at a price of 3 Scoreboard Units. I want ONLY the regular iron sword to be sold, not the SLAYER Sword. The text I am currently using to sell a single sword is /clear @p minecraft:iron_sword -1 1. This is currently clearing BOTH swords, not just the regular iron sword.



Best Answer

I figured it out: make the regular iron sword-giver have a custom name of Iron Sword, which can be done by adding {display:{Name:"Iron Sword"}}. In the seller, make it clear the sword by adding the same display name.




Pictures about "How do I clear 2 items from my inventory, with one being a specific name?"

How do I clear 2 items from my inventory, with one being a specific name? - Blackboard surrounded with cones and pebbles
How do I clear 2 items from my inventory, with one being a specific name? - Mock up business cards on board with cotton
How do I clear 2 items from my inventory, with one being a specific name? - Hands of crop faceless man under water



How do you delete specific items from inventory?

You can clear items from a player's inventory using the /clear command in Minecraft.

How do you delete named items?

Ways to easily clear inventory in Minecraft If players don't need any items and simply want to remove them from their inventory quickly, they can simply press the drop button ('Q' is the default button on PC) while having the mouse cursor on the item to drop on the ground.

How do you quickly remove items from your inventory in Minecraft?

Firstly, press the T key on your keyboard to open the chat. Yet, you can change this hotkey in the game settings. One of the most popular and fastest ways to clear items is the kill command. First, type /kill @e[type=item] in the chat and press enter to remove all dropped items in your Minecraft world instantly.



Using Commands in Minecraft: /clear and Custom Item Names! | 1.11.2




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, Monstera, Mariana Montrazi