Skip to content

Fix crafter slot ID conversions#13497

Merged
Warriorrrr merged 1 commit intoPaperMC:mainfrom
joshuaprince:fix/crafter-slot-ids
Feb 26, 2026
Merged

Fix crafter slot ID conversions#13497
Warriorrrr merged 1 commit intoPaperMC:mainfrom
joshuaprince:fix/crafter-slot-ids

Conversation

@joshuaprince
Copy link
Copy Markdown
Contributor

@joshuaprince joshuaprince commented Jan 4, 2026

Fixes #12864

The networked raw slot IDs for crafter inventory views are mapped a bit differently compared to any other inventory views. This is how raw slots are laid out in crafting tables compared to crafters:

Crafting table raw:               Crafter raw:
       1  2  3                          0  1  2
       4  5  6     0                    3  4  5     45
       7  8  9                          6  7  8
 10 11 12 13 14 15 16 17 18       9  10 11 12 13 14 15 16 17
 19 20 21 22 23 24 25 26 27       18 19 20 21 22 23 24 25 26
 28 29 30 31 32 33 34 35 36       27 28 29 30 31 32 33 34 35
 37 38 39 40 41 42 43 44 45       36 37 38 39 40 41 42 43 44

Paper currently handles the conversion from raw IDs to slot IDs incorrectly for crafters, as described in #12864. There is no handling for InventoryType.CRAFTER in the logic for converting raw slot IDs. The result is that these calls return incorrectly when a player clicks while viewing a crafter:

  • InventoryClickEvent#getSlot()
  • InventoryClickEvent#getClickedInventory()
  • InventoryClickEvent#getSlotType()

I generated a table outlining all of these return values before and after this patch at this gist.

A note on my selection of converted slot IDs: the crafter's use of resolved slot IDs 0-8 in the grid and 9 for the result are inconsistent with workbenches and inventory crafting, which use slot 0 for the result and 1-9/1-4 in the grid. Unfortunately, 0-8 and 9 match the vanilla assignment of crafter slot IDs, and therefore the ID mapping used in Inventory#setItem(int, ItemStack) and commands like /execute if items block ~ ~1 ~ container.0. An alternative mapping here could make crafters and workbenches number slots consistently, but it would make other behavior inconsistent.

@joshuaprince joshuaprince requested a review from a team as a code owner January 4, 2026 06:59
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Jan 4, 2026
@joshuaprince joshuaprince changed the title Fix crafter and workbench slot ID conversions Fix crafter slot ID conversions Jan 4, 2026
@joshuaprince
Copy link
Copy Markdown
Contributor Author

I pulled the workbench fix out of this PR since I found that the bug applies to a few other inventory views too, so best to keep that in a separate review later.

@Warriorrrr Warriorrrr added type: bug Something doesn't work as it was intended to. scope: api labels Feb 15, 2026
@Warriorrrr Warriorrrr merged commit 32dff6b into PaperMC:main Feb 26, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Awaiting review to Merged in Paper PR Queue Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api type: bug Something doesn't work as it was intended to.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

CraftAbstractInventoryView returns wrong Slot number in Crafter views

3 participants