How to testfor an item in a player's inventory that gets removed, and add it back?

How to testfor an item in a player's inventory that gets removed, and add it back? - Back view of unrecognizable curvy female in casual clothes writing fragile on empty side of carton box while waiting for courier

I'm building my own custom created mini-game called murder.

I have 3 teams, and I only have to setup 1 more, but I've ran into a problem; When they get an arrow and shoot it a command block with testfor activates and starts giving them every single time when they have no arrows, an arrow.

The problem is I only want them to give them 1 arrow at a time, so when they shoot that arrow, they get 1 back within 30 ticks of time , but I don't have enough experience with command blocks to do so, anyone who can help me?



Best Answer

/testfor @a[team=Arrow] {Inventory{Slot9b,id!:minecraft:arrow}

I beleve this does the trick, it tests for anything exept an arrow.




Pictures about "How to testfor an item in a player's inventory that gets removed, and add it back?"

How to testfor an item in a player's inventory that gets removed, and add it back? - Unpacked boxes in middle of room
How to testfor an item in a player's inventory that gets removed, and add it back? - Happy couple in casual clothes moving personal items in carton boxes from car trunk to new house
How to testfor an item in a player's inventory that gets removed, and add it back? - Crop man packing carton box with scotch tape dispenser



How do I get my items back after clearing inventory 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.



Minecraft Bedrock - Test For Items In Inventory (Mobile/Xbox/PS4/Windows 10/Switch)




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

Images: Ketut Subiyanto, Ketut Subiyanto, Ketut Subiyanto, Ketut Subiyanto