Skip to content

Tricks Hide Attribute Modifiers

Shane Bee edited this page Aug 5, 2024 · 9 revisions

As of Minecraft 1.20.5, hiding attributes with item flags no longer works for vanilla attribute modifiers.
This is caused by Mojang managing attribute modifiers 2 different ways (default modifiers are not part of the item/nbt itself)

Here are a few workarounds:

Remove Vanilla Attribute Modifiers

A simple solution is just removing the vanilla attribute modifiers from the item.

Important

Keep in mind this will remove all vanilla modifiers.
If you want to keep vanilla modifiers, see Copy/Hide Vanilla Modifiers

set {_i} to diamond sword with nbt from "{""minecraft:attribute_modifiers"":{modifiers:[],show_in_tooltip:0}}"

Apply/Hide Empty Modifier

Another solution is adding a useless modifier then hiding it.

set {_i} to diamond boots

# Apply a useless modifier to the item (since its amount is 0, it wont do anything)
apply attribute modifier to {_i}:
	id: "my_mod:scale"
	attribute: scale
	amount: 0.0
	slot: feet_slot_group
	operation: add_number
# Now hide in tooltip
add hide attributes to item flags of {_i}
give player {_i}

Copy/Hide Vanilla Modifiers

This method will copy the vanilla attribute modifiers into the item and then hide them

set {_i} to diamond boots

# Add all the vanilla modifiers to the custom modifiers of the item
loop all attribute types:
	add default loop-value modifier of {_i} to loop-value modifier of {_i}

# Then hide them
add hide attributes to item flags of {_i}
give player {_i}

Clone this wiki locally