Skip to content

Conversation

@APickledWalrus
Copy link
Member

@APickledWalrus APickledWalrus commented Jul 1, 2025

Problem

Attempting to add items to inventories could result in some slots being deleted (set to air). With Player inventories, leggings/boots were cleared.

Solution

Currently, we grab the inventory contents (not just storage contents either) as an array and attempt to modify ItemStacks to add in the ItemStack(s) represented by the ItemType. However, inventories may have differing implementations for how ItemStacks should be added. I have updated the method to instead use the Inventory API methods to add ItemStacks, which correctly accounts for existing slots, maximum stack sizes, etc. I have also corrected the getStorageContents() method.

Unfortunately, on older versions (1.20.6 specifically), the API methods for adding items to inventories due not work properly with large quantities.... For older versions (those below 1.21), I have elected to preserve the existing method. There have been no reported issues with adding items to inventories on those versions.

Testing Completed

I tested in-game before/after and confirmed the issue is resolved.

Supporting Information


Completes: #7975
Related: none

@APickledWalrus APickledWalrus requested review from a team and sovdeeth as code owners July 1, 2025 03:29
@APickledWalrus APickledWalrus added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Jul 1, 2025
@APickledWalrus APickledWalrus requested review from Efnilite and removed request for a team July 1, 2025 03:29
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Jul 1, 2025
@APickledWalrus APickledWalrus linked an issue Jul 1, 2025 that may be closed by this pull request
1 task
The API methods are bugged on those versions...
@skriptlang-automation skriptlang-automation bot added feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. and removed needs reviews A PR that needs additional reviews labels Jul 1, 2025
@github-project-automation github-project-automation bot moved this from In Review to Awaiting Merge in 2.12 Releases Jul 1, 2025
@APickledWalrus APickledWalrus merged commit 07a0b34 into SkriptLang:dev/feature Jul 1, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done in 2.12 Releases Jul 1, 2025
@APickledWalrus APickledWalrus deleted the patch/adding-items branch July 1, 2025 14:40
@skriptlang-automation skriptlang-automation bot added completed The issue has been fully resolved and the change will be in the next Skript update. and removed feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. labels Jul 1, 2025
Burbulinis pushed a commit to Burbulinis/Skript that referenced this pull request Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update.

Projects

Status: Done - Released

Development

Successfully merging this pull request may close these issues.

Giving items to the player on Paper 1.21.6 wipes their leggings and boots

4 participants