Short Delay between event and block change

Discussion in 'Plugin Development' started by Tster, Jan 5, 2014.

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

    Tster

    I'm changing the block involved in an event, but it seems to take ~1 second to do so.
    Is this something my code is doing, or do I have to update the block in some way?
     
  2. Offline

    caseif

    You haven't provided any code, mate.
     
  3. Offline

    Tster

    Last edited by a moderator: Jun 6, 2016
  4. Offline

    RawCode

    how you measured delay, i can't see any benchmark code?
     
  5. Offline

    Tster

    What?

    This video which I did on an older version about 2 years ago describes the issue:


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

    Desle

    I know what you mean, no clue how to fix it. Has nothing to do with your code.
     
  7. Offline

    Tster

  8. Offline

    bigteddy98

    Could you send us the code you are using to set the cobblestone to an ore?
     
  9. Offline

    Tster

    Don't worry - I just fixed it by cancelling the event, then doing what I wanted, and uncancelling if conditions weren't met.
    sample for those interested:
    Code:
        @EventHandler
        public void cobbleGeneration(BlockFromToEvent event) {   
            event.setCancelled(true);
            if (event.getToBlock().getType() == Material.AIR
                    && event.getToBlock().getRelative(event.getFace()).getType() == Material.STATIONARY_WATER) {
                // If the 'to' block is air after cancellation, the block behind that is
                // water, and the block was cobblestone before cancellation
                event.getToBlock().setType(chooseBlock());
                // Set the block to a random block - chosen by the chooseBlock
                // function
            } else {
                event.setCancelled(false);
            }
        }
    Oh yeah, and I think I finally got a simple way of detecting cobblestone generation!
     
  10. Offline

    bigteddy98

    Owh lol, learned something today. I had never heard of the BlockFromToEvent before :D.
     
Thread Status:
Not open for further replies.

Share This Page