You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am testing player click behaviour and noticed, that the clicked slot in a WorkbenchInventoryMock does not behave as expected. I am trying to verify the result of the crafting table by checking index 0 in the contents of the inventory. In the current implementation the item at the underlying index from the array is returned. Now the array is filled only by the matrix, the result slot is ignored and instead has its own field in the class.
I know that the test itself is easily fixable by just casting it to CraftingInventory and then accessing the result. However, I am using the CraftingInventory in parameterized tests and I would prefer all inventories behaving similar.
A potential fix could be by overriding Inventory#getItem in WorkbenchInventoryMock and checking if the index is 0. If so, then return the result variable. If not, then return the ItemStack from the underlying array at index-1.
The text was updated successfully, but these errors were encountered:
I could try to implement this behaviour along with support for the SlotType enum to add more functionality to the simulateInventoryClick methods. Potentially in the structure of #972 ?
I could try to implement this behaviour along with support for the SlotType enum to add more functionality to the simulateInventoryClick methods. Potentially in the structure of #972 ?
I failed to notice this issue (we should have an alert on issus opening in our discord). Anyhow, yes it's probably better to follow the same structure of #972 , but I would think that you should make the pull request to the 3.0 branch (not for 4.0)
Is there an existing issue for this?
Are you using the latest version of MockBukkit?
Minecraft Version
1.20
Describe the bug
I am testing player click behaviour and noticed, that the clicked slot in a WorkbenchInventoryMock does not behave as expected. I am trying to verify the result of the crafting table by checking index 0 in the contents of the inventory. In the current implementation the item at the underlying index from the array is returned. Now the array is filled only by the matrix, the result slot is ignored and instead has its own field in the class.
Reproducible Test
Anything else?
I know that the test itself is easily fixable by just casting it to CraftingInventory and then accessing the result. However, I am using the CraftingInventory in parameterized tests and I would prefer all inventories behaving similar.
A potential fix could be by overriding
Inventory#getItem
inWorkbenchInventoryMock
and checking if the index is 0. If so, then return the result variable. If not, then return the ItemStack from the underlying array at index-1.The text was updated successfully, but these errors were encountered: