How to get data of falling blocks - VERY IMPORTANT

Discussion in 'Plugin Development' started by TGF, Dec 9, 2012.

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

    TGF

    Hi there. I have really big problem.
    I can't find the way how to get position before and after block fall.
    ==_= first position[block _]
    ====
    ==+= and after(second pos)[block +].

    At this:
    public void physics(BlockPhysicsEvent event){ [...]
    I got only data before falling.
     
  2. Offline

    fireblast709

    track them using a scheduled task? (Add if they are spawned, and if they do not longer exist it probably is the last location)
     
  3. Offline

    TGF

    I'm not good at scheduling ;/
    Can you help me a "little" more?
     
  4. Offline

    fireblast709

    Basically a scheduled task would look like: (this is a newer, improved version than the wiki, thanks to the Bukkit team)
    Code:java
    1. // Some FallingBlock entity
    2. final FallingBlock b = .. whatever, your task to get it
    3. new BukkitRunnable()
    4. {
    5. Location l = b.getLocation();
    6. @Override
    7. public void run()
    8. {
    9. if(/*b is still present*/)
    10. {
    11. l = b.getLocation();
    12. }
    13. else
    14. {
    15. // do whatever you want with the location
    16. this.cancel();
    17. }
    18. }
    19. }.runTaskTimer(<plugin instance>, long starting_delay, long delay_between_calls);
     
  5. Offline

    TGF

    I'm crap...
    I need this String:
    x, y, z, block dec, block hex..
    And i only have to get this data on falling start and when block stop falling.

    This code make me scary ;/ Do i have to place it in the PhysicEvent void?
     
  6. Offline

    fireblast709

    No, probably in the CreatureSpawnEvent (though it is highly possible that it does not get called by the FallingBlock, then you would have to loop through the entities in the world). The data for the String you can get with the instance members. (And you might want to see if the EntityBlockFormEvent works, as it would make things easier if it works)
     
  7. Offline

    TGF

    -.- It's too complicated for me. OMG :(

    But that doesn't mean i don't need Your help!!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  8. Offline

    TGF

    Bump ;/
     
  9. Offline

    Barinade

Thread Status:
Not open for further replies.

Share This Page