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

Fix unconstrained code for PlayerInvDisplay menu updating #704

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BenCheung0422
Copy link
Member

Fixes #703
This greatly demonstrated an example of what could happen when low level programming bugged in high level language. If it is C/C++, just undefined bahaviour instead of an exception or error.

This should be a bug since 2.2.0-dev1 (29f6ff8). I believe it was because the code was copied directly from ContainerDisplay without further examination and modification. It should be a ArrayIndexOutOfBoundsException but since 2.2.0-dev4 (33c5083), a description menu has been added, so the 1st menu become the description menu when not in creative mode and thus not the requested InventoryMenu (ClassCastException), causing the exception.

The part of code is executed when a stack of item is updated when in menu or inventory is updated when items moved between player inventory and list of item (only in creative mode). Only the action of dropping item updating item stacks is available for non-creative mode, other than the deletion of items in creative mode. The logic is errored and an exception is thrown only when in non-creative mode. Since 2.2.0-dev1, ArrayIndexOutOfBoundsException will be thrown while since 2.2.0-dev4, ClassCastException will be thrown, on the same line of code.

@BenCheung0422 BenCheung0422 added Bug Something that shouldn't happen. Code Quality Issue related to code quality/coding standard. UI/Menus Issue related to (G)UI or menus/displays. labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something that shouldn't happen. Code Quality Issue related to code quality/coding standard. UI/Menus Issue related to (G)UI or menus/displays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Game crashes when dropping an item in menu
1 participant