Player info packet
This commit is contained in:
@@ -25,6 +25,7 @@ public abstract class NetStream {
|
|||||||
public abstract void writeBoolean(boolean value);
|
public abstract void writeBoolean(boolean value);
|
||||||
public abstract void writeByte(int value);
|
public abstract void writeByte(int value);
|
||||||
public abstract void writeBytes(byte[] buffer);
|
public abstract void writeBytes(byte[] buffer);
|
||||||
|
public abstract void writeShort(int value);
|
||||||
public abstract void writeInt(int value);
|
public abstract void writeInt(int value);
|
||||||
public abstract void writeFloat(float value);
|
public abstract void writeFloat(float value);
|
||||||
public abstract void writeDouble(double value);
|
public abstract void writeDouble(double value);
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ public class ByteArrayOutputNetStream extends NetStream_p125 {
|
|||||||
baos.write(buffer, 0, buffer.length);
|
baos.write(buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeShort(int value) {
|
||||||
|
baos.write((byte) value >>> 8);
|
||||||
|
baos.write((byte) value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeInt(int value) {
|
public void writeInt(int value) {
|
||||||
baos.write((byte) value >>> 24);
|
baos.write((byte) value >>> 24);
|
||||||
|
|||||||
@@ -88,6 +88,13 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
|||||||
abilitiesPkt.setInstantDestroyBlocks(true);
|
abilitiesPkt.setInstantDestroyBlocks(true);
|
||||||
channel.write(abilitiesPkt);
|
channel.write(abilitiesPkt);
|
||||||
|
|
||||||
|
// send Player info
|
||||||
|
PlayerInfoPacket infoPkt = new PlayerInfoPacket();
|
||||||
|
infoPkt.setPlayerName(player.getName());
|
||||||
|
infoPkt.setOnline(true);
|
||||||
|
infoPkt.setPing(4);
|
||||||
|
channel.write(infoPkt);
|
||||||
|
|
||||||
PositionAndLookPacket pkt = new PositionAndLookPacket();
|
PositionAndLookPacket pkt = new PositionAndLookPacket();
|
||||||
pkt.setLocation(new Location(0, 0, 0));
|
pkt.setLocation(new Location(0, 0, 0));
|
||||||
pkt.setStance(0);
|
pkt.setStance(0);
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ public class WrapperNetStream extends NetStream_p125 {
|
|||||||
byteBuf.writeBytes(buffer);
|
byteBuf.writeBytes(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeShort(int value) {
|
||||||
|
byteBuf.writeShort(value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeInt(int value) {
|
public void writeInt(int value) {
|
||||||
byteBuf.writeInt(value);
|
byteBuf.writeInt(value);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class PacketManager {
|
|||||||
.put(0x02, HandshakePacket.class)
|
.put(0x02, HandshakePacket.class)
|
||||||
.put(0x06, SpawnPositionPacket.class)
|
.put(0x06, SpawnPositionPacket.class)
|
||||||
.put(0x0D, PositionAndLookPacket.class)
|
.put(0x0D, PositionAndLookPacket.class)
|
||||||
|
.put(0xC9, PlayerInfoPacket.class)
|
||||||
.put(0xCA, PlayerAbilitiesPacket.class)
|
.put(0xCA, PlayerAbilitiesPacket.class)
|
||||||
.put(0xFE, PingPacket.class)
|
.put(0xFE, PingPacket.class)
|
||||||
.put(0xFF, KickPacket.class)
|
.put(0xFF, KickPacket.class)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-04-19
|
||||||
|
*/
|
||||||
|
package mc.core.network.proto_125.packets;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import mc.core.network.SCPacket;
|
||||||
|
import mc.core.network.proto_125.ByteArrayOutputNetStream;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class PlayerInfoPacket implements SCPacket {
|
||||||
|
private String playerName;
|
||||||
|
private boolean online;
|
||||||
|
private int ping;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] toByteArray() {
|
||||||
|
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
|
||||||
|
|
||||||
|
netStream.writeString(playerName);
|
||||||
|
netStream.writeBoolean(online);
|
||||||
|
netStream.writeShort(ping);
|
||||||
|
|
||||||
|
return netStream.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user