Problem with CraftingInventory

Discussion in 'Spigot Plugin Development' started by CraigParton, May 9, 2015.

  1. Hey everyone, I'm trying to add the ability to shift-click items into a crafting bench into my server plugin. I'm using Bukkit 1.8.3. The following code works well with one exception: If I shift-click nine stacks of iron ingots into the crafting bench, an iron block shows up in the results slot. Clicking the iron block makes it disappear without crafting it. All the shift clicked items stay in the crafting grid. If you manually pick up any item from the crafting grid and place it back, the iron block appears again and you can craft it normally. It happens the same way for any valid recipe.

    I've tried doing a lot of things to fix this. For some reason, a CraftingInventory's .getMatrix() method returns an ItemStack array with 10 entries, even though there are only 9 slots. I thought the 10th entry might be the results but it's not. It's always null even with the results slot occupied. The error only happens when my code modifies the crafting matrix. Maybe I'm just missing something. Using .setResult(ItemStack) has strange effects. The item you set won't show up in the results slot, but its there. You can pick it up, but if the recipe in the crafting grid isn't valid it will set the quantity of all the items to 0. Anyway, here's my code:


    http://pastebin.com/seSM4qrX

    Any help would be appreciated. Thanks in advance!