-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
3216-Spigot-ff89b97-61e4ca7 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT)
-
Yes
I tried to modify the repair amount of mending using the setRepairAmount method.
But as soon i use this method e.g. setRepairAmount(1) the PlayerItemMendEvent will be called more then 500 times (which results that the item is instantly repaired).
Output: https://paste.md-5.net/ajirexulic.md
In Class A:
@EventHandler public void mending(PlayerItemMendEvent event) { System.out.println("MENDING EVENT CALLED"); }
In Class B:
@EventHandler
public void mending(PlayerItemMendEvent event) {
event.setRepairAmount(1);
}
(Two event listeners to be sure if the event will be called multiple times or if the debug message will be outputed multiple times)
There is definitely a behaviour change from 1.16 that might even lead to a stack overflow and disconnect of the player if a plugin changes the repaired amount.
How it worked before: All exp was consumed and the item in question repaired for the set repair amount.How it works now: Only the exp that is necessary for the modified repair amount is consumed and another item is tried.Actually I looked into it a bit more closely and it seems like in 1.16 it actually tried additional items too, the difference being that in 1.16 the actual amount of the experience orb entity was adjusted each time the repair process was done. In 1.17 it is now a recursive method call which doesn't modify the experience orb amount.
This means that there is no way to get the actual exp used to repair anymore in the event (previously one was able to get that from the entity in the event), imo. this could be easily solved by again updating the orb's amount like it was done before which should fix these issues as well as keep the api comatible.