Solved When a Falling Block Lands

Discussion in 'Plugin Development' started by xWatermelon, Jun 20, 2013.

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

    xWatermelon

    I am trying to make it so the falling block will appear to break when it lands. This is what I have so far:
    Code:java
    1. @EventHandler
    2. public void onFallingBlockLand(EntityChangeBlockEvent event){
    3. if(event.getEntity() instanceof FallingBlock){
    4. FallingBlock fallingBlock = (FallingBlock) event.getEntity();
    5.  
    6. Bukkit.broadcastMessage("Fired.");
    7. }

    However, I am getting the "Fired" message whenever I place a sand or gravel block and it starts to fall. Does anybody know the proper way to get when a falling block lands?
     
  2. Offline

    Garris0n

    That's the correct way to do it, but I'm not positive on getting whether the block is falling or landing. Try checking the block type and seeing when the event is fired. If it's air when you place it then it's fired after the change, otherwise it's before the change. Then you can check using whether the block is air regardless.
     
    xWatermelon likes this.
  3. Offline

    xWatermelon

    Solved:
    Code:java
    1. @EventHandler
    2. public void onFallingBlockLand(final EntityChangeBlockEvent event){
    3. if(event.getEntity() instanceof FallingBlock){
    4. FallingBlock fallingBlock = (FallingBlock) event.getEntity();
    5.  
    6. if(event.getBlock().getType() == Material.AIR){
    7. new BukkitRunnable(){
    8. @Override
    9. public void run(){
    10. //Do something
    11. }
    12. }.runTaskLater(<plugin instance>, 1L);
    13. }
    14. }
    15. }
     
Thread Status:
Not open for further replies.

Share This Page