When using mod filters or regex in client to grab items mod items are missing but only if those scripts are present at startup client init
Yarden-zamir opened this issue ยท 1 comments
Minecraft Version
1.19.2
KubeJS Version
1902.6.2-build.39+forge
Rhino Version
1902.2.2-build.280+forge
Architectury Version
6.5.85+forge
Forge/Fabric Version
1.19.2-43.3.5
Describe your issue
As seen in this discord thread https://discord.com/channels/303440391124942858/1172814508901793812
Filters that are effected by this issue
Ingredient.of("@botania").stacks.forEach((item) => {
console.info(`${item.id} is alive at this stage!`)
})
Ingredient.of(/^botania:/).stacks.forEach(item => {
console.info(`${item.id} is alive at this stage!`)
})
Item.getList().forEach((item) => {
console.info(item);
})
[case 1] fails
When loading the game with any of the filters above are present in any client script (script in clients scripts folder) at startup, they return only minecraft items. Additionally, any time them or similar queries are done again on kjs reload command or f3+t they are still only working against minecraft items and cannot see any modded items.
BUT
[case 2] works
When loading the game without those filters, loading a world, then adding a script with those filters present, then reloading using f3+t, the modded items are present in all three types of filters, even after consecutive reloads.
logs with the following code
Ingredient.of(/^botania:/).stacks.forEach(item => {
console.info(`${item.id} is alive at this stage!`)
})
log with [case 1]
client.log
log with [case 2]
client.log
modlist present in those tests:
Botania-1.19.2-440-FORGE.jar
Patchouli-1.19.2-77.jar
architectury-6.5.85-forge.jar
curios-forge-1.19.2-5.1.4.2.jar
kubejs-forge-1902.6.2-build.39.jar
rhino-forge-1902.2.2-build.280.jar
Crash report/logs
Links provided in issue body
Client and Startup scripts load at essentially mod init, which means that the only objects (items, blocks ect) registered when they first load are vanilla ones.
Some events, like client init, also fire this early.
Because modded items aren't registered at this point, the ingredient doesn't pick them up. If you use it inside an event that fires a bit later, like the lang event, then it will work.
It is probably worth adding a check in Ingredient if it is used before item registration and log a warning if it is.