Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import java.io.DataInputStream;
4import java.io.DataOutputStream;
5import java.io.IOException;
6import java.util.zip.DataFormatException;
7import java.util.zip.Inflater;
8
9public class Packet51MapChunk extends Packet {
10
11 public int a;
12 public int b;
13 public int c;
14 public int d;
15 public int e;
16 public int f;
17 public byte[] g;
18 public int h; // CraftBukkit - private -> public
19 public byte[] rawData; // CraftBukkit
20
21 public Packet51MapChunk() {
22 this.k = true;
23 }
24
25 // CraftBukkit start
26 public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, World world) {
27 this(i, j, k, l, i1, j1, world.getMultiChunkData(i, j, k, l, i1, j1));
28 }
29
30 public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, byte[] data) {
31 // CraftBukkit end
32 this.k = true;
33 this.a = i;
34 this.b = j;
35 this.c = k;
36 this.d = l;
37 this.e = i1;
38 this.f = j1;
39 /* CraftBukkit - Moved compression into its own method.
40 byte[] abyte = data; // CraftBukkit - uses data from above constructor
41 Deflater deflater = new Deflater(-1);
42
43 try {
44 deflater.setInput(abyte);
45 deflater.finish();
46 this.g = new byte[l * i1 * j1 * 5 / 2];
47 this.h = deflater.deflate(this.g);
48 } finally {
49 deflater.end();
50 }*/
51 this.rawData = data; // CraftBukkit
52 }
53
54 public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOEXception
55 this.a = datainputstream.readInt();
56 this.b = datainputstream.readShort();
57 this.c = datainputstream.readInt();
58 this.d = datainputstream.read() + 1;
59 this.e = datainputstream.read() + 1;
60 this.f = datainputstream.read() + 1;
61 this.h = datainputstream.readInt();
62 byte[] abyte = new byte[this.h];
63
64 datainputstream.readFully(abyte);
65 this.g = new byte[this.d * this.e * this.f * 5 / 2];
66 Inflater inflater = new Inflater();
67
68 inflater.setInput(abyte);
69
70 try {
71 inflater.inflate(this.g);
72 } catch (DataFormatException dataformatexception) {
73 throw new IOException("Bad compressed data format");
74 } finally {
75 inflater.end();
76 }
77 }
78
79 public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
80 dataoutputstream.writeInt(this.a);
81 dataoutputstream.writeShort(this.b);
82 dataoutputstream.writeInt(this.c);
83 dataoutputstream.write(this.d - 1);
84 dataoutputstream.write(this.e - 1);
85 dataoutputstream.write(this.f - 1);
86 dataoutputstream.writeInt(this.h);
87 dataoutputstream.write(this.g, 0, this.h);
88 }
89
90 public void a(NetHandler nethandler) {
91 nethandler.a(this);
92 }
93
94 public int a() {
95 return 17 + this.h;
96 }
97}