CraftTweaker

CraftTweaker

151M Downloads

withTag and onlyWithTag not acting as expected based on Craft Tweaker 2 documentation

Dragnier opened this issue ยท 3 comments

commented

Issue Description:

.withTag and .onlyWithTag seem to be working in strange manners on recipe inputs that do not match what is stated in the documentation at: http://crafttweaker.readthedocs.io/en/latest/#Vanilla/Items/Item_Conditions/#nbt-tags_1

What happens:

I created a recipe script using .onlyWithTag and the result showed a recipe in game that stripped the tag from the item in question completely. I then changed all .onlyWithTag references to .withTag and the in game recipes showed up as expected with the proper nbt data required.

What you expected to happen:

I expected to .onlyWithTag to restrict the inputs to that specific tag rather than stripping all tag requirements. I also expected .withTag not to restrict the type of tag other than requiring that generic tag instead of being restricted to the exact tag value, similar to * for meta but with nbt.

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

https://gist.github.com/Dragnier/317ef40ad8f139c9e26f11140b20609c

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

This is a log with one recipe edited to use the .onlyWithTag version while all others use .withTag. No errors present in the log, but in game the recipe for the one using .onlyWithTag strips the tag completely from the input rather than restricting it to that input nbt specifically.

https://gist.github.com/Dragnier/e210e48d0147b658aab0b5554dbb9436


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12.2
  • Forge: 14.23.1.2581
  • Crafttweaker: 4.0.10
  • Soulus: 1.3.1-9a28759
  • Mystical Agriculture: 1.6.7

Your most recent log file where the issue was present:

https://gist.github.com/Dragnier/e210e48d0147b658aab0b5554dbb9436

commented

Are you talking about how it looked in JEI/The recipe book or on how the actual crafting recipe looks like?

OnlyWithTag is an ItemCondition. That means that it necessitates some of the ingredient's conditions.
JEI can't look at item Conditions and only sees the normal item so the JEI window would display a tagless item but if you tried to actually craft the item you would need to use the one with the essence.

You can bypass that by using both, withTag and onlyWithTag

commented

I tried using the recipes regardless of what JEI said. They didn't work as expected. (BTW, the JEI shown recipe was the one that worked even though it shouldn't have been.)

commented

Okay since I have no idea what expected means in the context of this conversation let's do this step by step, shall we?

Since I don't have the mods you have installed, I'm gonna replace the items with vanilla items, but leave everything else as it is:

recipes.addShaped(<minecraft:record_11>, [[<minecraft:wool:14>, <ore:dyeLightBlue>], [<minecraft:iron_ingot>.onlyWithTag({essence_type: "minecraft:skeleton"}), <minecraft:iron_ingot>.onlyWithTag({essence_type: "minecraft:creeper"})]]);

Let's see what JEI says:
image

Darn, it doesn't show that the item has NBT-Data stored. Let's see if crafting it exactly as in JEI will work:
image

Hm... Using normal Iron ingots doesn't work, what will? Let's use those with the same tags as provided in the only statement:
image

Wow, it suddenly works! Now Let's just fix JEI quickly, shall we?

recipes.addShaped(<minecraft:record_11>, [[<minecraft:wool:14>, <ore:dyeLightBlue>], [<minecraft:iron_ingot>.withTag({essence_type: "minecraft:skeleton"}).onlyWithTag({essence_type: "minecraft:skeleton"}), <minecraft:iron_ingot>.withTag({essence_type: "minecraft:creeper"}).onlyWithTag({essence_type: "minecraft:creeper"})]]);

What will JEI look like now?
image

Wait... why do I need to use both? Can't I just use withTag then?
Let's see... if only withTag is provided then the tag shouldn't matter in the actual recipe, should it?
image

Turns out it does. Why is that? That is because the recipe checks for an exact match in the recipes. That was changed because many people used what /ct hand gave them as Ingredients and wondered why it didn't work.

So, to answer your question:
Using .onlyWithTag limits the possible input items but does not change JEI in any way since jei can't access itemConditions.
Using .withTag changes JEI and also limits the crafting recipe since it checks for an exact match. Looks like jared changed that about a year ago. I never learn out!