Добавил еще пяток пакетов, но без обработчика
This commit is contained in:
@@ -45,8 +45,13 @@ public enum State {
|
|||||||
PLAY(3,
|
PLAY(3,
|
||||||
ImmutableBiMap.<Integer, Class<? extends CSPacket>>builder()
|
ImmutableBiMap.<Integer, Class<? extends CSPacket>>builder()
|
||||||
.put(0x00, TeleportConfirmPacket.class)
|
.put(0x00, TeleportConfirmPacket.class)
|
||||||
|
.put(0x01, TabCompletePacket.class)
|
||||||
|
.put(0x02, ChatMessagePacket.class)
|
||||||
.put(0x04, ClientSettingsPacket.class)
|
.put(0x04, ClientSettingsPacket.class)
|
||||||
.put(0x09, PluginMessagePacket.class)
|
.put(0x09, PluginMessagePacket.class)
|
||||||
|
.put(0x0E, PlayerPositionAndLookPacket.class)
|
||||||
|
.put(0x1A, HeldItemChangePacket.class)
|
||||||
|
.put(0x1D, AnimationPacket.class)
|
||||||
.build(),
|
.build(),
|
||||||
ImmutableBiMap.<Class<? extends SCPacket>, Integer>builder()
|
ImmutableBiMap.<Class<? extends SCPacket>, Integer>builder()
|
||||||
.put(PluginMessagePacket.class, 0x18)
|
.put(PluginMessagePacket.class, 0x18)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-06-17
|
||||||
|
*/
|
||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
|
import mc.core.network.NetStream;
|
||||||
|
|
||||||
|
public class AnimationPacket implements CSPacket {
|
||||||
|
private int handAnimation;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetStream netStream) {
|
||||||
|
this.handAnimation = netStream.readVarInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-06-17
|
||||||
|
*/
|
||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
|
import mc.core.network.NetStream;
|
||||||
|
|
||||||
|
public class ChatMessagePacket implements CSPacket {
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetStream netStream) {
|
||||||
|
this.message = netStream.readString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-06-17
|
||||||
|
*/
|
||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
|
import mc.core.network.NetStream;
|
||||||
|
|
||||||
|
public class HeldItemChangePacket implements CSPacket {
|
||||||
|
private int slot;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetStream netStream) {
|
||||||
|
this.slot = netStream.readShort();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
package mc.core.network.proto_1_12_2.packets;
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import mc.core.Location;
|
import mc.core.Location;
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
import mc.core.network.NetStream;
|
import mc.core.network.NetStream;
|
||||||
import mc.core.network.SCPacket;
|
import mc.core.network.SCPacket;
|
||||||
import mc.core.player.Look;
|
import mc.core.player.Look;
|
||||||
@@ -14,11 +16,13 @@ import mc.core.player.Look;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class PlayerPositionAndLookPacket implements SCPacket {
|
public class PlayerPositionAndLookPacket implements SCPacket, CSPacket {
|
||||||
private static Random RANDOM = new Random();
|
private static Random RANDOM = new Random();
|
||||||
private Location location;
|
private Location location;
|
||||||
private Look look;
|
private Look look;
|
||||||
|
private boolean onGround = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSelf(NetStream netStream) {
|
public void writeSelf(NetStream netStream) {
|
||||||
@@ -34,6 +38,23 @@ public class PlayerPositionAndLookPacket implements SCPacket {
|
|||||||
* Y_ROT - 0x08
|
* Y_ROT - 0x08
|
||||||
* X_ROT - 0x10
|
* X_ROT - 0x10
|
||||||
*/
|
*/
|
||||||
|
//FIXME teleport id
|
||||||
netStream.writeVarInt(RANDOM.nextInt()); // Client should confirm this packet with Teleport Confirm containing the same Teleport ID
|
netStream.writeVarInt(RANDOM.nextInt()); // Client should confirm this packet with Teleport Confirm containing the same Teleport ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetStream netStream) {
|
||||||
|
this.location = new Location(
|
||||||
|
netStream.readDouble(),
|
||||||
|
netStream.readDouble(),
|
||||||
|
netStream.readDouble()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.look = new Look(
|
||||||
|
netStream.readFloat(),
|
||||||
|
netStream.readFloat()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.onGround = netStream.readBoolean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-06-17
|
||||||
|
*/
|
||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import mc.core.Location;
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
|
import mc.core.network.NetStream;
|
||||||
|
import mc.core.network.proto_1_12_2.serializers.LocationSerializer;
|
||||||
|
|
||||||
|
public class TabCompletePacket implements CSPacket {
|
||||||
|
private String text;
|
||||||
|
private boolean assumeCommand;
|
||||||
|
private boolean hasPosition;
|
||||||
|
private Location location;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetStream netStream) {
|
||||||
|
this.text = netStream.readString();
|
||||||
|
this.assumeCommand = netStream.readBoolean();
|
||||||
|
this.hasPosition = netStream.readBoolean();
|
||||||
|
|
||||||
|
if (this.hasPosition) {
|
||||||
|
this.location = LocationSerializer.deserialize(netStream.readLong());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user