Getting crafting-recipe from 3x3 area in a chest

Discussion in 'Spigot Plugin Development' started by felix121felix, May 9, 2017.

  1. Is there an easy way to check wether the items from a 3x3 area in a chest equal a crafting recipe? Or do i have to check for every recipe if it equals the Items from the chest?
  2. So you want to create your own crafting table ?
  3. Decompile spigot and take a closer look at the CraftingManager. It holds a lot of recipes, but it will only give you the items in NMS format. But maybe theres also a trick in the spigot API for this.
  4. I checked it and looks like the loop through recipes too.
  5. Well, then its time for the copy n' paste army to strike again ;)
  6. Yes I want to make my own craftingtable inside a chest. I want to autocraft stuff in the chest.

    I just tried to get a workbench-inventory with >>Bukkit.createInventory(null, InventoryType.WORKBENCHCH)<< and then put in the Itemstacks from the chest. Now I try to get the Item from the result-slot which should be slot 0.
    The thing is: when I open the inventory to a Player there is the result in there, but when I try to get it by >>Inventory.getItem(0)<< I receive null.
  7. Then probably 0 isn't the correct slot.
  8. BananaPuncher714


    That's because when you create a workebnch inventory with Bukkit, it doesn't actually make a working workbench. The item that appears in the result slot is a client side ghost. I know because I tried to do this myself, and it's just a 1 row inventory that looks like a crafting grid. In order to make a working virtual ccrafting table, you'd have to rewrite most of the inventory handler code for crafting tables. I'm guessing it you try and shift click an item in your inventory then the console spams errors non stop?:p
    If you want to get the recipe, then open a workbench for the player with the player#openWorkbench() method, then when they craft something, get the result and recipie and register it.
  9. Would it be possible to make a npc and open the inventory for it? Because the player shouldn't see the inventory
    #9 felix121felix, May 11, 2017
    Last edited: May 11, 2017