a replacement for getTargetBlock

Discussion in 'Plugin Development' started by fokolo, Sep 21, 2013.

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

    fokolo

    getTargetBlock was deprecated due to magic value i searched in the docs and i couldnt find any does this mean i need to make a function on my own? and if so based on what?

    thanks a lot
     
  2. Offline

    Knux14

    Same problem :(
     
  3. Offline

    fokolo

    i hate the deprecated list.. its so annoying so much good commands and functions :(
     
  4. fokolo Knux14
    I'm not sure if there is a better way to do this, but I modified some code of mine.
    Code:java
    1. public Block getTargetBlock(Player player, int range) {
    2. Location loc = player.getEyeLocation();
    3. Vector dir = loc.getDirection().normalize();
    4.  
    5. Block b = null;
    6.  
    7. for (int i = 0; i <= range; i++) {
    8. b = loc.add(dir).getBlock();
    9. }
    10.  
    11. return b;
    12. }
     
  5. Offline

    Knux14

    Ok thanks, I'll try it
     
  6. deprecated methods can still be used, and is just telling us that we should not use them as they will soon be removed, I suggest you use the deprecated method and wait for bukkit to make a new one for Materials.
     
  7. Offline

    Garris0n

  8. Offline

    Knux14

    It works for me too, and his function doesnt
     
Thread Status:
Not open for further replies.

Share This Page