Problem with creating WORKBENCH window via Bukkit.createInventory

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None

      Hi!

      I do not know if it's a bug or not, but in previous versions of spigot (1.8.8) it worked

      I'm writing a small plugin under spigot 1.12.2 that displays crafting of recipes.
      I do not like the built-in mechanics in the game (the green book in the workbench), because:
      1. The player sees recipes only of available items
      2. The player does not see the recipes of other items that were registered in the game by other plugins.

      So I decided to write my own plugin. There is no problem to find all recipes, but problems begin when the recipes window is displayed. To display the recipes, I use the "WORKBENCH" window, but I can not display objects in slots. Here is an example of how I do it:

      Inventory inventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
      InventoryView inventoryView = player.openInventory(inventory);
      inventory.setItem(1, new ItemStack(Material.LOG));
      inventory.setItem(0, new ItemStack(Material.WOOD));
      

      The client displays a workbench window, but no items has relied on the workbench slots.
      Then, if player manually puts items into the workbench slots of this window, they are put, but the result of crafting does not appear. The result of crafting only appears if player performs "Drag" action on an item (InventoryDragEvent). But if the "Drag" action is performed in the workbench slots (not in the player's inventory), then this item disappears.

      When using InventoryType.FURNACE, everything works correctly (all items put in the furnace slot are displayed in the window)

      I looked at how it works in the Essentials plugin. There the workbench is created through the function player.openWorkbench. Here is an example done by analogy with Essentials:

      InventoryView inventoryView = player.openWorkbench(null, true);
      Inventory inventory = inventoryView.getTopInventory();
      inventory.setItem(1, new ItemStack(Material.LOG));
      inventory.setItem(0, new ItemStack(Material.WOOD));
      

      This code works, but I can not use it, because if the player presses the green book and then selects any recipe, all items from the workbench slots are transferred to his inventory. Thus, the player gets the opportunity to extract items "from the air", which should not be.

      I must note that in the Essentials plugin, the "/recipe" command also allows you to receive items "from the air", as described above. Therefore, I had to turn off this command in Essentials.

      So, my questions:
      Is this a bug with InventoryType.WORKBENCH?
      How can I work around this problem?

      Thanks

            Assignee:
            Unassigned
            Reporter:
            Serj
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: