Get Block in Front of Entity

Discussion in 'Plugin Development' started by Elimnator, Mar 24, 2014.

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

    Elimnator

    I want to have an entity moving and any blocks in its way are set to air.
    How would I go about getting the block in front of the moving entity (like an arrow)?
     
  2. Offline

    boogy92

    What about using "getTargetBlock" on Living Entities for this?
     
  3. Offline

    Elimnator

    boogy92
    I said like an arrow, not a living entity.
     
  4. Offline

    Minnymin3

    You could calculate the direction of the arrow by getting the yaw and then add distance to the arrow's location accordingly (lets say the yaw is 5 then you could calculate that the block in front of it is +1 on, lets say, x and then set the material of the block to air).
     
  5. Offline

    Botifier

    its some
    Code:java
    1. EntityArrow a;
    2. a.getLocation().getBlock();

    thing like:
     
  6. Offline

    TwoPointDuck

    This will not be easy. You basically gotta calculate where the arrow will fly, and therefore which blocks it flies through and then replace them with air. There is no EntityMoveEvent, sorry.
     
Thread Status:
Not open for further replies.

Share This Page