getTargetBlock Issue

Discussion in 'Spigot Plugin Development' started by tylerhyperHD, May 1, 2015.

  1. Hi I am having a problem with getTargetBlock, and I need some assistance. These are erroring as ambiguous.

    if (Tools.isWaterbendable(
    player.getTargetBlock(null, (int) Wave.defaultrange),
    player)) {
    new Wave(player);


    origin = player.getTargetBlock(null, (int) range).getLocation();

    Can someone help me on this? Kind of stuck on this one.
  2. There are two methods named getTargetBlock () one takes a set of bytes and the other a set of materials. The compiler cant figure out which one you are trying to use as null could be a set of bytes or materials.
  3. As @MrBlobman said, the compiler doesn't know which method you'd like to use; however, you can cast the null to a Set to force the compiler into knowing which method you're wanting to use. An example would like something like the following:
    Code (Java):
    player.getTargetBlock((Set<Material>) null, 5);