1.8.8 Why does it not work

Discussion in 'Spigot Plugin Development' started by Zerhusen, Oct 18, 2020.

  1. Code (Text):
    @EventHandler
        public void onPlayerCraftItem(PrepareItemCraftEvent e){
            if (e.getInventory().getMatrix().length < 9) return;
            ItemStack[] matrix = e.getInventory().getMatrix();
            if (matrix[1].getItemMeta().equals(Hackersword.hackerswordmeta)  ){
                e.getInventory().setResult(MagicWoodSword.magicwoodsword);
            }

        }
     
  2. What exactly isn't working?
     
  3. if you put a custom item (ItemStack) on the 2 slot of a workbench, you have to create a custom item called magicwooden sword.
     
  4. Why not registering a recipe?
     
  5. Try comparing just the name instead of the entire ItemMeta object
     
  6. Right, just use RecipeChoice.ExactChoice. You wont even need to use this event to make sure the items are the ones you want.
     
  7. This is not possible in 1.8.8
     
  8. Your choice not our problem.
     
  9. Unfortunately I did not work
     
  10. I just tried and it worked for me
     
  11. This did not work for me or is something wrong with the code
    Code (Java):
    @EventHandler
        public void onPlayerCraftItem(PrepareItemCraftEvent e){
            if(e.getInventory().getMatrix().length < 9)return;

            ItemStack[] matrix = e.getInventory().getMatrix();
            if (matrix[1].getItemMeta().getDisplayName().equals("┬ž2┬žlHackerschwert")  ){
                 e.getInventory().setResult(MagicWoodSword.magicwoodsword);
            }
        }
     
  12. Are you sure you set the item in the right slot? Remember than arrays start counting at 0, so index 1 (matrix[1]) returns the second slot
     
  13. The fast way is create new custom recipe , and you can craft it easily without doing this.
    Why are you making it difficult for yourself ?
     
    • Winner Winner x 1
  14. Strahan

    Benefactor

    This. Creating your own recipe would be SO much easier.
     
  15. that go not whit itemstack
     
  16. Either port back the API yourself or update to a version where it is easily makable with the present api. We do not force you to use outdated version of Minecraft and the Spigot API.
     
  17. You can very easily resolve your situation by making a custom recipe, it has to return a Material IIRC and from there you can grab the ItemStack.
     
  18. Yes I know