Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swapping items into offhand bypasses inventory conditions #1932

Open
spannercodes opened this issue Sep 2, 2023 · 1 comment · May be fixed by #1992
Open

Swapping items into offhand bypasses inventory conditions #1932

spannercodes opened this issue Sep 2, 2023 · 1 comment · May be fixed by #1992

Comments

@spannercodes
Copy link
Contributor

spannercodes commented Sep 2, 2023

I have an inventory condition which I apply to players to prevent them from moving items in their inventory:

public static final InventoryCondition readOnlyInventoryCondition =
    (player, slot, clickType, result) -> result.setCancel(true);

This works, except items in the hotbar can be moved by being put in the offhand (using the keybind), then by moving the held slot, and swapping back.

The swap should first check against the player's inventory conditions and respect the result.

This would affect PlayerDiggingListener#swapItemHand (line 153)

A temporary workaround for anyone else with this issue is to listen for PlayerSwapItemEvent and cancel it.

EDIT: More experimentation shows this bug also applies to armour and the elytra when right-clicked.

@mworzala
Copy link
Member

Will be closed by #1992

@mworzala mworzala linked a pull request Feb 12, 2024 that will close this issue
@mworzala mworzala linked a pull request Feb 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants