#Remove Tag from Item Upon Pickup?

15 messages · Page 1 of 1 (latest)

hoary hull
#

I want to remove the 'c:hidden_from_recipe_viewers' tag (that hides stacks from EMI) from an item after it's obtained. Is there a way to do that?

I've tried:

    ServerEvents.tags('item', event => {
        event.remove('c:hidden_from_recipe_viewers', 'rediscovered:cherry_chair')
    })
})```
But it doesn't seem to work...
last daggerBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

glossy crown
hoary hull
#

But is there a way to remove tags using itemEvents still?

#

I'm just a noob in coding...

glossy crown
hoary hull
glossy crown
#

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

sharp plume
#

You can also do this with AStages since it allows you to hide and unhide items in EMI when obtaining the stage.

https://www.curseforge.com/minecraft/mc-mods/astages

CurseForge

Set custom player stages, restricting items, ores, structures, mobs, and dimensions based on progression.
4.4K Downloads | Mods

hoary hull