I'm shocked I haven't seen anything in the entire server that seems to answer how to do this. Originally I wanted to make it so if you dropped the item 'khaos:weak_soul_pickaxe' it'd vanish but dropped is broken in 1.20.1 forge, so now I'd like to destroy any copies beyond 1 being in your inventory. Problem is I have no idea how to get the players amount of 1 item type in their inventory. I tried looking for how to find the total item count of unstackable items but I found absolutely nothing in the documentation. Is there a way to do this without checking every single slot in the player's inventory?
#Only allow 1 of a certain item in inventory?
12 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
const itemToRemove = 'minecraft:diamond'
PlayerEvents.tick(event=>{
let itemCnt = event.player.inventory.countItem(itemToRemove)
for(let i = 0; i < itemCnt - 1; i++){
event.player.inventory.allItems.find(item => Ingredient.of(itemToRemove).test(item)).shrink(1)
})
It should work on both stackable and unstackable items.
Quick question, where do you even learn stuff like this-
probeJS
How do you actually see what the different things use cases are for though?
Mine lets me auto complete but it doesn't say how different events can be used