diff options
author | Raphfrk <raphfrk@gmail.com> | 2011-03-02 20:27:44 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-03-07 12:34:27 +0000 |
commit | 03a5bbc6127c86e3c71c9ea293663681d1c6ba40 (patch) | |
tree | aabbf72736de79c7bce148e7d26259cb5ad4a63f /src | |
parent | 528b9b2e09ecf534383ea8bb6d2d42c6dabef4c5 (diff) | |
download | craftbukkit-03a5bbc6127c86e3c71c9ea293663681d1c6ba40.tar craftbukkit-03a5bbc6127c86e3c71c9ea293663681d1c6ba40.tar.gz craftbukkit-03a5bbc6127c86e3c71c9ea293663681d1c6ba40.tar.lz craftbukkit-03a5bbc6127c86e3c71c9ea293663681d1c6ba40.tar.xz craftbukkit-03a5bbc6127c86e3c71c9ea293663681d1c6ba40.zip |
Regenerate and refresh chunk methods
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/ChunkProviderServer.java | 4 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 82 |
2 files changed, 66 insertions, 20 deletions
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index 86f3d60b..a7932c3b 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -21,8 +21,8 @@ import org.bukkit.event.world.ChunkUnloadEvent; public class ChunkProviderServer implements IChunkProvider { public LongHashset a = new LongHashset(); // CraftBukkit - private Chunk b; - private IChunkProvider c; + public Chunk b; // CraftBukkit + public IChunkProvider c; // CraftBukkit private IChunkLoader d; public LongHashtable<Chunk> e = new LongHashtable<Chunk>(); // CraftBukkit public List f = new ArrayList(); // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 9781c48b..18cbe19f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -149,6 +149,48 @@ public class CraftWorld implements World { return true; } + public boolean regenerateChunk(int x, int z) { + unloadChunk(x, z, false, false); + + provider.a.remove(x, z); + + net.minecraft.server.Chunk chunk = null; + + if(provider.c == null) { + chunk = provider.b; + } else { + chunk = provider.c.b(x, z); + } + + chunkLoadPostProcess(chunk, x, z); + + refreshChunk(x, z); + + return chunk != null; + } + + public boolean refreshChunk(int x, int z) { + if(!isChunkLoaded(x, z)) { + return false; + } + + int px = x<<4; + int pz = z<<4; + + // If there are more than 10 updates to a chunk at once, it carries out the update as a cuboid + // This flags 16 blocks in a line along the bottom for update and then flags a block at the opposite corner at the top + // The cuboid that contains these 17 blocks covers the entire chunk + // The server will compress the chunk and send it to all clients + + for(int xx = px; xx < (px + 16); xx++) { + world.g(xx, 0, pz); + } + world.g(px, 127, pz+15); + + return true; + } + + public boolean isChunkInUse(int x, int z) { Player[] players = server.getOnlinePlayers(); @@ -180,31 +222,35 @@ public class CraftWorld implements World { if (chunk == null) { chunk = provider.e(x, z); - if (chunk != null) { - provider.e.put(x, z, chunk); - provider.f.add(chunk); + chunkLoadPostProcess(chunk, x, z); + } + return chunk != null; + } - chunk.c(); - chunk.d(); + private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int x, int z) { + if (chunk != null) { + provider.e.put(x, z, chunk); + provider.f.add(chunk); - if (!chunk.n && provider.a(x + 1, z + 1) && provider.a(x, z + 1) && provider.a(x + 1, z)) { - provider.a(provider, x, z); - } + chunk.c(); + chunk.d(); - if (provider.a(x - 1, z) && !provider.b(x - 1, z).n && provider.a(x - 1, z + 1) && provider.a(x, z + 1) && provider.a(x - 1, z)) { - provider.a(provider, x - 1, z); - } + if (!chunk.n && provider.a(x + 1, z + 1) && provider.a(x, z + 1) && provider.a(x + 1, z)) { + provider.a(provider, x, z); + } - if (provider.a(x, z - 1) && !provider.b(x, z - 1).n && provider.a(x + 1, z - 1) && provider.a(x, z - 1) && provider.a(x + 1, z)) { - provider.a(provider, x, z - 1); - } + if (provider.a(x - 1, z) && !provider.b(x - 1, z).n && provider.a(x - 1, z + 1) && provider.a(x, z + 1) && provider.a(x - 1, z)) { + provider.a(provider, x - 1, z); + } - if (provider.a(x - 1, z - 1) && !provider.b(x - 1, z - 1).n && provider.a(x - 1, z - 1) && provider.a(x, z - 1) && provider.a(x - 1, z)) { - provider.a(provider, x - 1, z - 1); - } + if (provider.a(x, z - 1) && !provider.b(x, z - 1).n && provider.a(x + 1, z - 1) && provider.a(x, z - 1) && provider.a(x + 1, z)) { + provider.a(provider, x, z - 1); + } + + if (provider.a(x - 1, z - 1) && !provider.b(x - 1, z - 1).n && provider.a(x - 1, z - 1) && provider.a(x, z - 1) && provider.a(x - 1, z)) { + provider.a(provider, x - 1, z - 1); } } - return chunk != null; } public boolean isChunkLoaded(Chunk chunk) { |