Get crafting result

Discussion in 'Plugin Development' started by MineTheCube, Sep 17, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    MineTheCube

    Hi,

    I need a way to get the material of a crafting result, and if possibly the amount. I thought there were an event for this, but.. no.

    However there is the CraftItemEvent (which extends InventoryClickEvent), but it is fired even if no craft is done, for instance clicking on the result with items under cursor trigger the event:
    [​IMG]

    Any workaround for this ?
     
  2. Offline

    i3ick

    Hmm here is an idea:

    You could save the inv to an object when it's opened, and then listen for a click event and see if the item is contained in the object. That way you could determine if the item is new (i.e. crafted) or just some item from the inventory.

    Downsides:
    Doesn't work if the you are crafting a duplicate of an object you already posses.
    Not sure but i believe it is very memory intensive.

    Still maybe it helps
     
  3. Offline

    mine-care

    When a click fires, check if the item was picked up from the results slot or not (after click check if the slot is empty) and boom you got it. Notice, this is in theory, haven't tried but by reading the docs you will find the alapropriate methods :)
     
  4. Offline

    i3ick

    @mine-care
    That wouldn't work. If nothing was crafted and the player just picked up some item from the inventory this code would assume what you're holding was crafted.
     
    mine-care likes this.
  5. Offline

    mine-care

    @i3ick Εrr you can check for the clicked slot, if it is the crafting table result slot in the clicked inventory (i think it is 9 but im not sure, you can find that out :)) and if it is the click and the item on the cursor is not null it means that someone picked up the result.
     
    i3ick likes this.
Thread Status:
Not open for further replies.

Share This Page