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 creative mode item list filtering #223

Merged
merged 1 commit into from
Dec 26, 2022

Conversation

MelnCat
Copy link
Contributor

@MelnCat MelnCat commented Dec 26, 2022

Currently when container items are filtered in creative mode, the code responsible for filtering the contents of container items while in creative will unintentionally delete vanilla items from the container. This can be reproduced by going into survival, filling up a bundle with 1 vanilla item and 1 nova item, then going into creative and checking the item while in creative.
This is caused by the following code:

            } else if (fromCreative) {
                if (isFakeItem(contentItem)) // Don't collapse if statement to prevent isNovaItem call
                    getNovaItem(contentItem).save(compound)
            } 

If fromCreative is set and isFakeItem is false (i.e. the item is a vanilla item), nothing will be saved to the compound tag, and the item will be written as {}. This causes the vanilla items to disappear.
This pull request solves it by collapsing the if statement into

            } else if (fromCreative && isFakeItem(contentItem)) {
                getNovaItem(contentItem).save(compound)
            }

The comment states that collapsing the if statement will cause an isNovaItem call, but having the nova packet item be sent to a creative client will not cause the item on the server to be written as the client-side item due to the creative set-slot packet having its item changed to the real server-side item.

@NichtStudioCode NichtStudioCode merged commit 6cec170 into xenondevs:main Dec 26, 2022
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 this pull request may close these issues.

2 participants