Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

items' displayName were lost when edit nbt on 1.20+ #315

Open
JWJUN233233 opened this issue Jan 30, 2025 · 3 comments
Open

items' displayName were lost when edit nbt on 1.20+ #315

JWJUN233233 opened this issue Jan 30, 2025 · 3 comments

Comments

@JWJUN233233
Copy link

as the title said.

@tr7zw
Copy link
Owner

tr7zw commented Jan 30, 2025

You are probably either missing the 1.20.3 nbt change or mixing item meta and nbt changes.
See https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#working-with-items

@JWJUN233233
Copy link
Author

I used follow methods:
1:

NBTItem nbti = new NBTItem(item, true);
nbti.getUUID("uuid");

//then itemStack lost its name

2:

NBTItem nbti = new NBTItem(item);
nbti.setUUID("uuid", UUID.randomUUID());

nbti.applyNBT(item)
//then itemStack lost its name

@tr7zw
Copy link
Owner

tr7zw commented Jan 30, 2025

Both are deprecated and unsupported. Please use

NBT.modify(item, nbt -> {
nbt.setUUID("uuid", UUID.randomUUID());
});

and

UUID uuid = NBT.get(item, nbt -> {
return nbt.getUUID("uuid");
});

as stated in the javadoc/documentation.

If the name or uuid gets lost, you are mixing ItemMeta changes and nbt changes at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants