Prevent Falling Block From Turning Into Block?

Discussion in 'Plugin Development' started by TrollTaylor, Apr 9, 2014.

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

    TrollTaylor

    How would i prevent a falling block from turning into a normal block and then set its velocity?
     
  2. Offline

    Shadow_Parallax

    Listen for the BlockChangeEvent event and cancel it. You can set the velocity by getting the entity using event.getEntity() and then using setVelocity(x,y,z) although I'm not entirely sure if the BlockChangeEvent has an entity field.

    EDIT: Example
    Code:java
    1. @EventHandler
    2. public void onBlockChange(BlockChangeEvent event){
    3. event.getEntity().setVelocity(0, 5, 0);
    4. event.setCancelled(true);
    5. }
     
  3. Offline

    TrollTaylor

    Shadow_Parallax Whenever the block spawns and when it hits the floor it disappears.
     
  4. Offline

    Shadow_Parallax

    TrollTaylor You can respawn the entity and set the velocity then? Kind of roundabout way I think, tough.
     
  5. Offline

    Xenira

    @TrollTaylor Try to make a custom FallingBlock entity.
    This might help you. If you need more help I can search my code for an example ;)

    MfG Xenira
     
  6. Offline

    Shadow_Parallax

    Xenira Why did you quote me? :p
     
  7. Offline

    Xenira

    Ups wrong one ^^
     
    Shadow_Parallax likes this.
  8. Offline

    Garris0n

    EntityChangeBlockEvent.

    1. Check if entity is a fallingblock.
    2. If necessary, check if it's a falling block you want to stop.
    3. Check if the block (not falling block entity, actual block) is air or something else.
    4. If it's air, cancel the event. If it's something else, the event is being called because of a block falling instead of landing and you shouldn't cancel it.
    5. Cancel it.
     
Thread Status:
Not open for further replies.

Share This Page