Problems with the forced generation of the world

Discussion in 'Plugin Development' started by RiseOfDeath, Sep 21, 2011.

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

    RiseOfDeath

    I have a small problem. I wanted to write a plugin that can force sgenenrirovat area of the world (saving me from having to walk most of the world that he created). However, I have a problem, and I can not understand it is my mistake or a bukkit `s bug.

    If my mistake (which I have little doubt), please explain what am I doing wrong?

    Thanks in advance.
    I was found that the bug occurs when the 52 lines from the file "generator.yava."

    2011-09-21 11:29:15 [INFO] Starting minecraft server version Beta 1.8.1
     

    Attached Files:

  2. Offline

    bergerkiller

    By far easier to do this without a command. Simply load and get all chunks you need.
    Code:
    int locationX = 20;
    int locationZ = 30;
    int chunkX = locationX >> 4;
    int chunkZ = locationZ >> 4;
    world.getChunk(chunkX, chunkZ);
    GetChunk will automatically load or generate this chunk if needed. (how else can he get a chunk?)

    Simple algoritm I used to get chunks around a player in a square pattern and set a flag on them
    Code:
        public static void handleMove(Location from, Location to) {
            if (from.getWorld() == to.getWorld()) {
                int cx = toChunk(to.getBlockX());
                int cz = toChunk(to.getBlockZ());
                if (toChunk(from.getBlockX()) == cx) {
                    if (toChunk(from.getBlockZ()) == cz) {
                        return;
                    }
                }
                //Handle it
                int radius = Bukkit.getServer().getViewDistance();
                cx -= radius;
                cz -= radius;
                radius *= 2;
                World w = to.getWorld();
                long time = System.currentTimeMillis();
                for (int a = 0; a < radius; a++) {
                    for (int b = 0; b < radius; b++) {
                        int chunkX = cx + a;
                        int chunkZ = cz + b;
                        if (w.isChunkLoaded(chunkX, chunkZ)) {
                            touch(w.getChunkAt(chunkX, chunkZ), time);
                        }
                    }
                }
            }
        }
     
  3. Offline

    RiseOfDeath

    Thank you. I'll try this method.

    upd.
    Thanks again. This method really works. (all genius is simple)
     
Thread Status:
Not open for further replies.

Share This Page