Update CraftBukkit to Minecraft 1.3.1
This commit is contained in:
committed by
Travis Watkins
parent
08e2923bd4
commit
a43d621c01
@@ -4,7 +4,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.DataFormatException;
|
||||
// import java.util.zip.Deflater; // CraftBukkit
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class Packet51MapChunk extends Packet {
|
||||
@@ -13,11 +13,13 @@ public class Packet51MapChunk extends Packet {
|
||||
public int b;
|
||||
public int c;
|
||||
public int d;
|
||||
// CraftBukkit start - private -> public
|
||||
public byte[] buffer;
|
||||
public boolean f;
|
||||
public int size; // CraftBukkit - private -> public
|
||||
private int h;
|
||||
public byte[] rawData = new byte[0]; // CraftBukkit
|
||||
public byte[] inflatedBuffer;
|
||||
public boolean e;
|
||||
public int size;
|
||||
// CraftBukkit end
|
||||
private static byte[] buildBuffer = new byte[196864];
|
||||
|
||||
public Packet51MapChunk() {
|
||||
this.lowPriority = true;
|
||||
@@ -27,124 +29,40 @@ public class Packet51MapChunk extends Packet {
|
||||
this.lowPriority = true;
|
||||
this.a = chunk.x;
|
||||
this.b = chunk.z;
|
||||
this.f = flag;
|
||||
if (flag) {
|
||||
i = '\uffff';
|
||||
chunk.seenByPlayer = true;
|
||||
}
|
||||
this.e = flag;
|
||||
ChunkMap chunkmap = a(chunk, flag, i);
|
||||
// Deflater deflater = new Deflater(-1); // CraftBukkit
|
||||
|
||||
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);
|
||||
this.d = chunkmap.c;
|
||||
this.c = chunkmap.b;
|
||||
|
||||
/* CraftBukkit start - compression moved to new thread
|
||||
try {
|
||||
deflater.setInput(abyte, 0, i1);
|
||||
this.inflatedBuffer = chunkmap.a;
|
||||
deflater.setInput(chunkmap.a, 0, chunkmap.a.length);
|
||||
deflater.finish();
|
||||
this.buffer = new byte[i1];
|
||||
this.buffer = new byte[chunkmap.a.length];
|
||||
this.size = deflater.deflate(this.buffer);
|
||||
} finally {
|
||||
deflater.end();
|
||||
} */
|
||||
this.rawData = abyte;
|
||||
}
|
||||
*/
|
||||
this.inflatedBuffer = chunkmap.a;
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOEXception
|
||||
public void a(DataInputStream datainputstream) throws IOException {
|
||||
this.a = datainputstream.readInt();
|
||||
this.b = datainputstream.readInt();
|
||||
this.f = datainputstream.readBoolean();
|
||||
this.e = datainputstream.readBoolean();
|
||||
this.c = datainputstream.readShort();
|
||||
this.d = datainputstream.readShort();
|
||||
this.size = datainputstream.readInt();
|
||||
this.h = datainputstream.readInt();
|
||||
if (rawData.length < this.size) {
|
||||
rawData = new byte[this.size];
|
||||
if (buildBuffer.length < this.size) {
|
||||
buildBuffer = new byte[this.size];
|
||||
}
|
||||
|
||||
datainputstream.readFully(rawData, 0, this.size);
|
||||
datainputstream.readFully(buildBuffer, 0, this.size);
|
||||
int i = 0;
|
||||
|
||||
int j;
|
||||
@@ -154,17 +72,17 @@ public class Packet51MapChunk extends Packet {
|
||||
}
|
||||
|
||||
j = 12288 * i;
|
||||
if (this.f) {
|
||||
if (this.e) {
|
||||
j += 256;
|
||||
}
|
||||
|
||||
this.buffer = new byte[j];
|
||||
this.inflatedBuffer = new byte[j];
|
||||
Inflater inflater = new Inflater();
|
||||
|
||||
inflater.setInput(rawData, 0, this.size);
|
||||
inflater.setInput(buildBuffer, 0, this.size);
|
||||
|
||||
try {
|
||||
inflater.inflate(this.buffer);
|
||||
inflater.inflate(this.inflatedBuffer);
|
||||
} catch (DataFormatException dataformatexception) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
} finally {
|
||||
@@ -175,11 +93,10 @@ public class Packet51MapChunk extends Packet {
|
||||
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
|
||||
dataoutputstream.writeInt(this.a);
|
||||
dataoutputstream.writeInt(this.b);
|
||||
dataoutputstream.writeBoolean(this.f);
|
||||
dataoutputstream.writeBoolean(this.e);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -190,4 +107,84 @@ public class Packet51MapChunk extends Packet {
|
||||
public int a() {
|
||||
return 17 + this.size;
|
||||
}
|
||||
|
||||
public static ChunkMap a(Chunk chunk, boolean flag, int i) {
|
||||
int j = 0;
|
||||
ChunkSection[] achunksection = chunk.i();
|
||||
int k = 0;
|
||||
ChunkMap chunkmap = new ChunkMap();
|
||||
byte[] abyte = buildBuffer;
|
||||
|
||||
if (flag) {
|
||||
chunk.seenByPlayer = true;
|
||||
}
|
||||
|
||||
int l;
|
||||
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].a()) && (i & 1 << l) != 0) {
|
||||
chunkmap.b |= 1 << l;
|
||||
if (achunksection[l].i() != null) {
|
||||
chunkmap.c |= 1 << l;
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].a()) && (i & 1 << l) != 0) {
|
||||
byte[] abyte1 = achunksection[l].g();
|
||||
|
||||
System.arraycopy(abyte1, 0, abyte, j, abyte1.length);
|
||||
j += abyte1.length;
|
||||
}
|
||||
}
|
||||
|
||||
NibbleArray nibblearray;
|
||||
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].a()) && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].j();
|
||||
System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
j += nibblearray.a.length;
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].a()) && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].k();
|
||||
System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
j += nibblearray.a.length;
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].a()) && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].l();
|
||||
System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
j += nibblearray.a.length;
|
||||
}
|
||||
}
|
||||
|
||||
if (k > 0) {
|
||||
for (l = 0; l < achunksection.length; ++l) {
|
||||
if (achunksection[l] != null && (!flag || !achunksection[l].a()) && achunksection[l].i() != null && (i & 1 << l) != 0) {
|
||||
nibblearray = achunksection[l].i();
|
||||
System.arraycopy(nibblearray.a, 0, abyte, j, nibblearray.a.length);
|
||||
j += nibblearray.a.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
byte[] abyte2 = chunk.m();
|
||||
|
||||
System.arraycopy(abyte2, 0, abyte, j, abyte2.length);
|
||||
j += abyte2.length;
|
||||
}
|
||||
|
||||
chunkmap.a = new byte[j];
|
||||
System.arraycopy(abyte, 0, chunkmap.a, 0, j);
|
||||
return chunkmap;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user