mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-13 09:11:03 -05:00
Add support for 20w21a
This commit is contained in:
parent
81de9b4577
commit
00fc4c605a
6 changed files with 42 additions and 13 deletions
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<groupId>com.github.steveice10</groupId>
|
<groupId>com.github.steveice10</groupId>
|
||||||
<artifactId>mcprotocollib</artifactId>
|
<artifactId>mcprotocollib</artifactId>
|
||||||
<version>20w20b-SNAPSHOT</version>
|
<version>20w21a-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MCProtocolLib</name>
|
<name>MCProtocolLib</name>
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.github.steveice10.mc.protocol;
|
||||||
|
|
||||||
public class MinecraftConstants {
|
public class MinecraftConstants {
|
||||||
// General Constants
|
// General Constants
|
||||||
public static final String GAME_VERSION = "20w20b";
|
public static final String GAME_VERSION = "20w21a";
|
||||||
public static final int PROTOCOL_VERSION = 717;
|
public static final int PROTOCOL_VERSION = 718;
|
||||||
|
|
||||||
// General Key Constants
|
// General Key Constants
|
||||||
public static final String PROFILE_KEY = "profile";
|
public static final String PROFILE_KEY = "profile";
|
||||||
|
|
|
@ -14,6 +14,7 @@ import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Setter(AccessLevel.NONE)
|
@Setter(AccessLevel.NONE)
|
||||||
|
@ -22,6 +23,7 @@ import java.io.IOException;
|
||||||
public class ServerChatPacket implements Packet {
|
public class ServerChatPacket implements Packet {
|
||||||
private @NonNull Message message;
|
private @NonNull Message message;
|
||||||
private @NonNull MessageType type;
|
private @NonNull MessageType type;
|
||||||
|
private @NonNull UUID senderUuid;
|
||||||
|
|
||||||
public ServerChatPacket(@NonNull String text) {
|
public ServerChatPacket(@NonNull String text) {
|
||||||
this(Message.fromString(text));
|
this(Message.fromString(text));
|
||||||
|
@ -32,19 +34,29 @@ public class ServerChatPacket implements Packet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerChatPacket(@NonNull String text, @NonNull MessageType type) {
|
public ServerChatPacket(@NonNull String text, @NonNull MessageType type) {
|
||||||
this(Message.fromString(text), type);
|
this(Message.fromString(text), type, new UUID(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerChatPacket(@NonNull Message message, @NonNull MessageType type) {
|
||||||
|
this(message, type, new UUID(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerChatPacket(@NonNull String text, @NonNull MessageType type, UUID uuid) {
|
||||||
|
this(Message.fromString(text), type, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(NetInput in) throws IOException {
|
public void read(NetInput in) throws IOException {
|
||||||
this.message = Message.fromString(in.readString());
|
this.message = Message.fromString(in.readString());
|
||||||
this.type = MagicValues.key(MessageType.class, in.readByte());
|
this.type = MagicValues.key(MessageType.class, in.readByte());
|
||||||
|
this.senderUuid = in.readUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(NetOutput out) throws IOException {
|
public void write(NetOutput out) throws IOException {
|
||||||
out.writeString(this.message.toJsonString());
|
out.writeString(this.message.toJsonString());
|
||||||
out.writeByte(MagicValues.value(Integer.class, this.type));
|
out.writeByte(MagicValues.value(Integer.class, this.type));
|
||||||
|
out.writeUUID(this.senderUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.NBT;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.packetlib.io.NetInput;
|
import com.github.steveice10.packetlib.io.NetInput;
|
||||||
import com.github.steveice10.packetlib.io.NetOutput;
|
import com.github.steveice10.packetlib.io.NetOutput;
|
||||||
import com.github.steveice10.packetlib.packet.Packet;
|
import com.github.steveice10.packetlib.packet.Packet;
|
||||||
|
@ -25,7 +27,8 @@ public class ServerJoinGamePacket implements Packet {
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private boolean hardcore;
|
private boolean hardcore;
|
||||||
private @NonNull GameMode gameMode;
|
private @NonNull GameMode gameMode;
|
||||||
private int dimension;
|
private @NonNull CompoundTag dimensionCodec;
|
||||||
|
private @NonNull String dimension;
|
||||||
private long hashedSeed;
|
private long hashedSeed;
|
||||||
private int maxPlayers;
|
private int maxPlayers;
|
||||||
private int viewDistance;
|
private int viewDistance;
|
||||||
|
@ -41,8 +44,8 @@ public class ServerJoinGamePacket implements Packet {
|
||||||
int gameMode = in.readUnsignedByte();
|
int gameMode = in.readUnsignedByte();
|
||||||
this.hardcore = (gameMode & GAMEMODE_FLAG_HARDCORE) != 0;
|
this.hardcore = (gameMode & GAMEMODE_FLAG_HARDCORE) != 0;
|
||||||
this.gameMode = MagicValues.key(GameMode.class, gameMode & GAMEMODE_MASK);
|
this.gameMode = MagicValues.key(GameMode.class, gameMode & GAMEMODE_MASK);
|
||||||
|
this.dimensionCodec = NBT.read(in);
|
||||||
this.dimension = in.readInt();
|
this.dimension = in.readString();
|
||||||
this.hashedSeed = in.readLong();
|
this.hashedSeed = in.readLong();
|
||||||
this.maxPlayers = in.readUnsignedByte();
|
this.maxPlayers = in.readUnsignedByte();
|
||||||
this.viewDistance = in.readVarInt();
|
this.viewDistance = in.readVarInt();
|
||||||
|
@ -62,8 +65,8 @@ public class ServerJoinGamePacket implements Packet {
|
||||||
}
|
}
|
||||||
|
|
||||||
out.writeByte(gameMode);
|
out.writeByte(gameMode);
|
||||||
|
NBT.write(out, this.dimensionCodec);
|
||||||
out.writeInt(this.dimension);
|
out.writeString(this.dimension);
|
||||||
out.writeLong(this.hashedSeed);
|
out.writeLong(this.hashedSeed);
|
||||||
out.writeByte(this.maxPlayers);
|
out.writeByte(this.maxPlayers);
|
||||||
out.writeVarInt(this.viewDistance);
|
out.writeVarInt(this.viewDistance);
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.io.IOException;
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ServerRespawnPacket implements Packet {
|
public class ServerRespawnPacket implements Packet {
|
||||||
private int dimension;
|
private String dimension;
|
||||||
private long hashedSeed;
|
private long hashedSeed;
|
||||||
private @NonNull GameMode gamemode;
|
private @NonNull GameMode gamemode;
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
|
@ -28,7 +28,7 @@ public class ServerRespawnPacket implements Packet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(NetInput in) throws IOException {
|
public void read(NetInput in) throws IOException {
|
||||||
this.dimension = in.readInt();
|
this.dimension = in.readString();
|
||||||
this.hashedSeed = in.readLong();
|
this.hashedSeed = in.readLong();
|
||||||
this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte());
|
this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte());
|
||||||
this.debug = in.readBoolean();
|
this.debug = in.readBoolean();
|
||||||
|
@ -38,7 +38,7 @@ public class ServerRespawnPacket implements Packet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(NetOutput out) throws IOException {
|
public void write(NetOutput out) throws IOException {
|
||||||
out.writeInt(this.dimension);
|
out.writeString(this.dimension);
|
||||||
out.writeLong(this.hashedSeed);
|
out.writeLong(this.hashedSeed);
|
||||||
out.writeByte(MagicValues.value(Integer.class, this.gamemode));
|
out.writeByte(MagicValues.value(Integer.class, this.gamemode));
|
||||||
out.writeBoolean(this.debug);
|
out.writeBoolean(this.debug);
|
||||||
|
|
|
@ -9,6 +9,9 @@ import com.github.steveice10.mc.protocol.data.status.VersionInfo;
|
||||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
|
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
|
||||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
|
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.packetlib.Client;
|
import com.github.steveice10.packetlib.Client;
|
||||||
import com.github.steveice10.packetlib.Server;
|
import com.github.steveice10.packetlib.Server;
|
||||||
import com.github.steveice10.packetlib.Session;
|
import com.github.steveice10.packetlib.Session;
|
||||||
|
@ -44,7 +47,7 @@ public class MinecraftProtocolTest {
|
||||||
new TextMessage("Hello world!"),
|
new TextMessage("Hello world!"),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 0, 100, 0, 16, false, false, false, false);
|
private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, getDimensionTag(), "minecraft:overworld", 100, 0, 16, false, false, false, false);
|
||||||
|
|
||||||
private static Server server;
|
private static Server server;
|
||||||
|
|
||||||
|
@ -139,4 +142,15 @@ public class MinecraftProtocolTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static CompoundTag getDimensionTag() {
|
||||||
|
CompoundTag tag = new CompoundTag("");
|
||||||
|
ListTag dimensionTag = new ListTag("dimension");
|
||||||
|
CompoundTag overworldTag = new CompoundTag("");
|
||||||
|
overworldTag.put(new StringTag("key", "minecraft:overworld"));
|
||||||
|
overworldTag.put(new StringTag("element", "minecraft:overworld"));
|
||||||
|
dimensionTag.add(overworldTag);
|
||||||
|
tag.put(tag);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue