Problem With Getting Block

Discussion in 'Plugin Development' started by TheHandfish, May 8, 2014.

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

    TheHandfish

    I'm trying to get the block in front of the player, and if it's a PISTON_MOVING_PIECE and he's going the right way, send a message, and if he's going the wrong way, kill him.

    Code:Javascript
    1. Material mat1 = p.getVehicle().getLocation().add(2,0,0).getBlock().getRelative(BlockFace.EAST).getType();
    2. Material mat2 = p.getVehicle().getLocation().add(-2,0,0).getBlock().getRelative(BlockFace.WEST).getType();
    3. Material mat3 = p.getVehicle().getLocation().add(0, 0, 2).getBlock().getRelative(BlockFace.SOUTH).getType();
    4. Material mat4 = p.getVehicle().getLocation().add(0, 0, -2).getBlock().getRelative(BlockFace.NORTH).getType();
    5.  
    6. if(mat1 == Material.PISTON_MOVING_PIECE && mat2 == Material.PISTON_MOVING_PIECE && mat3 == Material.PISTON_MOVING_PIECE && mat4 == Material.PISTON_MOVING_PIECE && p.getLocation().getYaw() < 90 && p.getLocation().getYaw() > -90)
    7. {
    8. p.sendMessage("§aDebug: Near raceline.");
    9. }
    10. else if(mat1 == Material.PISTON_MOVING_PIECE && mat2 == Material.PISTON_MOVING_PIECE && mat3 == Material.PISTON_MOVING_PIECE && mat4 == Material.PISTON_MOVING_PIECE)
    11. {
    12. p.setHealth(0.0);
    13. }


    I'm not getting any results, though. So how do I accomplish this?
     
  2. Ouch!

    Anyway, you'll want to add in more debug to see what code is and isn't reached.
     
    TheHandfish likes this.
  3. Offline

    TheHandfish

    AdamQpzm: Honestly, I'd rather just start fresh with it. ._. I don't know what to use, which is the problem.
     
  4. Offline

    TheHandfish

  5. Offline

    TheHandfish

    Bump. >_>

    Bump. .-.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  6. Offline

    22vortex22

    Hey, No need to bump so much. Anyways if I read correctly nothing is happening? Are you registering your events using EventHandler? If so what event are you using. Are any of the debug messages showing. I just need to have some mroe information to help.
     
  7. Offline

    TheHandfish

    22vortex22: (I'm bumping every 12 hours [I think])


    As I said there, I'd like to just start from scratch.
     
  8. Offline

    22vortex22

    Oh, okay sorry I couldn't help then.
     
Thread Status:
Not open for further replies.

Share This Page