Solved Can't check if item == Material.STICK

Discussion in 'Plugin Development' started by realmdude, Dec 30, 2020.

  1. Offline


    I am trying to create a wand that creates an explosion where you look.

    Here is my code:
    public void onInteract(PlayerInteractEvent e) {
    Action action = e.getAction();{
    if (action == Action.RIGHT_CLICK_AIR)
    Player p = e.getPlayer();ItemStack item = p.getInventory().getItemInHand(); if == Material.STICK else throw return;
    p.getWorld().createExplosion(p.getLocation(), 3.0f);}

    I'm still new to this, how can I check if it's a stick then run the explosion on a right click? I only want it to explode if they're holding a stick (preferably the wand). Thanks!
  2. Offline


    What did you want to do?
  3. Offline


    I was trying to check if it was a stick, and if it wasn't, then return the code (which is supposed to rerun it, right?)
  4. Online

    timtower Administrator Administrator Moderator

    Nope, does not rerun the code.
  5. Offline


    I got it to work, thanks!

Share This Page