Solved Get anvil from InventoryClickEvent?

Discussion in 'Plugin Development' started by daviga404, Jul 15, 2013.

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

    daviga404

    Hi, I have an InventoryClickEvent to track when anvils are used. I need to get the anvil's block from what is given in the InventoryClickEvent, and I am already checking that it is an anvil. The Inventory#getHolder() method returns null, and I'm not entirely sure how else to get the block. Is there a way I can get the block, or would I need to keep track of interaction events so I can get the block from those?
     
  2. Offline

    foodyling

  3. Offline

    daviga404

  4. Offline

    xTrollxDudex

    daviga404
    I'm a bit confused but this is how I interpreted it:
    On inventory click event check if the inventory is an anvil inventory.
    Use:
    PHP:
    //inventory click event
    if(event.getInventory().getType().equals(InventoryType.ANVIL)){
    //do stuff
    }
     
  5. Offline

    daviga404

    I have already implemented the check for whether it's an anvil or not, that is not the problem. The scenario is that I want to replace the anvil with another block upon use, but I don't have a clue how to get the Anvil block to replace it in the first place.
     
  6. Offline

    xTrollxDudex

    daviga404
    PHP:
    player.getTargetBlock(null7).setType(Material.TYPE)
     
    Hellgast likes this.
  7. Offline

    daviga404

    Thanks! Didn't know that method existed :confused:
     
  8. Offline

    xTrollxDudex

Thread Status:
Not open for further replies.

Share This Page