Compare commits
4 Commits
dev/tablis
...
dev/chat
| Author | SHA1 | Date | |
|---|---|---|---|
|
c632513e4c
|
|||
|
918db26698
|
|||
|
68a288c525
|
|||
|
47e6c3e76f
|
@@ -50,19 +50,17 @@ public enum State {
|
|||||||
0x0B, PingPacket.class,
|
0x0B, PingPacket.class,
|
||||||
0x0D, PlayerPositionPacket.class,
|
0x0D, PlayerPositionPacket.class,
|
||||||
0x0E, CPlayerPositionAndLookPacket.class,
|
0x0E, CPlayerPositionAndLookPacket.class,
|
||||||
0x0F, PlayerLookPacket.class,
|
0x0F, PlayerLookPacket.class
|
||||||
0x15, EntityActionPacket.class
|
|
||||||
),
|
),
|
||||||
// client bound
|
// client bound
|
||||||
Map.of(
|
Map.of(
|
||||||
|
SChatPacket.class, 0x0F,
|
||||||
PingPacket.class, 0x1F,
|
PingPacket.class, 0x1F,
|
||||||
ChunkDataPacket.class, 0x20,
|
|
||||||
JoinGamePacket.class, 0x23,
|
JoinGamePacket.class, 0x23,
|
||||||
PlayerAbilitiesPacket.class,0x2C,
|
|
||||||
PlayerListItemPacket.class,0x2E,
|
|
||||||
SPlayerPositionAndLookPacket.class, 0x2F,
|
|
||||||
SpawnPositionPacket.class, 0x46,
|
SpawnPositionPacket.class, 0x46,
|
||||||
PlayerListHeaderAndFooterPacket.class,0x4A
|
ChunkDataPacket.class, 0x20,
|
||||||
|
PlayerAbilitiesPacket.class,0x2C,
|
||||||
|
SPlayerPositionAndLookPacket.class, 0x2F
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ public enum TextColor {
|
|||||||
WHITE ("white", 'f');
|
WHITE ("white", 'f');
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
|
public static final char SPECIAL_CHAR = '\u00a7';
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final char code;
|
private final char code;
|
||||||
|
|
||||||
|
public String toLegacy() {
|
||||||
|
return "" + SPECIAL_CHAR + code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package mc.protocol.model.text;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum TextStyleLegacy {
|
||||||
|
|
||||||
|
OBFUSCATED('k'),
|
||||||
|
BOLD('l'),
|
||||||
|
STRIKETHOUGH('m'),
|
||||||
|
UNDERLINE('n'),
|
||||||
|
ITALIC('o'),
|
||||||
|
RESET('r');
|
||||||
|
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
public String toLegacy() {
|
||||||
|
return "" + TextColor.SPECIAL_CHAR + code;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package mc.protocol.packets.client;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import mc.protocol.io.NetByteBuf;
|
|
||||||
import mc.protocol.packets.ClientSidePacket;
|
|
||||||
import mc.protocol.utils.EntityActionAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entity Action packet.
|
|
||||||
*
|
|
||||||
* <p>Структура пакета</p>
|
|
||||||
* <pre>
|
|
||||||
* | FIELD | TYPE | NOTES |
|
|
||||||
* |------------|--------|-------------------------------------------|
|
|
||||||
* | Entity ID | VarInt | ID игрока |
|
|
||||||
* | Action ID | VarInt | ID действия |
|
|
||||||
* | Jump Boost | VarInt | Используется только при "Action ID" = 5. |
|
|
||||||
* | | | В этом случае значение будет от 0 до 100. |
|
|
||||||
* | | | В остальных случаях значение 0. |
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Entity_Action" target="_top">Entity Action</a>
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@ToString
|
|
||||||
public class EntityActionPacket implements ClientSidePacket {
|
|
||||||
|
|
||||||
private Integer entityId;
|
|
||||||
private EntityActionAction action;
|
|
||||||
private Integer jumpBoost;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readSelf(NetByteBuf netByteBuf) {
|
|
||||||
this.entityId = netByteBuf.readVarInt();
|
|
||||||
int actionId = netByteBuf.readVarInt();
|
|
||||||
this.jumpBoost = netByteBuf.readVarInt();
|
|
||||||
|
|
||||||
this.action = EntityActionAction.valueOfCode(actionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void passivate() {
|
|
||||||
this.entityId = null;
|
|
||||||
this.action = null;
|
|
||||||
this.jumpBoost = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package mc.protocol.packets.server;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import mc.protocol.io.NetByteBuf;
|
|
||||||
import mc.protocol.model.text.Text;
|
|
||||||
import mc.protocol.packets.ServerSidePacket;
|
|
||||||
import mc.protocol.serializer.TextSerializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Установка текста для "шапки" и "подвала" Tab-листа.
|
|
||||||
*
|
|
||||||
* <p>Структура пакета</p>
|
|
||||||
* <pre>
|
|
||||||
* | FIELD | TYPE | NOTES |
|
|
||||||
* |--------|------|-------|
|
|
||||||
* | Header | Text | |
|
|
||||||
* | Footer | Text | |
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* <p>Для удаления "шапки" и/или "подвала", нужно отправить следующий {@link Text} компонент:</p>
|
|
||||||
* <pre>
|
|
||||||
* {"translate":""}
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Player_List_Header_And_Footer">Player List Header And Footer</a>
|
|
||||||
* @see PlayerListItemPacket
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class PlayerListHeaderAndFooterPacket implements ServerSidePacket {
|
|
||||||
|
|
||||||
private static final String REMOVE_COMPONENT = "{\"translate\":\"\"}";
|
|
||||||
|
|
||||||
private Text header;
|
|
||||||
private Text foother;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeSelf(NetByteBuf netByteBuf) {
|
|
||||||
if (this.header == null) {
|
|
||||||
netByteBuf.writeString(REMOVE_COMPONENT);
|
|
||||||
} else {
|
|
||||||
netByteBuf.writeString(TextSerializer.toJsonObject(this.header).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.foother == null) {
|
|
||||||
netByteBuf.writeString(REMOVE_COMPONENT);
|
|
||||||
} else {
|
|
||||||
netByteBuf.writeString(TextSerializer.toJsonObject(this.foother).toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
package mc.protocol.packets.server;
|
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
import mc.protocol.io.NetByteBuf;
|
|
||||||
import mc.protocol.packets.ServerSidePacket;
|
|
||||||
import mc.protocol.utils.GameMode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player List Item packet.
|
|
||||||
*
|
|
||||||
* <p>Обновление списка игроков, по кнопке TAB.</p>
|
|
||||||
*
|
|
||||||
* <p>Структура пакета</p>
|
|
||||||
* <pre>
|
|
||||||
* | FIELD | TYPE | NOTES |
|
|
||||||
* |-------------------|-------------|-------------------------------------------------|
|
|
||||||
* | Action | VarInt | Определяет поля для секции "Player" |
|
|
||||||
* | Number of players | VarInt | Количество элементов в секции "Players" |
|
|
||||||
* | Players | Array | Перечисление полей для каждого игрока (player). |
|
|
||||||
* | | | Поля определяются по "Action" |
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* <p>Варианты "Action"</p>
|
|
||||||
* <pre>
|
|
||||||
* | ACTION | PLAYER FIELD | TYPE | NOTES |
|
|
||||||
* | VALUE | DESCRIPTION | | | |
|
|
||||||
* |-------|---------------------|----------------------|-------------|----------------------------------------------------|
|
|
||||||
* | 0 | add player | UUID | UUID | |
|
|
||||||
* | | | Name | String (16) | |
|
|
||||||
* | | | Number Of Properties | VarInt | Количество элементов "Properties" |
|
|
||||||
* | | | Properties | - | см. поля ниже |
|
|
||||||
* | | | Gamemode | VarInt | |
|
|
||||||
* | | | Ping | VarInt | в милисекундах |
|
|
||||||
* | | | Has Display Name | Boolean | |
|
|
||||||
* | | | Display Name | Text | Опционально. Только если "Has Display Name" = true |
|
|
||||||
* | 1 | update gamemode | UUID | UUID | |
|
|
||||||
* | | | Gamemode | VarInt | |
|
|
||||||
* | 2 | update latency | UUID | UUID | |
|
|
||||||
* | | | Ping | VarInt | (см. выше) |
|
|
||||||
* | 3 | update display name | UUID | UUID | |
|
|
||||||
* | | | Has Display Name | Boolean | |
|
|
||||||
* | | | Display Name | Text | (см. выше) |
|
|
||||||
* | 4 | remove player | UUID | UUID | |
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* <p>Поля секции "Properties"</p>
|
|
||||||
* <pre>
|
|
||||||
* | FIELD | TYPE | NOTES |
|
|
||||||
* |-----------|------------- |---------------------------------------------|
|
|
||||||
* | Name | String (32767) | |
|
|
||||||
* | Value | String (32767) | |
|
|
||||||
* | Is Signed | Boolean | |
|
|
||||||
* | Signature | String (32767) | Опционально. Только если "Is Signed" = true |
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Player_List_Item">Player List Item</a>
|
|
||||||
* @see PlayerListHeaderAndFooterPacket
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class PlayerListItemPacket implements ServerSidePacket {
|
|
||||||
|
|
||||||
private final List<PlayerItem> playerItems = new ArrayList<>();
|
|
||||||
|
|
||||||
private Action action;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeSelf(NetByteBuf netByteBuf) {
|
|
||||||
netByteBuf.writeVarInt(this.action.getCode());
|
|
||||||
netByteBuf.writeVarInt(playerItems.size());
|
|
||||||
|
|
||||||
BiConsumer<NetByteBuf, PlayerItem> consumer = null;
|
|
||||||
switch (this.action) {
|
|
||||||
//@formatter:off
|
|
||||||
case ADD_PLAYER: consumer = this::addPlayer; break;
|
|
||||||
case UPDATE_GAMEMODE: consumer = this::updateGamemode; break;
|
|
||||||
case UPDATE_LATENCY: consumer = this::updateLatency; break;
|
|
||||||
case UPDATE_DISPLAY_NAME: consumer = this::updateDisplayName; break;
|
|
||||||
case REMOVE_PLAYER: consumer = this::removePlayer; break;
|
|
||||||
//@formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
Objects.requireNonNull(consumer);
|
|
||||||
|
|
||||||
for (PlayerItem playerItem : playerItems) {
|
|
||||||
consumer.accept(netByteBuf, playerItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPlayer(NetByteBuf netByteBuf, PlayerItem playerItem) {
|
|
||||||
netByteBuf.writeUUID(playerItem.getUuid());
|
|
||||||
netByteBuf.writeString(playerItem.getName());
|
|
||||||
netByteBuf.writeVarInt(playerItem.getProperties().size());
|
|
||||||
|
|
||||||
for (PlayerProperties property : playerItem.getProperties()) {
|
|
||||||
netByteBuf.writeString(property.getName());
|
|
||||||
netByteBuf.writeString(property.getValue());
|
|
||||||
netByteBuf.writeBoolean(property.getIsSigned());
|
|
||||||
if (property.getIsSigned()) {
|
|
||||||
netByteBuf.writeString(property.getSignature());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
netByteBuf.writeVarInt(playerItem.getGamemode().getId());
|
|
||||||
netByteBuf.writeVarInt(playerItem.getPing());
|
|
||||||
netByteBuf.writeBoolean(playerItem.getHasDisplayName());
|
|
||||||
if (playerItem.getHasDisplayName()) {
|
|
||||||
netByteBuf.writeString(playerItem.getDisplayName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateGamemode(NetByteBuf netByteBuf, PlayerItem playerItem) {
|
|
||||||
netByteBuf.writeUUID(playerItem.getUuid());
|
|
||||||
netByteBuf.writeVarInt(playerItem.getGamemode().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLatency(NetByteBuf netByteBuf, PlayerItem playerItem) {
|
|
||||||
netByteBuf.writeUUID(playerItem.getUuid());
|
|
||||||
netByteBuf.writeVarInt(playerItem.getPing());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDisplayName(NetByteBuf netByteBuf, PlayerItem playerItem) {
|
|
||||||
netByteBuf.writeUUID(playerItem.getUuid());
|
|
||||||
netByteBuf.writeBoolean(playerItem.getHasDisplayName());
|
|
||||||
if (playerItem.getHasDisplayName()) {
|
|
||||||
netByteBuf.writeString(playerItem.getDisplayName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removePlayer(NetByteBuf netByteBuf, PlayerItem playerItem) {
|
|
||||||
netByteBuf.writeUUID(playerItem.getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum Action {
|
|
||||||
ADD_PLAYER(0),
|
|
||||||
UPDATE_GAMEMODE(1),
|
|
||||||
UPDATE_LATENCY(2),
|
|
||||||
UPDATE_DISPLAY_NAME(3),
|
|
||||||
REMOVE_PLAYER(4);
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Builder(builderClassName = "Builder")
|
|
||||||
@Value
|
|
||||||
public static class PlayerItem {
|
|
||||||
List<PlayerProperties> properties = new ArrayList<>();
|
|
||||||
|
|
||||||
UUID uuid;
|
|
||||||
String name;
|
|
||||||
GameMode gamemode;
|
|
||||||
Integer ping;
|
|
||||||
Boolean hasDisplayName;
|
|
||||||
String displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Builder(builderClassName = "Builder")
|
|
||||||
@Value
|
|
||||||
public static class PlayerProperties {
|
|
||||||
String name;
|
|
||||||
String value;
|
|
||||||
Boolean isSigned;
|
|
||||||
String signature;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package mc.protocol.packets.server;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import mc.protocol.io.NetByteBuf;
|
||||||
|
import mc.protocol.model.text.Text;
|
||||||
|
import mc.protocol.model.text.TextColor;
|
||||||
|
import mc.protocol.model.text.TextStyle;
|
||||||
|
import mc.protocol.packets.ServerSidePacket;
|
||||||
|
import mc.protocol.serializer.TextSerializer;
|
||||||
|
import mc.protocol.utils.ChatPosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chat packet.
|
||||||
|
*
|
||||||
|
* <p>Структура пакета</p>
|
||||||
|
* <pre>
|
||||||
|
* | FIELD | TYPE | NOTES |
|
||||||
|
* |-----------|------|-----------------------------------------------|
|
||||||
|
* | JSON Data | Text | Текст* |
|
||||||
|
* | Position | Byte | 0 - сообщение чата |
|
||||||
|
* | | | 1 - системное сообщение (отображается в чате) |
|
||||||
|
* | | | 2 - над панелью быстрого доступа (hotbar) |
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* * - стоит обратить внимание, что {@link TextColor} и {@link TextStyle} не работают: клиент не применяет
|
||||||
|
* стилистику в таком виде. Однако метод через символ "§" (\<span>u00a7</span>) работает.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Chat_Message_.28clientbound.29">Chat Message (clientbound)</a>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SChatPacket implements ServerSidePacket {
|
||||||
|
|
||||||
|
private Text message;
|
||||||
|
private ChatPosition position;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeSelf(NetByteBuf netByteBuf) {
|
||||||
|
netByteBuf.writeString(TextSerializer.toJsonObject(this.message).toString());
|
||||||
|
netByteBuf.writeByte(this.position.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
15
protocol/src/main/java/mc/protocol/utils/ChatPosition.java
Normal file
15
protocol/src/main/java/mc/protocol/utils/ChatPosition.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package mc.protocol.utils;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum ChatPosition {
|
||||||
|
|
||||||
|
CHAT(0),
|
||||||
|
SYSTEM(1),
|
||||||
|
HOTBAR(2);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final int code;
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package mc.protocol.utils;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum EntityActionAction {
|
|
||||||
START_SNEAKING(0),
|
|
||||||
STOP_SNEAKING(1),
|
|
||||||
LEAVE_BED(2),
|
|
||||||
START_SPRINTING(3),
|
|
||||||
STOP_SPRINTING(4),
|
|
||||||
START_JUMP_WITH_HORSE(5),
|
|
||||||
STOP_JUMP_WITH_HORSE(6),
|
|
||||||
OPEN_HORSE_INVENTORY(7),
|
|
||||||
START_FLYING_WITH_ELYTRA(8);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static EntityActionAction valueOfCode(int code) {
|
|
||||||
for (EntityActionAction action : EntityActionAction.values()) {
|
|
||||||
if (action.code == code) {
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int code;
|
|
||||||
}
|
|
||||||
@@ -9,12 +9,14 @@ import mc.protocol.model.Look;
|
|||||||
import mc.protocol.model.ServerInfo;
|
import mc.protocol.model.ServerInfo;
|
||||||
import mc.protocol.model.text.Text;
|
import mc.protocol.model.text.Text;
|
||||||
import mc.protocol.model.text.TextColor;
|
import mc.protocol.model.text.TextColor;
|
||||||
|
import mc.protocol.model.text.TextStyleLegacy;
|
||||||
import mc.protocol.packets.PingPacket;
|
import mc.protocol.packets.PingPacket;
|
||||||
import mc.protocol.packets.client.HandshakePacket;
|
import mc.protocol.packets.client.HandshakePacket;
|
||||||
import mc.protocol.packets.client.LoginStartPacket;
|
import mc.protocol.packets.client.LoginStartPacket;
|
||||||
import mc.protocol.packets.client.StatusServerRequestPacket;
|
import mc.protocol.packets.client.StatusServerRequestPacket;
|
||||||
import mc.protocol.packets.server.*;
|
import mc.protocol.packets.server.*;
|
||||||
import mc.protocol.serializer.TextSerializer;
|
import mc.protocol.serializer.TextSerializer;
|
||||||
|
import mc.protocol.utils.ChatPosition;
|
||||||
import mc.protocol.utils.Difficulty;
|
import mc.protocol.utils.Difficulty;
|
||||||
import mc.protocol.utils.GameMode;
|
import mc.protocol.utils.GameMode;
|
||||||
import mc.protocol.utils.LevelType;
|
import mc.protocol.utils.LevelType;
|
||||||
@@ -70,20 +72,16 @@ public class PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onLoginStart(ConnectionContext context, LoginStartPacket loginStartPacket) {
|
public void onLoginStart(ConnectionContext context, LoginStartPacket loginStartPacket) {
|
||||||
var playerUuid = UUID.randomUUID();
|
|
||||||
var playerName = loginStartPacket.getName();
|
|
||||||
var playerGamemode = GameMode.SURVIVAL;
|
|
||||||
|
|
||||||
var loginSuccessPacket = new LoginSuccessPacket();
|
var loginSuccessPacket = new LoginSuccessPacket();
|
||||||
loginSuccessPacket.setUuid(playerUuid);
|
loginSuccessPacket.setUuid(UUID.randomUUID());
|
||||||
loginSuccessPacket.setName(playerName);
|
loginSuccessPacket.setName(loginStartPacket.getName());
|
||||||
|
|
||||||
context.sendNow(loginSuccessPacket);
|
context.sendNow(loginSuccessPacket);
|
||||||
context.setState(State.PLAY);
|
context.setState(State.PLAY);
|
||||||
|
|
||||||
var joinGamePacket = new JoinGamePacket();
|
var joinGamePacket = new JoinGamePacket();
|
||||||
joinGamePacket.setEntityId(random.nextInt());
|
joinGamePacket.setEntityId(random.nextInt());
|
||||||
joinGamePacket.setGameMode(playerGamemode);
|
joinGamePacket.setGameMode(GameMode.SURVIVAL);
|
||||||
joinGamePacket.setDimension(0/*Overworld*/);
|
joinGamePacket.setDimension(0/*Overworld*/);
|
||||||
joinGamePacket.setDifficulty(Difficulty.PEACEFUL);
|
joinGamePacket.setDifficulty(Difficulty.PEACEFUL);
|
||||||
joinGamePacket.setLevelType(LevelType.FLAT);
|
joinGamePacket.setLevelType(LevelType.FLAT);
|
||||||
@@ -131,28 +129,23 @@ public class PacketHandler {
|
|||||||
|
|
||||||
// -- Эксперименты -- //
|
// -- Эксперименты -- //
|
||||||
|
|
||||||
var playerListItemPacket = new PlayerListItemPacket();
|
var chatPacket = new SChatPacket();
|
||||||
playerListItemPacket.setAction(PlayerListItemPacket.Action.ADD_PLAYER);
|
chatPacket.setMessage(Text.of(TextColor.RED.toLegacy() + "== Hello! =="));
|
||||||
playerListItemPacket.getPlayerItems().add(PlayerListItemPacket.PlayerItem.builder()
|
chatPacket.setPosition(ChatPosition.CHAT);
|
||||||
.uuid(playerUuid)
|
|
||||||
.name(playerName)
|
|
||||||
.gamemode(playerGamemode)
|
|
||||||
.ping(100)
|
|
||||||
.hasDisplayName(false)
|
|
||||||
.build());
|
|
||||||
|
|
||||||
context.send(playerListItemPacket);
|
context.send(chatPacket);
|
||||||
|
|
||||||
var playerListHeaderAndFooterPacket = new PlayerListHeaderAndFooterPacket();
|
var systemChatPacket = new SChatPacket();
|
||||||
playerListHeaderAndFooterPacket.setHeader(Text.builder()
|
systemChatPacket.setMessage(Text.of(TextColor.RED.toLegacy() + "[SYSTEM]"));
|
||||||
.append("") //TODO bug component
|
systemChatPacket.setPosition(ChatPosition.SYSTEM);
|
||||||
.append(Text.of(TextColor.GREEN, "==="))
|
|
||||||
.append(Text.of(TextColor.RED, " MC-PROJECT "))
|
|
||||||
.append(Text.of(TextColor.GREEN, "==="))
|
|
||||||
.build());
|
|
||||||
playerListHeaderAndFooterPacket.setFoother(Text.of(TextColor.GRAY, "develop by DmitriyMX"));
|
|
||||||
|
|
||||||
context.send(playerListHeaderAndFooterPacket);
|
context.send(systemChatPacket);
|
||||||
|
|
||||||
|
var hotbarChatPacket = new SChatPacket();
|
||||||
|
hotbarChatPacket.setMessage(Text.of(TextColor.RED.toLegacy() + TextStyleLegacy.BOLD.toLegacy() + "In game info"));
|
||||||
|
hotbarChatPacket.setPosition(ChatPosition.HOTBAR);
|
||||||
|
|
||||||
|
context.send(hotbarChatPacket);
|
||||||
|
|
||||||
context.flushSending();
|
context.flushSending();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user