The following code causes the bug.
@EventHandler public void onPlayerEat(PlayerItemConsumeEvent e) { if (e.getItem().getType() == Material.GOLDEN_APPLE && e.getItem().getData().getData() == (byte) 1) { Player plr = e.getPlayer(); ItemStack is = e.getItem().clone(); is.setAmount(1); // ItemStack is = new ItemStack(Material.GOLDEN_APPLE); // is.setDurability((short)1); plr.getInventory().addItem(is); plr.updateInventory(); } }
If you eat a god apple this code gives the player a replacement God apple. If you do this with one apple in your hotbar, upon replacement the amount in the bar shows that you have TWO apples. Dropping the item and picking it up, or clicking on it in your inventory instantly updates the amount to the correct number so it is purely a visual bug.
Likewise if you create a new item stack and set the data the same issue arises. If you have 17 apples and eat one, after the code executes it shows that you have 18 apples, picking up the apples or dropping them fixes the number back to 17.
Oddly enough if you eat 1 gapple then eat a second the issue does not repeat itself, it stays at the +1 number until you mess with the item in your inventory.
The code commented was another method I tried which produces the same result.
- duplicates
-
SPIGOT-2869 Summary
- Closed