[SPIGOT-5621] Custom InventoryView not respecting top inventory size Created: 18/Mar/20 Updated: 05/Apr/20 Resolved: 05/Apr/20 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Tim Blattner | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | InventoryView | ||
Environment: |
Windows 10 OpenJDK 13.0.2 2020-01-14 (build 13.0.2+8) |
Attachments: |
![]() ![]() ![]() |
Version: | git-Spigot-6de3d4b-a6f8093 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
I'm trying to create a custom InventoryView. I was able to do this back in 1.12 without issue. Unfortunately, in version 1.15.2, something is not working right. Maybe I do not understand the workflow for when things call 'player.openInventory(customInventoryView)' Anyways, I have created a simple test plugin to experiment with and demonstrate the issue. I have attached the full code. CustomInvView is the custom InventoryView. SimpleTest is the main plugin interface and implements the command.
The plugin is very simple. I have a command 'invtest' that when called it will create a new CustomInvView and have the player open that inventory. It should spawn a top inventory with 54 item slots. Instead it only opens an inventory with 27 slots. What am I missing in this version of spigot as I was not having this issue in earlier versions! And here is a screenshot showing that smaller inventory. A couple interesting points. Example of how I plan on using the CustomInvView: @EventHandler public void inventoryClick(InventoryClickEvent e) { if (e.getView() instanceof CustomInvView) { CustomInvView customInvView = (CustomInvView)e.getView(); // Do things that are specific to the custom inv } } Any ideas on why the CustomInvView does not have the requested 54 item slots? |
Comments |
Comment by md_5 [ 05/Apr/20 ] |
Fixed, but only because the PR made the code better. Implementing InventoryView is a common pitfall and has other bugs/behaviour that won't be fixed (there was a long discussion about this previously in some much older PRs) |
Comment by Tim Blattner [ 22/Mar/20 ] |
Created pull request https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/646/overview
I opted for a simpler solution as getNotchInventoryType is used in multiple other locations. |
Comment by Tim Blattner [ 20/Mar/20 ] |
Looking over CraftBukkit, CraftHumanEntity uses CraftContainer.getNotchInventoryType(type), where type is InventoryType from the InventoryView. The type returned from getNotchInventoryType does not include all of the types and defaults too Containers.GENERIC_9X3. I just submitted a request to fork craftbukkit. I'd like to include a way to also have access to the other GENERIC sizes (9X1, 9X2, 9X3, 9X4, 9X5, and 9X6). Possibly passing the size or Inventory object as a parameter to getNotchInventoryType?
The aim would also try to make it more generic and could be used in the other inventory functions, such as for the CraftHumanEntity::openInventory(Inventory inventory) function, which switches over the InventoryType. |
Comment by Tim Blattner [ 18/Mar/20 ] |
Right, in this case I specify InventoryType.CHEST, which should be allowed to have 54 slots? Or is there other components that I may need to alter to have the client use the right size? |
Comment by md_5 [ 18/Mar/20 ] |
The size is tied to the InventoryType client side |