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.List;
7
8public class Packet104WindowItems extends Packet {
9
10 public int a;
11 public ItemStack[] b;
12
13 public Packet104WindowItems() {
14 }
15
16 public Packet104WindowItems(int i, List list) {
17 this.a = i;
18 this.b = new ItemStack[list.size()];
19
20 for (int j = 0; j < this.b.length; ++j) {
21 ItemStack itemstack = (ItemStack) list.get(j);
22
23 this.b[j] = itemstack == null ? null : itemstack.cloneItemStack();
24 }
25 }
26
27 public void a(DataInputStream datainputstream) throws IOException {
28 this.a = datainputstream.readByte();
29 short short1 = datainputstream.readShort();
30
31 this.b = new ItemStack[short1];
32
33 for (int i = 0; i < short1; ++i) {
34 short short2 = datainputstream.readShort();
35
36 if (short2 >= 0) {
37 byte b0 = datainputstream.readByte();
38 short short3 = datainputstream.readShort();
39
40 this.b[i] = new ItemStack(short2, b0, short3);
41 }
42 }
43 }
44
45 public void a(DataOutputStream dataoutputstream) throws IOException {
46 dataoutputstream.writeByte(this.a);
47 dataoutputstream.writeShort(this.b.length);
48
49 for (int i = 0; i < this.b.length; ++i) {
50 if (this.b[i] == null) {
51 dataoutputstream.writeShort(-1);
52 } else {
53 dataoutputstream.writeShort((short) this.b[i].id);
54 dataoutputstream.writeByte((byte) this.b[i].count);
55 dataoutputstream.writeShort((short) this.b[i].getData());
56 }
57 }
58 }
59
60 public void a(NetHandler nethandler) {
61 nethandler.a(this);
62 }
63
64 public int a() {
65 return 3 + this.b.length * 5;
66 }
67}