mojira.dev
MC-233336

2 tick delay between applying attribute modifiers to items and the modifier actually taking effect

As title.

There is a 2 gt delay between applying attribute modifiers to items and the attribute modifiers actually taking effect.
Modifiers applied by command /attribute are not affected.

The attachment is a datapack including some functions to verify the bug.

Steps to reproduce

  1. install the datapack and reload

  2. run /function test:direct/modify_attribute to see values queried by /attribute with modifiers applied by /attribute

  3. run /function test:item/modify_attribute to see values queried by /attribute with modifiers applied on item by /item and item modifier file

Note

  • all selectors in the datapack are @p in order to simplify the code

  • modifier is automatically removed after 3 gt

Linked issues

Attachments

Comments 3

Can confirm.

(In fact it is only one tick delay because it is already applied before the second schedule.)

This bug is because the modifiers on an item is detected and applied only when the player entity is ticked (detectEquipmentUpdates() in LivingEntity.tick()). So there's a delay.

To fix this bug, update modifiers immediately when an item slot is changed, rather than when entity ticking.

Can confirm: 1.19.4 rc1

Yui

(Unassigned)

Community Consensus

Platform

Data Packs, Player

1.17.1, 1.19.4 Release Candidate 1, 1.21

Retrieved