[SPIGOT-6708] setRepairAmount of the PlayerItemMendEvent is broken ? Created: 13/Aug/21 Updated: 03/Sep/21 Resolved: 03/Sep/21 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | False | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | bug |
Version: | 3216-Spigot-ff89b97-61e4ca7 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
I tried to modify the repair amount of mending using the setRepairAmount method. 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) |
Comments |
Comment by Phoenix616 [ 01/Sep/21 ] |
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.
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. |
Comment by False [ 14/Aug/21 ] |
As workarount i use setCancelled(true) but i have to repair the item mayself then. Also the experience orb had 6 experience in my case, so if i set the repairamount to 1 the event should be called 6 times with your argumentation. But it was called over 500 times ;o |
Comment by md_5 [ 14/Aug/21 ] |
I don't think it's broken. |