PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.61k stars 2.23k forks source link

Canceling archery causes the player's inventory to become out of sync #9919

Open KioProject123 opened 9 months ago

KioProject123 commented 9 months ago

Expected behavior

Cancel EntityShootBowEvent or PlayerReadyArrowEvent, the number of arrows in the player's inventory will not be reduced

Observed/Actual behavior

The number of arrows will decrease until you click on the arrow in the inventory to synchronize

Steps/models to reproduce

    @EventHandler
    public void onEntityShootBow(final @NotNull EntityShootBowEvent e) {
        e.setCancelled(true); // or e.setConsumeItem(false);
    }
    @EventHandler
    public void onPlayerReadyArrow(final @NotNull PlayerReadyArrowEvent e) {
        e.setCancelled(true);
        // It should not be necessary for plugins to use this method. If it is required for some reason, it is probably a bug.
        // e.getPlayer().updateInventory();
    }

Plugin and Datapack List

Blank

Paper version

This server is running Paper version git-Paper-280 (MC: 1.20.2) (Implementing API version 1.20.2-R0.1-SNAPSHOT) (Git: 4675152) You are running the latest version

Other

No response

Malfrador commented 9 months ago

Partly a duplicate of https://github.com/PaperMC/Paper/issues/7702, though it affecting the EntityShootBowEvent too is new.