Item not being added to inventory from custom anvil recipe

Discussion in 'Plugin Development' started by voltywolty, Feb 13, 2024.

  1. Offline

    voltywolty

    Do custom anvil recipes not allow the user to get an item from the result slot or am I doing it wrong. I'm using it like a crafting way. I'm thinking I'm going to have to code it to where it adds it to the inventory after clicking on the result.
    Code:
    @EventHandler
        private void onAnvilPrepare(PrepareAnvilEvent event) {
            AnvilInventory anvilInventory = event.getInventory();
    
            ItemStack slot1 = anvilInventory.getItem(0);
            ItemStack slot2 = anvilInventory.getItem(1);
    
            event.getInventory().setMaximumRepairCost(0);
    
            if (slot1 != null && slot2 != null) {
                if (swordRecipe(slot1, slot2)) {
                    if (sword != null)
                        event.setResult(sword);
                }
            }
        }
     
  2. Online

    timtower Administrator Administrator Moderator

    @deborah621 We don't do mods here, we make plugins.
    And the plugin AnvilAPI is from 2011
     

Share This Page