#Remove Tag from Item Upon Pickup?
15 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Tags are defined in server loading. Maybe you'd need to look for some method to dynamically adjust EMI.
Yes, I've just realised you would still need to restart a world to see the newly discovered items
But is there a way to remove tags using itemEvents still?
I'm just a noob in coding...
No. Although you could trigger a reload command there and update the tags, I don't recommend doing that.
So there's no way to do what I want to do..? 😭
It might depend on how EMI works. I haven't read its code so I couldn't say anything certain. But if you want it desperately, there's a method.
put this in startup script
global.server_pData = null
This in server script
ServerEvents.tags('item', event => {
const pData = global.server_pData
if(!pData) return;
const toShowInEMI = pData.getCompound("toShow")
toShowInEMI.allKeys.toArray().forEach(item => event.remove('c:hidden_from_recipe_viewers', item))
})
const itemsToShowAfterPickUp = ['rediscovered:cherry_chair',]
PlayerEvents.inventoryChanged(itemsToShowAfterPickUp, event => {
const {item:{id}, server} = event
const pData = event.server.persistentData
const toShowInEMI = pData.getCompound("toShow")
const shown = toShowInEMI.allKeys.toArray().includes(id)
if(shown) return;
toShowInEMI.putBoolean(event.item.id, true)
pData.put("toShow", toShowInEMI)
global.server_pData = pData
server.reloadResources([])
})
Note that it causes server reload after player picking up the item, and thus it will have a lag
how bad the lag would be basically depends on how many mods/scripts you have
You can also do this with AStages since it allows you to hide and unhide items in EMI when obtaining the stage.
Thank you very much for providing such detailed info! I will try it out!