PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.74k stars 2.27k forks source link

HIDE_ATTRIBUTES doesn't hide attributes without adding a dummy attribute modifier #11224

Closed hapyl closed 1 month ago

hapyl commented 1 month ago

Expected behavior

Item with tag HIDE_ATTRIBUTES should not show attributes:

image

Observed/Actual behavior

Item with tag 'HIDE_ATTRIBUTES' shows attributes:

image

Steps/models to reproduce

final ItemStack item = new ItemStack(Material.IRON_PICKAXE);
final ItemMeta meta = item.getItemMeta();

meta.setDisplayName("Test Item");
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);

item.setItemMeta(meta);

player.getInventory().addItem(item);

Plugin and Datapack List

> plugins
[11:50:28 INFO]: Server Plugins (1):
[11:50:28 INFO]: Bukkit Plugins:
[11:50:28 INFO]:  - PaperProject
> datapack list
[11:51:11 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[11:51:11 INFO]: There are no more data packs available

Paper version

> version
[11:51:37 INFO]: Checking version, please wait...
[11:51:39 INFO]: This server is running Paper version 1.21-127-master@4e6a2a1 (2024-08-07T12:50:10Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21-81-ceeb8c1 (MC: 1.21)

Other

This works as intended on latest Spigot:

Paper will only hide default attributes if there is any modifier and the tag is set, but will not add a dummy modifier:

final ItemStack item = new ItemStack(Material.IRON_PICKAXE);
final ItemMeta meta = item.getItemMeta();

meta.setDisplayName("Test Item with dummy modifier");
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);

meta.addAttributeModifier(Attribute.GENERIC_LUCK, new AttributeModifier(
        new NamespacedKey(this, "dummy"),
        0,
        AttributeModifier.Operation.ADD_NUMBER
));

item.setItemMeta(meta);

player.getInventory().addItem(item);

image

Malfrador commented 1 month ago

Duplicate of https://github.com/PaperMC/Paper/issues/10655

This is working as intended. To hide something, something needs to be added first. Vanilla behavior since 1.20.5