Block#breakNaturally getting stuck.

Discussion in 'Spigot Plugin Development' started by Roboroads, Jun 28, 2016.

Thread Status:
Not open for further replies.
  1. Hi. I'm trying to break blocks naturally after some time has passed. I have an arraylist of Block objects but when I call breakNaturally on it, it does not pop the block, nor continuing the code (seems like an infinite loop), nor getting a stacktrace. It does not freeze the main thread because i put this on a different thread.

    This is what i do (heartSides contains 6 blocks):
    Code (Text):

    ArrayList<Block> heartSides = this.getHeartSides();
    for(Block heartSide : heartSides) {
        heartSide.breakNaturally();
    }
     
    When i do this:

    Code (Text):

    ArrayList<Block> heartSides = this.getHeartSides();
    for(Block heartSide : heartSides) {
        System.out.println("DEBUG 1");
        heartSide.breakNaturally();
        System.out.println("DEBUG 2");
    }
     
    I only get "DEBUG 1" in my console.

    Does anyone know what i'm doing wrong?
     
  2. MiniDigger

    Supporter

    don't access the bukkit api from a different thread
     
  3. Okay.. but, how to break blocks then from that thread? It's a timed action.
     
  4. MiniDigger

    Supporter

    sync back to the main thread using the bukkit sheduler. you only can access bukkit api methods from the main thread because bukkit (and the underlying minecraft server) are not thread save.
     
  5. Alright, thanks. That explains a lot!
     
Thread Status:
Not open for further replies.