summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/PlayerChunk.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/PlayerChunk.java')
-rw-r--r--src/main/java/net/minecraft/server/PlayerChunk.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index 10a43b64..81d66e45 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -10,6 +10,7 @@ class PlayerChunk {
private short[] dirtyBlocks;
private int dirtyCount;
private int f;
+ private long g;
private boolean loaded = false; // CraftBukkit
final PlayerChunkMap playerChunkMap;
@@ -18,7 +19,6 @@ class PlayerChunk {
this.playerChunkMap = playerchunkmap;
this.b = new ArrayList();
this.dirtyBlocks = new short[64];
- this.dirtyCount = 0;
this.location = new ChunkCoordIntPair(i, j);
// CraftBukkit start
playerchunkmap.a().chunkProviderServer.getChunkAt(i, j, new Runnable() {
@@ -33,6 +33,10 @@ class PlayerChunk {
if (this.b.contains(entityplayer)) {
throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.location.x + ", " + this.location.z);
} else {
+ if (this.b.isEmpty()) {
+ this.g = PlayerChunkMap.a(this.playerChunkMap).getTime();
+ }
+
this.b.add(entityplayer);
// CraftBukkit start
@@ -52,15 +56,19 @@ class PlayerChunk {
public void b(EntityPlayer entityplayer) {
if (this.b.contains(entityplayer)) {
- entityplayer.playerConnection.sendPacket(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), true, 0));
+ Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z);
+
+ entityplayer.playerConnection.sendPacket(new Packet51MapChunk(chunk, true, 0));
this.b.remove(entityplayer);
entityplayer.chunkCoordIntPairQueue.remove(this.location);
if (this.b.isEmpty()) {
long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32;
+ this.a(chunk);
PlayerChunkMap.b(this.playerChunkMap).remove(i);
+ PlayerChunkMap.c(this.playerChunkMap).remove(this);
if (this.dirtyCount > 0) {
- PlayerChunkMap.c(this.playerChunkMap).remove(this);
+ PlayerChunkMap.d(this.playerChunkMap).remove(this);
}
this.playerChunkMap.a().chunkProviderServer.queueUnload(this.location.x, this.location.z);
@@ -68,9 +76,18 @@ class PlayerChunk {
}
}
+ public void a() {
+ this.a(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z));
+ }
+
+ private void a(Chunk chunk) {
+ chunk.q += PlayerChunkMap.a(this.playerChunkMap).getTime() - this.g;
+ this.g = PlayerChunkMap.a(this.playerChunkMap).getTime();
+ }
+
public void a(int i, int j, int k) {
if (this.dirtyCount == 0) {
- PlayerChunkMap.c(this.playerChunkMap).add(this);
+ PlayerChunkMap.d(this.playerChunkMap).add(this);
}
this.f |= 1 << (j >> 4);
@@ -97,7 +114,7 @@ class PlayerChunk {
}
}
- public void a() {
+ public void b() {
if (this.dirtyCount != 0) {
int i;
int j;
@@ -107,7 +124,7 @@ class PlayerChunk {
i = this.location.x * 16 + (this.dirtyBlocks[0] >> 12 & 15);
j = this.dirtyBlocks[0] & 255;
k = this.location.z * 16 + (this.dirtyBlocks[0] >> 8 & 15);
- this.sendAll(new Packet53BlockChange(i, j, k, PlayerChunkMap.a(this.playerChunkMap)));
+ this.sendAll(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f)); // CraftBukkit - send everything (including biome) if all sections flagged
if (PlayerChunkMap.a(this.playerChunkMap).isTileEntity(i, j, k)) {
this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(i, j, k));
}
@@ -117,7 +134,7 @@ class PlayerChunk {
if (this.dirtyCount == 64) {
i = this.location.x * 16;
j = this.location.z * 16;
- this.sendAll(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f)); // CraftBukkit - send everything (including biome) if all sections flagged
+ this.sendAll(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), false, this.f));
for (k = 0; k < 16; ++k) {
if ((this.f & 1 << k) != 0) {