canceling sand entity converting to block

Discussion in 'Plugin Development' started by thegunmaster, Jun 25, 2014.

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

    thegunmaster

    I am currently working on a project where i need fallingsand entities to set ontop of normal blocks but it obviously converts to a sand block. so i have tried this:

    Code:
    public void onBlockFall(EntityChangeBlockEvent e){
            if(e.getEntityType() == EntityType.FALLING_BLOCK){
                   if(e.getTo() != Material.AIR){
                        e.setCancelled(true);
                   }
            }
    }
    and e.getTo() != Material.AIR is used for detecting if the sand lands instead of when you place it.
    but this simply removes the new block that is created but doesn't stop the sand entity from deleting.
    i have tried to spawn a new sand entity on this event aswell, but it just triggers so often that i crashed. and when i give it velocity so it doesn't trigger as often it will look really ugly.
    so does anybody know how i stop the deletion of the sand entity?
     
  2. Code:java
    1. @EventHandler
    2. public void EntityChangeBlockEvent(EntityChangeBlockEvent e) {
    3. if(e.getEntityType() == EntityType.FALLING_BLOCK){
    4. if(e.getBlock().getType() == Material.AIR){
    5. e.getBlock().setType(Material.AIR);
    6. }
    7. }
    8. }

    I didnĀ“t tried it^^
     
Thread Status:
Not open for further replies.

Share This Page