`IngredientJS` created during `rei.group` event has empty tag context
falxie opened this issue ยท 1 comments
Minecraft Version
1.18.2
KubeJS Version
1802.5.5-build.554
Rhino Version
1802.2.1-build.248
Architectury Version
4.10.86
Forge/Fabric Version
Forge 40.1.84
Describe your issue
I'm creating REI groups for Chipped and Additional Lanterns variations with rei.group
so that things like oak plank variations don't clutter the REI side bar. The following snippet works in single-player, but not in multiplayer.
// kubejs/client_scripts/shared.js
// Credit to https://github.com/ChloeDawn
// Modified version of snippet in latvian.dev Discord server
// https://discord.com/channels/303440391124942858/1010550815968215090/1010757873300680755
global.groupModTags = (modName, event) => {
const modIngredient = Ingredient.of(`@${modName}`)
modIngredient.stacks
.stream()
.flatMap(stack => stack.tags.stream())
.distinct() // Exclude duplicate tag entries
.filter(tag => tag.namespace === modName)
.forEach(tag => {
const { namespace, path } = tag
// Human-readable title case, e.g white_wool -> White Wool
const name = path
.slice(0)
.replace(/^(\w)/, c => c.toUpperCase())
.replace(/_(\w)/g, (_, c) => " " + c.toUpperCase())
event.groupItems(`kubejs:rei_groups/${namespace}/${path}`, name, Ingredient.of(`#${tag}`).filter(modIngredient))
})
}
// kubejs/client_scripts/chipped.js
onEvent('rei.group', event => {
global.groupModTags('chipped', event)
})
// kubejs/client_scripts/additionallanterns.js
onEvent('rei.group', event => {
global.groupModTags('additionallanterns', event)
})
rei.group
seems to be fired after connecting, but could be fired before the tags context is populated. When REI plugins are reloaded after being fully connected the tags context is still empty.