Changing many blocks at once crashes client

Discussion in 'Plugin Development' started by Netizen, Mar 1, 2013.

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


    Hey all,

    I was wondering if anybody has had experience with changing a lot of blocks all at once (aka world edit style) and having any minecraft clients in the area crash. The server seems to do the right thing, since relogging back into the server shows the expected results.

    It used to happen only occasionally but has progressively gotten worse. I never experience these problems using worldedit, so I must be doing something wrong.

    Typically I'm doing something like this:
    /* SimpleBlock structure contains type id, data, and a relative x,y,z. */
    public void build (Location center, ArrayList<SimpleBlock> blocks) {
        for (SimpleBlock sb : blocks) {
            Block b = center.getRelative(sb.getX(), sb.getY(), sb.getZ());
            b.setTypeAndData(sb.getType(), sb.getData());
    This code is running in a synchronous task and typically causes my client to crash when doing more than about 200-300 blocks at once.

  2. Offline


    This typically can't be avoided, though it does seem unusual considering you're changing a relatively small number of blocks. It may help to run it in an asynchronous task, rather than a synchronous one.
  3. Offline


    Naw. I can't run this in an async thread without crashing the server. (I've tried =P). Bukkit/Minecraft is not thread safe so anything that touches things in MC has to be run in a sync thread.

    After a bit of searching, by chance I found this thread:

    Where desht mentions that in building from a schematic:
    I was unaware that setTypeIdAndData was firing off lighting changes and other calculations. This might be the problem. He's written a handy API to do this here: which has a setBlockFast() function. I'll give that a try and see if it fixes my issues.
  4. Quick TIP if it doesn't fix it.
    You could also try to set a timer and change some blocks every x milliseconds, so you give your computer a bit longer to process all the changes. (I haven't tested it though)
Thread Status:
Not open for further replies.

Share This Page