2011-05-21 21:27:34 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.zip.DataFormatException;
|
|
|
|
import java.util.zip.Deflater;
|
|
|
|
import java.util.zip.Inflater;
|
|
|
|
|
|
|
|
public class Packet51MapChunk extends Packet {
|
|
|
|
|
|
|
|
public int a;
|
|
|
|
public int b;
|
|
|
|
public int c;
|
|
|
|
public int d;
|
|
|
|
public int e;
|
|
|
|
public int f;
|
2012-01-12 16:27:39 +01:00
|
|
|
public byte[] buffer;
|
|
|
|
public int size; // CraftBukkit - private -> public
|
2011-07-26 18:03:52 +02:00
|
|
|
public byte[] rawData; // CraftBukkit
|
2011-05-21 21:27:34 +02:00
|
|
|
|
|
|
|
public Packet51MapChunk() {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.lowPriority = true;
|
2011-05-21 21:27:34 +02:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
// CraftBukkit start
|
2011-05-21 21:27:34 +02:00
|
|
|
public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, World world) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this(i, j, k, l, i1, j1, world.getMultiChunkData(i, j, k, l, i1, j1));
|
2011-05-21 21:27:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, byte[] data) {
|
2011-06-27 00:25:01 +02:00
|
|
|
// CraftBukkit end
|
2012-01-14 21:03:48 +01:00
|
|
|
this.lowPriority = true;
|
2011-05-21 21:27:34 +02:00
|
|
|
this.a = i;
|
|
|
|
this.b = j;
|
|
|
|
this.c = k;
|
|
|
|
this.d = l;
|
|
|
|
this.e = i1;
|
|
|
|
this.f = j1;
|
2012-01-14 21:03:48 +01:00
|
|
|
/* CraftBukkit start - Moved compression into its own method.
|
2011-05-21 21:27:34 +02:00
|
|
|
byte[] abyte = data; // CraftBukkit - uses data from above constructor
|
2011-06-12 00:02:58 +02:00
|
|
|
Deflater deflater = new Deflater(-1);
|
2011-05-21 21:27:34 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
deflater.setInput(abyte);
|
|
|
|
deflater.finish();
|
2012-01-14 21:03:48 +01:00
|
|
|
this.buffer = new byte[l * i1 * j1 * 5 / 2];
|
|
|
|
this.size = deflater.deflate(this.buffer);
|
2011-05-21 21:27:34 +02:00
|
|
|
} finally {
|
|
|
|
deflater.end();
|
2012-01-14 21:03:48 +01:00
|
|
|
} */
|
|
|
|
this.rawData = data;
|
|
|
|
// CraftBukkit end
|
2011-05-21 21:27:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2012-01-12 16:27:39 +01:00
|
|
|
this.size = datainputstream.readInt();
|
|
|
|
byte[] abyte = new byte[this.size];
|
2011-05-21 21:27:34 +02:00
|
|
|
|
|
|
|
datainputstream.readFully(abyte);
|
2012-01-12 16:27:39 +01:00
|
|
|
this.buffer = new byte[this.d * this.e * this.f * 5 / 2];
|
2011-05-21 21:27:34 +02:00
|
|
|
Inflater inflater = new Inflater();
|
|
|
|
|
|
|
|
inflater.setInput(abyte);
|
|
|
|
|
|
|
|
try {
|
2012-01-12 16:27:39 +01:00
|
|
|
inflater.inflate(this.buffer);
|
2011-05-21 21:27:34 +02:00
|
|
|
} catch (DataFormatException dataformatexception) {
|
|
|
|
throw new IOException("Bad compressed data format");
|
|
|
|
} finally {
|
|
|
|
inflater.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2012-01-12 16:27:39 +01:00
|
|
|
dataoutputstream.writeInt(this.size);
|
|
|
|
dataoutputstream.write(this.buffer, 0, this.size);
|
2011-05-21 21:27:34 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void handle(NetHandler nethandler) {
|
2011-05-21 21:27:34 +02:00
|
|
|
nethandler.a(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a() {
|
2012-01-12 16:27:39 +01:00
|
|
|
return 17 + this.size;
|
2011-05-21 21:27:34 +02:00
|
|
|
}
|
|
|
|
}
|