CraftTweaker

CraftTweaker

151M Downloads

[1.12.2] JEI.addItem() doesn't work

democat3457 opened this issue ยท 10 comments

commented

Intro:

Using JEI and CT in a modpack, JEI.addItem() didn't work, so I decided to try it out on a bare-minimum install. #889 could be related; if so, is this an issue for the JEI repo instead?

Issue Description:

When using JEI.addItem() in a CT script, the item does not show up in JEI, no matter if the item has enchantments, a different name, or other nbt data. Also, potentially unrelated, JEI.removeAndHide(IOreDictEntry) doesn't seem to work? (Should I make a separate issue for it?)

What happens:

JEI doesn't add any of the items with or without NBT, nor does it remove any planks.

What you expected to happen:

JEI should add the specified items.

Script used (Please Pastebin or gist your script, posting an unpasted or ungist'd script will automatically close this issue):

https://pastebin.com/YMkvVtv9

crafttweaker.log file (Please Pastebin or gist your file, posting an unpasted or ungist'd file will automatically close this issue):

https://pastebin.com/CM4EZdq1


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12.2
  • Forge: 14.23.5.2847
  • Crafttweaker: 1.12-4.1.20.577
  • Using a server: No
  • If yes, does the client have the exact same scripts? N/A

Your most recent log file where the issue was present:

debug.log

commented

Commented on JEI Issue mezz/JustEnoughItems#2053

commented

That is the one from the client as far as I know - it was a singleplayer world.

commented

@democat3457 do you have a debug.log from the client? I believe the one posted here is from a server because JEI is not logging anything there.

commented

The issue here is with how item subtypes are implemented in JEI.
By default, JEI treats items with NBT differences as being the same item. This is because most NBT differences do not actually have an effect in crafting, and it lets players look up items more easily.

Mods that add items with NBT differences that are significant in crafting need to tell JEI about it. This is done by registering a "subtype interpreter" to JEI that tells JEI how to tell subtypes of an item apart. For vanilla's JEI plugin, I add subtype interpreters for potions, books, tipped arrows, banners, and eggs.

CraftTweaker command to hide diamonds hides the diamond and you see no diamonds at all.
Then when you add a diamond item with NBT, JEI looks it up and finds it matches the regular diamond (because there is no "subtype interpreter" added for diamonds). Because it found a match, JEI treats the "add" as "un-hide" and so it shows the regular diamond again, and your subtype with NBT is never added.

commented

So for all of the items that have an NBT tag that are added, JEI finds a match with the original and adds the original item regardless of whether it was added before? I'm pretty sure the diamond chestplate remained hidden even though I added it back with NBT, but that could be because it has no recipes...? Also, the removal of the planks oredict didn't seem to work, since all of the planks were still there. Does the boolean option for removeAndHide actually do anything, as the description for that was unclear?

commented

That boolean is for the removal of the recipe, nothing about hiding the item in JEI

commented

That boolean is for the removal of the recipe, nothing about hiding the item in JEI

Gotcha, the CrT docs just say "NBT-Match" with no further explanation.

commented

I'll try this out in my dev environment using the script you provided.

commented

Hmm you're right, I guess the mod log lines are not getting written to file for some reason.

commented

As said here: mezz/JustEnoughItems#2053 (comment)

This won't be getting fixed