summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/Packet51MapChunk.java
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2012-03-01 10:49:23 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2012-03-01 14:38:31 +0000
commit543c4879fee3b7165764c5371d226c93fe3a657b (patch)
tree4fe9116464e1fe42a40dc3ba19b58234bd26f821 /src/main/java/net/minecraft/server/Packet51MapChunk.java
parente9ca87000c1794715bc3fe0a7d1caaf809057635 (diff)
downloadcraftbukkit-543c4879fee3b7165764c5371d226c93fe3a657b.tar
craftbukkit-543c4879fee3b7165764c5371d226c93fe3a657b.tar.gz
craftbukkit-543c4879fee3b7165764c5371d226c93fe3a657b.tar.lz
craftbukkit-543c4879fee3b7165764c5371d226c93fe3a657b.tar.xz
craftbukkit-543c4879fee3b7165764c5371d226c93fe3a657b.zip
Updated CraftBukkit to 1.2
Diffstat (limited to 'src/main/java/net/minecraft/server/Packet51MapChunk.java')
-rw-r--r--src/main/java/net/minecraft/server/Packet51MapChunk.java158
1 files changed, 126 insertions, 32 deletions
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
index 3acdba76..08c1df81 100644
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
@@ -13,61 +13,155 @@ public class Packet51MapChunk extends Packet {
public int b;
public int c;
public int d;
- public int e;
- public int f;
public byte[] buffer;
+ public boolean f;
public int size; // CraftBukkit - private -> public
- public byte[] rawData; // CraftBukkit
+ private int h;
+ public byte[] rawData = new byte[0]; // CraftBukkit
public Packet51MapChunk() {
this.lowPriority = true;
}
// CraftBukkit start
- public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, World world) {
- this(i, j, k, l, i1, j1, world.getMultiChunkData(i, j, k, l, i1, j1));
- }
-
- public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, byte[] data) {
- // CraftBukkit end
+ public Packet51MapChunk(Chunk chunk, boolean flag, int i) {
this.lowPriority = true;
- this.a = i;
- this.b = j;
- this.c = k;
- this.d = l;
- this.e = i1;
- this.f = j1;
+ this.a = chunk.x;
+ this.b = chunk.z;
+ this.f = flag;
+ if (flag) {
+ i = '\uffff';
+ }
+
+ ChunkSection[] achunksection = chunk.h();
+ int j = 0;
+ int k = 0;
+
+ int l;
+
+ for (l = 0; l < achunksection.length; ++l) {
+ if (achunksection[l] != null && (!flag || !achunksection[l].a()) && (i & 1 << l) != 0) {
+ this.c |= 1 << l;
+ ++j;
+ if (achunksection[l].h() != null) {
+ this.d |= 1 << l;
+ ++k;
+ }
+ }
+ }
+
+ l = 2048 * (5 * j + k);
+ if (flag) {
+ l += 256;
+ }
+
+ if (rawData.length < l) {
+ rawData = new byte[l];
+ }
+
+ byte[] abyte = rawData;
+ int i1 = 0;
+
+ int j1;
+
+ for (j1 = 0; j1 < achunksection.length; ++j1) {
+ if (achunksection[j1] != null && (!flag || !achunksection[j1].a()) && (i & 1 << j1) != 0) {
+ byte[] abyte1 = achunksection[j1].g();
+
+ System.arraycopy(abyte1, 0, abyte, i1, abyte1.length);
+ i1 += abyte1.length;
+ }
+ }
+
+ NibbleArray nibblearray;
+
+ for (j1 = 0; j1 < achunksection.length; ++j1) {
+ if (achunksection[j1] != null && (!flag || !achunksection[j1].a()) && (i & 1 << j1) != 0) {
+ nibblearray = achunksection[j1].i();
+ System.arraycopy(nibblearray.a, 0, abyte, i1, nibblearray.a.length);
+ i1 += nibblearray.a.length;
+ }
+ }
+
+ for (j1 = 0; j1 < achunksection.length; ++j1) {
+ if (achunksection[j1] != null && (!flag || !achunksection[j1].a()) && (i & 1 << j1) != 0) {
+ nibblearray = achunksection[j1].j();
+ System.arraycopy(nibblearray.a, 0, abyte, i1, nibblearray.a.length);
+ i1 += nibblearray.a.length;
+ }
+ }
+
+ for (j1 = 0; j1 < achunksection.length; ++j1) {
+ if (achunksection[j1] != null && (!flag || !achunksection[j1].a()) && (i & 1 << j1) != 0) {
+ nibblearray = achunksection[j1].k();
+ System.arraycopy(nibblearray.a, 0, abyte, i1, nibblearray.a.length);
+ i1 += nibblearray.a.length;
+ }
+ }
+
+ if (k > 0) {
+ for (j1 = 0; j1 < achunksection.length; ++j1) {
+ if (achunksection[j1] != null && (!flag || !achunksection[j1].a()) && achunksection[j1].h() != null && (i & 1 << j1) != 0) {
+ nibblearray = achunksection[j1].h();
+ System.arraycopy(nibblearray.a, 0, abyte, i1, nibblearray.a.length);
+ i1 += nibblearray.a.length;
+ }
+ }
+ }
+
+ if (flag) {
+ byte[] abyte2 = chunk.l();
+
+ System.arraycopy(abyte2, 0, abyte, i1, abyte2.length);
+ i1 += abyte2.length;
+ }
+
/* CraftBukkit start - Moved compression into its own method.
byte[] abyte = data; // CraftBukkit - uses data from above constructor
Deflater deflater = new Deflater(-1);
try {
- deflater.setInput(abyte);
+ deflater.setInput(abyte, 0, i1);
deflater.finish();
- this.buffer = new byte[l * i1 * j1 * 5 / 2];
+ this.buffer = new byte[i1];
this.size = deflater.deflate(this.buffer);
} finally {
deflater.end();
} */
- this.rawData = data;
+ this.rawData = abyte;
// CraftBukkit end
}
public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOEXception
this.a = datainputstream.readInt();
- this.b = datainputstream.readShort();
- this.c = datainputstream.readInt();
- this.d = datainputstream.read() + 1;
- this.e = datainputstream.read() + 1;
- this.f = datainputstream.read() + 1;
+ this.b = datainputstream.readInt();
+ this.f = datainputstream.readBoolean();
+ this.c = datainputstream.readShort();
+ this.d = datainputstream.readShort();
this.size = datainputstream.readInt();
- byte[] abyte = new byte[this.size];
+ this.h = datainputstream.readInt();
+ if (rawData.length < this.size) {
+ rawData = new byte[this.size];
+ }
+
+ datainputstream.readFully(rawData, 0, this.size);
+ int i = 0;
+
+ int j;
+
+ for (j = 0; j < 16; ++j) {
+ i += this.c >> j & 1;
+ }
+
+ j = 12288 * i;
+ if (this.f) {
+ j += 256;
+ }
- datainputstream.readFully(abyte);
- this.buffer = new byte[this.d * this.e * this.f * 5 / 2];
+ this.buffer = new byte[j];
Inflater inflater = new Inflater();
- inflater.setInput(abyte);
+ inflater.setInput(rawData, 0, this.size);
try {
inflater.inflate(this.buffer);
@@ -80,12 +174,12 @@ public class Packet51MapChunk extends Packet {
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
dataoutputstream.writeInt(this.a);
- dataoutputstream.writeShort(this.b);
- dataoutputstream.writeInt(this.c);
- dataoutputstream.write(this.d - 1);
- dataoutputstream.write(this.e - 1);
- dataoutputstream.write(this.f - 1);
+ dataoutputstream.writeInt(this.b);
+ dataoutputstream.writeBoolean(this.f);
+ dataoutputstream.writeShort((short) (this.c & '\uffff'));
+ dataoutputstream.writeShort((short) (this.d & '\uffff'));
dataoutputstream.writeInt(this.size);
+ dataoutputstream.writeInt(this.h);
dataoutputstream.write(this.buffer, 0, this.size);
}