-
-
Notifications
You must be signed in to change notification settings - Fork 202
/
ServerEntityMovementPacket.java
97 lines (75 loc) · 1.89 KB
/
ServerEntityMovementPacket.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package org.spacehq.mc.protocol.packet.ingame.server.entity;
import org.spacehq.packetlib.io.NetInput;
import org.spacehq.packetlib.io.NetOutput;
import org.spacehq.packetlib.packet.Packet;
import java.io.IOException;
public class ServerEntityMovementPacket implements Packet {
protected int entityId;
protected double moveX;
protected double moveY;
protected double moveZ;
protected float yaw;
protected float pitch;
private boolean onGround;
protected boolean pos = false;
protected boolean rot = false;
protected ServerEntityMovementPacket() {
}
public ServerEntityMovementPacket(int entityId, boolean onGround) {
this.entityId = entityId;
this.onGround = onGround;
}
public int getEntityId() {
return this.entityId;
}
public double getMovementX() {
return this.moveX;
}
public double getMovementY() {
return this.moveY;
}
public double getMovementZ() {
return this.moveZ;
}
public float getYaw() {
return this.yaw;
}
public float getPitch() {
return this.pitch;
}
public boolean isOnGround() {
return this.onGround;
}
@Override
public void read(NetInput in) throws IOException {
this.entityId = in.readVarInt();
if(this.pos) {
this.moveX = in.readByte() / 32D;
this.moveY = in.readByte() / 32D;
this.moveZ = in.readByte() / 32D;
}
if(this.rot) {
this.yaw = in.readByte() * 360 / 256f;
this.pitch = in.readByte() * 360 / 256f;
}
this.onGround = in.readBoolean();
}
@Override
public void write(NetOutput out) throws IOException {
out.writeVarInt(this.entityId);
if(this.pos) {
out.writeByte((int) (this.moveX * 32));
out.writeByte((int) (this.moveY * 32));
out.writeByte((int) (this.moveZ * 32));
}
if(this.rot) {
out.writeByte((byte) (this.yaw * 256 / 360));
out.writeByte((byte) (this.pitch * 256 / 360));
}
out.writeBoolean(this.onGround);
}
@Override
public boolean isPriority() {
return false;
}
}