1.15.2 Make a recipe for... Grindstone? (if it`s posible...)

Discussion in 'Spigot Plugin Development' started by Mykola, Apr 2, 2020.

  1. Hi,
    I am beginner with API of spigot, but I just curios...
    Is there a posible way to implement a "Recipe" Interface for grindstone?

    I actualy founded on hub.spigotmc.org about GrindstoneInventory but I cant understand how to use it...

    Can somebody explain like for beginner: "Is there a way to do that?"
     
  2. And again not explicit enough,do you want to open the grindstone inventory or be able to craft it?
     
  3. What i want actualy:
    if i had an enchanted "thing"(top one) and "Book and Quill"(bottom) in grindstone i can make a random enchanted book (1 enchantment)(bottom) and disenchanted item(result box)
     
  4. I know it`s actualy would be unfair if that would be implemented, but for educational purpose... I could give it a try...
     
  5. You can't create a recipe for grindstone. All available Recipe classes can be found here.
     
  6. You should be able to achieve the same effect by using inventory events and monitoring the input slots and set the output slot accordingly.
     
  7. Can anybody explain how to allow "Material.WRITABLE_BOOK" to put in grindstone?
     
  8. You could try to set the the clicked slot to the cursor item:
    Code (Java):
    grindstone.setItem(event.getSlot(), event.getCursor());
    After doing this you will need to remove the item that the player still has on the cursor
    You have to test this properly to make sure it is not possible to dupe the item in any way
     
  9. I found how to delete item from cursor... but still, item doesnt added to grindstone slot
     
  10. Have you tried without removing it? You may need to wait a tick before removing the item from cursor
     
  11. I have this:
    Code (Java):
    if(event.getCursor()!=null) {
        if(event.getSlotType().equals(SlotType.CRAFTING)) {
            if(event.getCursor().getType().equals(Material.WRITABLE_BOOK)) {
                //event.setResult(Result.ALLOW);
                event.getInventory().setItem(event.getSlot(), event.getCursor());
                Bukkit.getServer().getPlayer(event.getWhoClicked().getName()).updateInventory();
            }
        }
    }
    But no results...
     
  12. It has something like restiction for put "WRITABLE_BOOK" inside grindstone...
     
  13. Ok... I tried this and get confused...
    Code (Java):
            @EventHandler
        public void InventoryClick(InventoryClickEvent event) {
            HumanEntity he = event.getWhoClicked();
            if(he instanceof Player) {
                Player pl = (Player)he;
                pl.sendMessage("Its player");
                Inventory inv = event.getClickedInventory();
                pl.sendMessage(inv.getType().toString());
                if(inv.getType()==InventoryType.GRINDSTONE) {
                    pl.sendMessage("Its grindstone");

    //                Location loc = inv.getLocation();
                    pl.sendMessage(""+event.getSlot());
                    inv.setItem(event.getSlot(), event.getCurrentItem());
                    pl.sendMessage(inv.getItem(event.getSlot()).toString());
                   
                }
            }
        }
    And on server i had NullPointerException on line
    Code (Text):
    pl.sendMessage(inv.getItem(event.getSlot()).toString());
    I even tried
    Code (Text):
    pl.sendMessage(event.getClickedInventory().getItem(event.getSlot()).toString());
    But inventory just like disappeared after setting item...