Solved Removing a FallingBlock

Discussion in 'Plugin Development' started by killerzz1, Aug 31, 2015.

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

    killerzz1

    Hello, so I am wanting to spawn a falling block and then 10 seconds after it is spawned i want to remove it.

    here is the code for the falling block. Could someone help me remove the block after 10 seconds

    Code:
        Vector v = new Vector();
                    v.setY(1);
                   
                   
                       
                    final FallingBlock block = e.getPlayer().getWorld().spawnFallingBlock(e.getPlayer().getLocation(), Material.GOLD_BLOCK, (byte) 0);
    
                    block.setVelocity(p.getLocation().getDirection().multiply(1.5D).setY(1));
     
  2. Offline

    Oxyorum

    @killerzz1 Perhaps you can have a sync task run after 10 seconds which deletes the block? Just pass the block to the task. Someone tell me if I'm wrong.
     
  3. Offline

    crolemol

    add this add the end,
    Code:
                        new BukkitRunnable(){
    
                            @Override
                            public void run() {
                                block.remove();
                            }
                        }.runTaskLater(YOURPLUGIN,200L);
     
  4. Offline

    killerzz1

    @crolemol I done that and it did not work but let me try again i will update you if it does :D

    yae I just tried your code and it did't work

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Aug 31, 2015
  5. Offline

    Oxyorum

    @crolemol @killerzz1 Looked at the javadocs and there is no remove() method for the block class. I'm pretty sure you just have to set the Material of the relevant block to air instead.
     
  6. Offline

    killerzz1


    Yea I just done that lol i got it to work now thanks guys for you're help :p
     
  7. Offline

    crolemol

    @killerzz1 @Oxyorum
    that will not remove the entity but just make it invisible, i just looked it up and there is a entity.remove() method.
     
  8. Offline

    Oxyorum

    @crolemol That is the same method you guys were using that didn't work. I'm not sure it's properly implemented in the FallingBlock class. Someone that is more knowledgeable is free to correct me. :)
     
  9. Offline

    crolemol

    @Oxyorum i'm very sure it works because i used it like 2 hours ago in my plugin so it's a bug from the original poster
     
  10. Offline

    Oxyorum

    @crolemol Ah. Cool then. :)
     
Thread Status:
Not open for further replies.

Share This Page