Sponge icon indicating copy to clipboard operation
Sponge copied to clipboard

[1.12.2 / v7.4] MainPlayerInventory#getSlot is broken

Open qixils opened this issue 3 years ago • 0 comments

I am currently running

  • SpongeForge version: N/A
  • SpongeVanilla version: 1.12.2-7.4.7
  • Java version: 1.8.0_313/32-bit (Temurin)
  • Operating System: Windows 10 (10.0/x86)
  • Plugins/Mods: Just my test plugin 🙂

Issue Description

The methods #getSlot(int x, int y) and #getSlot(SlotPos pos) both seem to be broken on the MainPlayerInventory class (may or may not apply to other classes and/or API versions; haven't tested beyond the code attached below).

When parameter y equals 0, the method works as expected-- a filled optional is returned for x in [0,8], corresponding with the player's hotbar, otherwise it returns an empty optional.

However, things break down for the rest of the inventory. The entire rest of the inventory (the 3 rows besides the hotbar) have all been lumped into y=1, i.e. #getSlot(9, 1) returns what should be returned by #getSlot(0, 2). An empty optional is always returned for y=2 and y=3, and an exception is thrown(!) for x=27 through x=38 when y=1.

Example code and detailed logs (which may or may not be easier to understand than the above text): https://gist.github.com/qixils/7817ffb40110b883aa5ae12a170aac26

qixils avatar Jan 11 '22 03:01 qixils