Is there any kind of code or script (for example in KubeJS or similar modding tools) that allows items in a player’s inventory to disappear under certain conditions?
For example, when the player finds their corpse, reaches specific coordinates, or triggers some other condition.
Basically, I’m looking for a way to make items get removed from the inventory based on custom events or location-based triggers.
#item disapier
6 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
locations might be a bit hard, but there are events that trigger when a player clicks a block/item
there are a lot of examples on the discord as well, you will probably be able to find a lot of usefull clues by looking through #1048591172165189632 , #1047320998199955458 and #1254790121807548437
here is a chunk of code I have that could work? It always removes a certain item from the inventory instantly. You could likely add other checks in here too to make it conditional
ServerEvents.tick(event => {
event.server.players.forEach(player => {
player.inventory.allItems.forEach(item => {
if(item.id == 'easy_villagers:villager'){
let nbt = item.nbt?.villager
if(nbt){
player.runCommandSilent(`summon minecraft:villager ~ ~ ~ ${nbt}`)
}
item.count--
}
})
})
})