KubeJS (Old)

KubeJS (Old)

3M Downloads

Script is grabbing the wrong array on launch, but works properly on reload

aaronhowser1 opened this issue ยท 8 comments

commented

Minecraft Version

1.19.2

KubeJS Version

kubejs-forge-1902.6.2-build.45

Rhino Version

rhino-forge-1902.2.2-build.280

Architectury Version

architectury-6.5.85-forge

Forge/Fabric Version

Forge 43.3.5

Describe your issue

So I have a lists.js that has the arrays customItems, jeiOnlyItems, jeiItems, and itemsToRemove.

The script emi.js makes a json file for use with the mod EMI. The json is output to the client.log for testing purposes.

image

That's definitely not right. Even aside from the fact that everything has repeating NBT and is air for some reason, all of those have the nbt hone/gild_5.

The thing is, that's in the added section of the json. That part of the json only gets things added to it via an iterator on customItems in emi.js. customItems doesn't HAVE anything with the nbt hone/gild_5 in it. jeiOnlyItems does. That array is never even LOADED by emi.js.

After doing F3+T however, it works fine! What gives?
image

Crash report/logs

No response

commented

Those consts are outside any event and it is too soon for modded items, hence why only Minecraft items shows up.
You need to load it lazily or come up with some function to load those variable just before you use them

commented

Would replacing const thing = [] with function getThing() { return [] } work?

commented

It looks like it did! Tyvm

commented

KubeJS should log a warning about getting an ingredient before all items are registered.
This is the second issue where this happened

commented

Technically isn't the NBT thing still an issue though? There's no reason it should have the gild whatever nbt in the add place since no item with that is in the list being iterated over for the add place

commented

I suspect that might be a mod mistakenly attaching nbt to empty items.

commented

That specific NBT is the NBT of one of the items in the other list, though. It's not just some arbitrary random NBT, it's a direct match

commented

Probably something being cached weirdly then. I don't think its much of an issue unless you can reproduce it in more normal circumstances.