Paper
Paper copied to clipboard
Itemstack Glint API
Closes #5274
First time touching item meta stuff
Unsure of a few things, mainly the behavior of this elsewhere in the codebase, like anvils/grindstones. Currently you can remove the glint with the grindstone (and get no xp), and you can put enchanted books on the item, BUT that removes the empty NBTTagCompound, so removing that enchant will make the item lose it's glint.
Issue relating to this: #5723
Not sure how I feel about this because all this seems like is a helper method for adding enchantments while making it seem like an inherent property an ItemStack can have.
Also, has this been tested with items that already have enchantments on them?
I didn’t specifically test that JRoy, but the result would be an Enchantments nbt list with a normal tagcompound and an empty one. I don’t see how that would behave differently from a list with just an empty one
Won't that still show up on the item? I dont know how the client determines what shows up or not if its missing an equivalent on the client side.
You can easily create "invisible" enchantments, even with API (with no hide tag required).
Aside from Bukkit, the most basic format a client accepts perfectly fine is something along the lines of this (just some Via code stuffed somewhere to get the gist of it):
// Add dummy enchant for the glow effect if there are no actual enchantments left
if (!storedEnchant && enchantments.size() == 0) {
CompoundTag dummyEnchantment = new CompoundTag();
dummyEnchantment.put("id", new StringTag()); // String value empty = ""
dummyEnchantment.put("lvl", new ShortTag((short) 0));
enchantments.add(dummyEnchantment);
}
Curious, how does normal items have the enchantment glint without any enchantments such as the golden apple?
Pretty sure those are hardcoded by on the client.
(yarn mappings)
(yarn mappings)
Yes, exactly, I don’t think that is ever passed between the client and server, hence, hardcoded.
Can we just ask Mojang for an NBT flag it seems super easy.
I've dropped that suggestion in a place where we often speak to mojang devs, will see if they have any comments on this as the general handling of this always feels a bit icky, so I'd love to avoid having to do something like this as supported API
@electronicboy Do you have any news on it ?
In general, this can prolly be closed? Hopefully waiting on mojang for this, but with my item property API these types of items will work just fine in the future due to no item meta processing being done.
Closing in favor of the item property api.
in 1.20.5, we will be getting components, and one is override_enchantment_glint