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;
6
7public class Packet28EntityVelocity extends Packet {
8
9 public int a;
10 public double b;
11 public double c;
12 public double d;
13
14 public Packet28EntityVelocity() {
15 }
16
17 public Packet28EntityVelocity(Entity entity) {
18 this(entity.id, entity.motX, entity.motY, entity.motZ);
19 }
20
21 public Packet28EntityVelocity(int i, double d0, double d1, double d2) {
22 this.a = i;
23 // uberbukkit - values are calculated on sending to achieve compatibility
24 // TODO: test impact on performance?
25 this.b = d0;
26 this.c = d1;
27 this.d = d2;
28 }
29
30 public void a(DataInputStream datainputstream) throws IOException {
31 this.a = datainputstream.readInt();
32 this.b = datainputstream.readShort();
33 this.c = datainputstream.readShort();
34 this.d = datainputstream.readShort();
35 }
36
37 public void a(DataOutputStream dataoutputstream) throws IOException {
38 dataoutputstream.writeInt(this.a);
39
40 // uberbukkit start
41 double d3 = 3.9D;
42 if (this.pvn <= 5) d3 = 0.9D;
43
44 if (this.b < -d3) {
45 this.b = -d3;
46 }
47
48 if (this.c < -d3) {
49 this.c = -d3;
50 }
51
52 if (this.d < -d3) {
53 this.d = -d3;
54 }
55
56 if (this.b > d3) {
57 this.b = d3;
58 }
59
60 if (this.c > d3) {
61 this.c = d3;
62 }
63
64 if (this.d > d3) {
65 this.d = d3;
66 }
67
68 double multiplier = 8000.0D;
69 if (this.pvn <= 5) multiplier = 32000.0D;
70
71 dataoutputstream.writeShort((int) (this.b * multiplier));
72 dataoutputstream.writeShort((int) (this.c * multiplier));
73 dataoutputstream.writeShort((int) (this.d * multiplier));
74 // uberbukkit end
75 }
76
77 public void a(NetHandler nethandler) {
78 nethandler.a(this);
79 }
80
81 public int a() {
82 return 10;
83 }
84}