Lightning stick help

Discussion in 'Plugin Development' started by ItsMas_, Feb 14, 2016.

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

    ItsMas_

    I am trying to summon lightning where a player is looking using getTargetBlock with the following code:
    Code:
    p.getWorld().strikeLightning(p.getTargetBlock(null, 50).getLocation());
    I get an error on the (null, 50) part.
    Error:
    Code:
    Ambiguous method call. Both getTargetblock (HashSet<Btyte>, int) in LivingEntity and getTargetBlock (Set<Material> int) in LivingEntity match
    Any solutions? Thanks
     
  2. Offline

    teej107

    @ItsMas_ cast the null value to one of objects that the method requires in its parameters.
     
  3. Offline

    ItsMas_

    Could you give an example of this?
     
  4. Offline

    mcdorli

    You don't know how to cast? Check what it requires (I think one of it is a Set of blocks), than cast the null to that. Ambigious method means, that it doesn't know, wich one it needs to choose.
     
  5. Offline

    teej107

    Yes, but not on a Bukkit forum. Basic Java should go somewhere else.
     
  6. Offline

    DS_STORE

    (Double) 5 casts 5 (an int) into a Double. Now go to your problem.
     
  7. @ItsMas_
    I hate spoonfeeding but I'm feeling nice today.
    Code:
    e.getPlayer().getTargetBlock((Set<Material>) null, 50);
     
  8. Offline

    teej107

    I hardly call a single method/line spoonfeeding. It's just sad that there are people who won't take the time to learn the language first.
     
    Connor2weirdness likes this.
  9. @teej107
    I was, and in a way still am, one of those people. I regret my decision to learn the API first, but I got there in the end.
     
Thread Status:
Not open for further replies.

Share This Page