CraftTweaker

CraftTweaker

151M Downloads

Nbt Manipulation Not Working As Intended

FeedCat02 opened this issue ยท 2 comments

commented

What happens:

You craft an unbreakable diamond sword from an unbreakable diamond sword, emerald and 5 xp levels

What you expected to happen:

You craft an breakable diamond sword from an unbreakable diamond sword, emerald and 5 xp levels

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

https://pastebin.com/syLV25vc

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

https://pastebin.com/eXmcXCAg


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12
  • Forge: forge-14.23.5.2847
  • Crafttweaker: CraftTweaker2-1.12-4.1.19.
  • Using a server: No
  • If yes, does the client have the exact same scripts?

Your most recent log file where the issue was present:

https://pastebin.com/Fpg9xXEm

commented

Okay, ignoring the chunk of your script that does absolutely nothing beyond (incorrectly) constructing a string representation of a modified NBT tag which is then discarded... the actually relevant lines appear to be 21, 22, and 24:

out.removeTag("Unbreakable");
print(out.tag);
return out;

The IItemStack documentation says that stack.removeTag(String name) should return a new IItemStack with the changed property. Can you try assigning that to a new variable, printing its tag, and returning that value? I'm not sure if it works destructively, the docs don't say it does, but if it returns "a new stack" then it probably doesn't.

commented

it definitely works by assigning it to a variable, this was unclear in the example given:
item.updateTag({Unbreakable: 1}); and doesn't seem like it should be like that but thx for the help