Archived
0

дополнение пакета PlayerAbilitiesPacket

This commit is contained in:
2018-08-18 22:31:03 +03:00
parent fcefba29ac
commit 993f398a62
2 changed files with 20 additions and 1 deletions

View File

@@ -80,6 +80,7 @@ public enum State {
.put(0x0D, PlayerPositionPacket.class)
.put(0x0E, PlayerPositionAndLookPacket.class)
.put(0x0F, PlayerLookPacket.class)
.put(0x13, PlayerAbilitiesPacket.class)
.put(0x15, EntityActionPacket.class)
.put(0x1A, HeldItemChangePacket.class)
.put(0x1D, AnimationPacket.class)

View File

@@ -4,22 +4,27 @@
*/
package mc.core.network.proto_1_12_2.packets;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import mc.core.network.CSPacket;
import mc.core.network.NetInputStream;
import mc.core.network.NetOutputStream;
import mc.core.network.SCPacket;
@NoArgsConstructor
@Getter
@Setter
@ToString
public class PlayerAbilitiesPacket implements SCPacket {
public class PlayerAbilitiesPacket implements SCPacket, CSPacket {
private boolean godMode = false;
private boolean flying = false;
private boolean canFly = false;
private boolean instantDestroyBlocks = false;
private float flyingSpeed = 0.05f;
private float fieldOfView = flyingSpeed;
private float walkingSpeed;
@Override
public void writeSelf(NetOutputStream netStream) {
@@ -33,4 +38,17 @@ public class PlayerAbilitiesPacket implements SCPacket {
netStream.writeFloat(flyingSpeed);
netStream.writeFloat(fieldOfView);
}
@Override
public void readSelf(NetInputStream netStream) {
byte flag = netStream.readByte();
//FIXME треубет проверки
godMode = (flag == 0x08);
canFly = (flag == 0x04);
flying = (flag == 0x02);
instantDestroyBlocks = (flag == 0x01);
flyingSpeed = netStream.readFloat();
walkingSpeed = netStream.readFloat();
}
}