added packets PlayerPosition & PlayerLook
This commit is contained in:
@@ -77,7 +77,9 @@ public enum State {
|
|||||||
.put(0x04, ClientSettingsPacket.class)
|
.put(0x04, ClientSettingsPacket.class)
|
||||||
.put(0x09, PluginMessagePacket.class)
|
.put(0x09, PluginMessagePacket.class)
|
||||||
.put(0x0B, KeepAlivePacket.class)
|
.put(0x0B, KeepAlivePacket.class)
|
||||||
|
.put(0x0D, PlayerPositionPacket.class)
|
||||||
.put(0x0E, PlayerPositionAndLookPacket.class)
|
.put(0x0E, PlayerPositionAndLookPacket.class)
|
||||||
|
.put(0x0F, PlayerLookPacket.class)
|
||||||
.put(0x1A, HeldItemChangePacket.class)
|
.put(0x1A, HeldItemChangePacket.class)
|
||||||
.put(0x1D, AnimationPacket.class)
|
.put(0x1D, AnimationPacket.class)
|
||||||
.build(),
|
.build(),
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
|
import mc.core.network.NetInputStream;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PlayerLookPacket implements CSPacket {
|
||||||
|
private float yaw, pitch;
|
||||||
|
private boolean onGround; // True if the client is on the ground, false otherwise
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetInputStream netStream) {
|
||||||
|
this.yaw = netStream.readFloat();
|
||||||
|
this.pitch = netStream.readFloat();
|
||||||
|
this.onGround = netStream.readBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import mc.core.network.CSPacket;
|
||||||
|
import mc.core.network.NetInputStream;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PlayerPositionPacket implements CSPacket {
|
||||||
|
private double x, y, z; // Y - is feet position. Normally Head Y - +1.62d
|
||||||
|
private boolean onGround; // True if the client is on the ground, false otherwise
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSelf(NetInputStream netStream) {
|
||||||
|
this.x = netStream.readDouble();
|
||||||
|
this.y = netStream.readDouble();
|
||||||
|
this.z = netStream.readDouble();
|
||||||
|
this.onGround = netStream.readBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,7 @@ package mc.core.network.proto_1_12_2.netty.handlers;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import mc.core.chat.ChatProcessor;
|
import mc.core.chat.ChatProcessor;
|
||||||
import mc.core.network.proto_1_12_2.TeleportManager;
|
import mc.core.network.proto_1_12_2.TeleportManager;
|
||||||
import mc.core.network.proto_1_12_2.packets.ChatMessageClientPacket;
|
import mc.core.network.proto_1_12_2.packets.*;
|
||||||
import mc.core.network.proto_1_12_2.packets.ClientSettingsPacket;
|
|
||||||
import mc.core.network.proto_1_12_2.packets.PlayerPositionAndLookPacket;
|
|
||||||
import mc.core.network.proto_1_12_2.packets.TeleportConfirmPacket;
|
|
||||||
import mc.core.player.Player;
|
import mc.core.player.Player;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -63,4 +60,16 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
|
|||||||
packet.getMessage()
|
packet.getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Handler
|
||||||
|
public void onPlayerMove(Channel channel, PlayerPositionPacket packet) {
|
||||||
|
Player player = channel.attr(ATTR_PLAYER).get();
|
||||||
|
player.getLocation().setXYZ(packet.getX(), packet.getY(), packet.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Handler
|
||||||
|
public void onPlayerLook(Channel channel, PlayerLookPacket packet) {
|
||||||
|
Player player = channel.attr(ATTR_PLAYER).get();
|
||||||
|
player.getLocation().setYawPitch(packet.getYaw(), packet.getPitch());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user