Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 119 lines 3.5 kB view raw
1package net.minecraft.server; 2 3import java.io.DataInputStream; 4import java.io.DataOutputStream; 5import java.io.IOException; 6 7public class Packet5EntityEquipment extends Packet { 8 9 public int a; 10 public int b; 11 public int c; 12 public int d; 13 public ItemStack[] items; // uberbukkit - vanilla alpha support 14 15 public Packet5EntityEquipment() { 16 } 17 18 // pvn >= 7 19 public Packet5EntityEquipment(int i, int j, ItemStack itemstack) { 20 this.a = i; 21 this.b = j; 22 if (itemstack == null) { 23 this.c = -1; 24 this.d = 0; 25 } else { 26 this.c = itemstack.id; 27 this.d = itemstack.getData(); 28 } 29 } 30 31 // pvn <= 6 32 // uberbukkit - added constructor for the alpha variant of packet 5 33 public Packet5EntityEquipment(int i, ItemStack[] aitemstack) { 34 this.a = i; 35 this.items = new ItemStack[aitemstack.length]; 36 37 for (int j = 0; j < this.items.length; ++j) { 38 this.items[j] = aitemstack[j] == null ? null : aitemstack[j].cloneItemStack(); 39 } 40 } 41 42 public void a(DataInputStream datainputstream) throws IOException { 43 this.a = datainputstream.readInt(); 44 // uberbukkit start 45 if (this.pvn >= 7) { 46 this.b = datainputstream.readShort(); 47 this.c = datainputstream.readShort(); 48 49 if (this.pvn >= 8) { 50 this.d = datainputstream.readShort(); 51 } else { 52 this.d = 0; 53 } 54 } else { 55 short short1 = datainputstream.readShort(); 56 57 this.items = new ItemStack[short1]; 58 59 for (int i = 0; i < short1; ++i) { 60 short short2 = datainputstream.readShort(); 61 62 if (short2 >= 0) { 63 byte b0 = datainputstream.readByte(); 64 short short3 = datainputstream.readShort(); 65 66 this.items[i] = new ItemStack(short2, b0, short3); 67 } 68 } 69 } 70 // uberbukkit end 71 } 72 73 public void a(DataOutputStream dataoutputstream) throws IOException { 74 dataoutputstream.writeInt(this.a); 75 // uberbukkit start 76 if (this.pvn >= 7) { 77 dataoutputstream.writeShort(this.b); 78 dataoutputstream.writeShort(this.c); 79 80 if (this.pvn >= 8) { 81 dataoutputstream.writeShort(this.d); 82 } 83 } else { 84 dataoutputstream.writeShort(this.items.length); 85 86 for (int i = 0; i < this.items.length; ++i) { 87 if (this.items[i] == null) { 88 dataoutputstream.writeShort(-1); 89 } else { 90 dataoutputstream.writeShort((short) this.items[i].id); 91 dataoutputstream.writeByte((byte) this.items[i].count); 92 dataoutputstream.writeShort((short) this.items[i].damage); 93 } 94 } 95 } 96 // uberbukkit end 97 } 98 99 public void a(NetHandler nethandler) { 100 nethandler.a(this); 101 } 102 103 public int a() { 104 // uberbukkit - size varies between pvns 105 return this.pvn >= 7 ? 8 : (6 + this.items.length * 5); 106 } 107 108 // uberbukkit 109 @Override 110 public Packet clone() { 111 Packet5EntityEquipment packet = new Packet5EntityEquipment(); 112 packet.a = this.a; 113 packet.b = this.b; 114 packet.c = this.c; 115 packet.d = this.d; 116 packet.items = this.items; 117 return packet; 118 } 119}