Falling Block Land Event?

Discussion in 'Plugin Development' started by Limeth, May 18, 2013.

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

    Limeth

    Hello, I'm working on changing sand physics, so sand collapses to sides, if there's space. I've got the code all working. It executes when a player places a sand/gravel block, but I need to find a way to execute it, when the sand/gravel block falls, to check if there's any more free space around. Any ideas?
     
  2. Offline

    GodzOfMadness

    Limeth So you're saying if i were to place a block of sand it would fall but then move to the right/left if there was space?
     
  3. Offline

    Limeth

  4. Offline

    GodzOfMadness

    Limeth Not sure if this would work at all but you could try this,
    fallingBlock.getLocation().getBlock().getRelative(BlockFace.FACE);
    And lets say if fallingBlock.getLocation().getBlock().getRelative(BlockFace.EAST).getType().equals(Material.AIR);
    then do something like change the velocities x/z to that direction.
     
  5. Offline

    Limeth

    GodzOfMadness Where am I supposed to put this code though? That's why I need the event.
     
  6. Offline

    GodzOfMadness

    EntityChangeBlockEvent checks if a block is about to fall.
    for example:
    Code:
        @EventHandler
        public void onBlockFall(EntityChangeBlockEvent event) {
            if ((event.getEntityType() == EntityType.FALLING_BLOCK)) {
                //block falling
            }
     
        }
     
Thread Status:
Not open for further replies.

Share This Page