play effect after X sec of block placing

Discussion in 'Plugin Development' started by Niv200, Aug 7, 2013.

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

    Niv200

    solved :/ had to add @Eventhandler.. idk why i forgot it :p but now i want to play effect on that block and destory it after 5 seconds of flight time.. cant figure how to do that :/ any help?
    Code:java
    1. @EventHandler
    2. public void onPlace(BlockPlaceEvent e){
    3. if(e.getBlock().getType() == Material.DRAGON_EGG){
    4. e.setCancelled(true);
    5. Player p = e.getPlayer();
    6. p.setItemInHand(null);
    7. Location loc = e.getBlock().getLocation();
    8. Block b = e.getBlock();
    9. FallingBlock ent = b.getLocation().getWorld().spawnFallingBlock(loc, Material.DRAGON_EGG,(byte) 0);
    10. ent.setFallDistance(0);
    11. ent.setVelocity(new Vector(0, 10, 0));
    12. ent.setDropItem(false);
    13.  
    14. }
    15.  
    16. }
     
  2. Offline

    TomFromCollege

    Of flight time?
    Your best bet would be to create a scheduled runnable every 5 or so ticks check that theyre still in the air, and then, after 100 of these ticks, removing the block
     
  3. Offline

    Niv200

    thx for reply :) the problem is that i dont know how to do that - everytime im trying its doesnt work! i alredy asked on that on forums... still cant do that :/ please can you explain me abit more? and yes - i saw the tutorial on the scheduled programming xD
    still dont udnerstand anything :/
     
  4. Offline

    TomFromCollege

    I don't have any code to give you as I'm typing on a Foreign keyboard (Kill me now) And I'm not at my own PC, Try and get yur first scheduler working, just something simple that outputs a message to server ever 5 ticks :) I'll help you if you're still stuck tonight, but for now; I'd rather type as little as possible :p No offence!
     
  5. Offline

    Niv200

    ok thx :) and i tried right now.. when i want to do something like ent.getLocation.playeffect.blablablabla after 5 ticks or so its isnt work! its doesnt "know" what ent means... also idk which scheduler should i pick.. :(
     
Thread Status:
Not open for further replies.

Share This Page