3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Snapshot 20w21a

Dieser Commit ist enthalten in:
Five (Xer) 2020-05-23 00:18:36 +02:00
Ursprung 10680f16d3
Commit d37b6a361c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F306B10E6330E7
10 geänderte Dateien mit 281 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -34,7 +34,8 @@ public enum ProtocolVersion {
MINECRAFT_1_14_4(498, "1.14.4"), MINECRAFT_1_14_4(498, "1.14.4"),
MINECRAFT_1_15(573, "1.15"), MINECRAFT_1_15(573, "1.15"),
MINECRAFT_1_15_1(575, "1.15.1"), MINECRAFT_1_15_1(575, "1.15.1"),
MINECRAFT_1_15_2(578, "1.15.2"); MINECRAFT_1_15_2(578, "1.15.2"),
MINECRAFT_1_16(718, "1.16");
private final int protocol; private final int protocol;
private final String name; private final String name;

Datei anzeigen

@ -63,6 +63,7 @@ dependencies {
compile 'it.unimi.dsi:fastutil:8.2.2' compile 'it.unimi.dsi:fastutil:8.2.2'
compile 'net.kyori:event-method-asm:3.0.0' compile 'net.kyori:event-method-asm:3.0.0'
compile 'net.kyori:nbt:1.12-1.0.0-SNAPSHOT'
compile 'com.mojang:brigadier:1.0.17' compile 'com.mojang:brigadier:1.0.17'

Datei anzeigen

@ -337,10 +337,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
int tempDim = joinGame.getDimension() == 0 ? -1 : 0; int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
player.getMinecraftConnection().delayedWrite( player.getMinecraftConnection().delayedWrite(
new Respawn(tempDim, joinGame.getPartialHashedSeed(), joinGame.getDifficulty(), new Respawn(tempDim, joinGame.getPartialHashedSeed(), joinGame.getDifficulty(),
joinGame.getGamemode(), joinGame.getLevelType())); joinGame.getGamemode(), joinGame.getLevelType(), joinGame.getShouldKeepPlayerData(),
joinGame.getIsDebug(), joinGame.getIsFlat(),
joinGame.getDimensionRegistryName()));
player.getMinecraftConnection().delayedWrite( player.getMinecraftConnection().delayedWrite(
new Respawn(joinGame.getDimension(), joinGame.getPartialHashedSeed(), new Respawn(joinGame.getDimension(), joinGame.getPartialHashedSeed(),
joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType())); joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType(),
joinGame.getShouldKeepPlayerData(), joinGame.getIsDebug(), joinGame.getIsFlat(),
joinGame.getDimensionRegistryName()));
} }
// Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to // Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to

Datei anzeigen

@ -6,13 +6,20 @@ import static com.google.common.base.Preconditions.checkState;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.GameProfile;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.ByteBufUtil; import io.netty.buffer.ByteBufUtil;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import net.kyori.nbt.CompoundTag;
public enum ProtocolUtils { public enum ProtocolUtils {
; ;
private static final int DEFAULT_MAX_STRING_SIZE = 65536; // 64KiB private static final int DEFAULT_MAX_STRING_SIZE = 65536; // 64KiB
@ -153,6 +160,81 @@ public enum ProtocolUtils {
buf.writeLong(uuid.getLeastSignificantBits()); buf.writeLong(uuid.getLeastSignificantBits());
} }
/**
* Reads an UUID stored as an Integer Array from the {@code buf}.
* @param buf the buffer to read from
* @return the UUID from the buffer
*/
public static UUID readUuidIntArray(ByteBuf buf) {
long msbHigh = (long) buf.readInt() << 32;
long msbLow = (long) buf.readInt() & 0xFFFFFFFFL;
long msb = msbHigh | msbLow;
long lsbHigh = (long) buf.readInt() << 32;
long lsbLow = (long) buf.readInt() & 0xFFFFFFFFL;
long lsb = lsbHigh | lsbLow;
return new UUID(msb, lsb);
}
/**
* Writes an UUID as an Integer Array to the {@code buf}.
* @param buf the buffer to write to
* @param uuid the UUID to write
*/
public static void writeUuidIntArray(ByteBuf buf, UUID uuid) {
buf.writeInt((int) (uuid.getMostSignificantBits() >> 32));
buf.writeInt((int) uuid.getMostSignificantBits());
buf.writeInt((int) (uuid.getLeastSignificantBits() >> 32));
buf.writeInt((int) uuid.getLeastSignificantBits());
}
/**
* Reads a {@link net.kyori.nbt.CompoundTag} from the {@code buf}.
* @param buf the buffer to read from
* @return {@link net.kyori.nbt.CompoundTag} the CompoundTag from the buffer
*/
public static CompoundTag readCompoundTag(ByteBuf buf) {
int indexBefore = buf.readerIndex();
byte startType = buf.readByte();
if (startType == 0) {
return null;
} else {
buf.readerIndex(indexBefore);
try {
DataInput input = new ByteBufInputStream(buf);
byte type = input.readByte();
if (type != 10) {
return null;
}
input.readUTF();
CompoundTag ret = new CompoundTag();
ret.read(input, 0);
return ret;
} catch (IOException e) {
return null;
}
}
}
/**
* Writes a CompoundTag to the {@code buf}.
* @param buf the buffer to write to
* @param compoundTag the CompoundTag to write
*/
public static void writeCompoundTag(ByteBuf buf, CompoundTag compoundTag) {
if (compoundTag == null) {
buf.writeByte(0);
} else {
try {
DataOutput output = new ByteBufOutputStream(buf);
output.writeByte(10);
output.writeUTF("");
compoundTag.write(output);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/** /**
* Writes a list of {@link com.velocitypowered.api.util.GameProfile.Property} to the buffer. * Writes a list of {@link com.velocitypowered.api.util.GameProfile.Property} to the buffer.
* @param buf the buffer to write to * @param buf the buffer to write to

Datei anzeigen

@ -6,6 +6,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_12_1;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_15; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_15;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4;
@ -113,13 +114,15 @@ public enum StateRegistry {
map(0x0C, MINECRAFT_1_12, false), map(0x0C, MINECRAFT_1_12, false),
map(0x0B, MINECRAFT_1_12_1, false), map(0x0B, MINECRAFT_1_12_1, false),
map(0x0E, MINECRAFT_1_13, false), map(0x0E, MINECRAFT_1_13, false),
map(0x0F, MINECRAFT_1_14, false)); map(0x0F, MINECRAFT_1_14, false),
map(0x10, MINECRAFT_1_16, false));
serverbound.register(ResourcePackResponse.class, ResourcePackResponse::new, serverbound.register(ResourcePackResponse.class, ResourcePackResponse::new,
map(0x19, MINECRAFT_1_8, false), map(0x19, MINECRAFT_1_8, false),
map(0x16, MINECRAFT_1_9, false), map(0x16, MINECRAFT_1_9, false),
map(0x18, MINECRAFT_1_12, false), map(0x18, MINECRAFT_1_12, false),
map(0x1D, MINECRAFT_1_13, false), map(0x1D, MINECRAFT_1_13, false),
map(0x1F, MINECRAFT_1_14, false)); map(0x1F, MINECRAFT_1_14, false),
map(0x20, MINECRAFT_1_16, false));
clientbound.register(BossBar.class, BossBar::new, clientbound.register(BossBar.class, BossBar::new,
map(0x0C, MINECRAFT_1_9, false), map(0x0C, MINECRAFT_1_9, false),

Datei anzeigen

@ -10,20 +10,25 @@ import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer; import net.kyori.text.serializer.gson.GsonComponentSerializer;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID;
public class Chat implements MinecraftPacket { public class Chat implements MinecraftPacket {
public static final byte CHAT_TYPE = (byte) 0; public static final byte CHAT_TYPE = (byte) 0;
public static final int MAX_SERVERBOUND_MESSAGE_LENGTH = 256; public static final int MAX_SERVERBOUND_MESSAGE_LENGTH = 256;
public static final UUID EMPTY_SENDER = new UUID(0, 0);
private @Nullable String message; private @Nullable String message;
private byte type; private byte type;
private UUID sender;
public Chat() { public Chat() {
} }
public Chat(String message, byte type) { public Chat(String message, byte type, UUID sender) {
this.message = message; this.message = message;
this.type = type; this.type = type;
this.sender = sender;
} }
public String getMessage() { public String getMessage() {
@ -45,11 +50,20 @@ public class Chat implements MinecraftPacket {
this.type = type; this.type = type;
} }
public UUID getSenderUuid() {
return sender;
}
public void setSenderUuid(UUID sender) {
this.sender = sender;
}
@Override @Override
public String toString() { public String toString() {
return "Chat{" return "Chat{"
+ "message='" + message + '\'' + "message='" + message + '\''
+ ", type=" + type + ", type=" + type
+ ", sender=" + sender
+ '}'; + '}';
} }
@ -58,6 +72,9 @@ public class Chat implements MinecraftPacket {
message = ProtocolUtils.readString(buf); message = ProtocolUtils.readString(buf);
if (direction == ProtocolUtils.Direction.CLIENTBOUND) { if (direction == ProtocolUtils.Direction.CLIENTBOUND) {
type = buf.readByte(); type = buf.readByte();
if(version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
sender = ProtocolUtils.readUuid(buf);
}
} }
} }
@ -69,6 +86,9 @@ public class Chat implements MinecraftPacket {
ProtocolUtils.writeString(buf, message); ProtocolUtils.writeString(buf, message);
if (direction == ProtocolUtils.Direction.CLIENTBOUND) { if (direction == ProtocolUtils.Direction.CLIENTBOUND) {
buf.writeByte(type); buf.writeByte(type);
if(version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
ProtocolUtils.writeUuid(buf, sender == null ? new UUID(0,0) : sender);
}
} }
} }
@ -78,15 +98,15 @@ public class Chat implements MinecraftPacket {
} }
public static Chat createClientbound(Component component) { public static Chat createClientbound(Component component) {
return createClientbound(component, CHAT_TYPE); return createClientbound(component, CHAT_TYPE, EMPTY_SENDER);
} }
public static Chat createClientbound(Component component, byte type) { public static Chat createClientbound(Component component, byte type, UUID sender) {
Preconditions.checkNotNull(component, "component"); Preconditions.checkNotNull(component, "component");
return new Chat(GsonComponentSerializer.INSTANCE.serialize(component), type); return new Chat(GsonComponentSerializer.INSTANCE.serialize(component), type, sender);
} }
public static Chat createServerbound(String message) { public static Chat createServerbound(String message) {
return new Chat(message, CHAT_TYPE); return new Chat(message, CHAT_TYPE, EMPTY_SENDER);
} }
} }

Datei anzeigen

@ -5,6 +5,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.kyori.nbt.CompoundTag;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public class JoinGame implements MinecraftPacket { public class JoinGame implements MinecraftPacket {
@ -19,6 +20,11 @@ public class JoinGame implements MinecraftPacket {
private int viewDistance; //1.14+ private int viewDistance; //1.14+
private boolean reducedDebugInfo; private boolean reducedDebugInfo;
private boolean showRespawnScreen; private boolean showRespawnScreen;
private boolean shouldKeepPlayerData;
private boolean isDebug;
private boolean isFlat;
private String dimensionRegistryName;
private CompoundTag dimensionRegistry;
public int getEntityId() { public int getEntityId() {
return entityId; return entityId;
@ -91,6 +97,46 @@ public class JoinGame implements MinecraftPacket {
this.reducedDebugInfo = reducedDebugInfo; this.reducedDebugInfo = reducedDebugInfo;
} }
public boolean getShouldKeepPlayerData() {
return shouldKeepPlayerData;
}
public void setShouldKeepPlayerData(boolean shouldKeepPlayerData) {
this.shouldKeepPlayerData = shouldKeepPlayerData;
}
public boolean getIsDebug() {
return isDebug;
}
public void setIsDebug(boolean isDebug) {
this.isDebug = isDebug;
}
public boolean getIsFlat() {
return isFlat;
}
public void setIsFlat(boolean isFlat) {
this.isFlat = isFlat;
}
public String getDimensionRegistryName() {
return dimensionRegistryName;
}
public void setDimensionRegistryName(String dimensionRegistryName) {
this.dimensionRegistryName = dimensionRegistryName;
}
public CompoundTag getDimensionRegistry() {
return dimensionRegistry;
}
public void setDimensionRegistry(CompoundTag dimensionRegistry) {
this.dimensionRegistry = dimensionRegistry;
}
@Override @Override
public String toString() { public String toString() {
return "JoinGame{" return "JoinGame{"
@ -110,11 +156,16 @@ public class JoinGame implements MinecraftPacket {
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
this.entityId = buf.readInt(); this.entityId = buf.readInt();
this.gamemode = buf.readUnsignedByte(); this.gamemode = buf.readUnsignedByte();
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
this.dimensionRegistry = ProtocolUtils.readCompoundTag(buf);
this.dimensionRegistryName = ProtocolUtils.readString(buf);
} else {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {
this.dimension = buf.readInt(); this.dimension = buf.readInt();
} else { } else {
this.dimension = buf.readByte(); this.dimension = buf.readByte();
} }
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
this.difficulty = buf.readUnsignedByte(); this.difficulty = buf.readUnsignedByte();
} }
@ -122,7 +173,11 @@ public class JoinGame implements MinecraftPacket {
this.partialHashedSeed = buf.readLong(); this.partialHashedSeed = buf.readLong();
} }
this.maxPlayers = buf.readUnsignedByte(); this.maxPlayers = buf.readUnsignedByte();
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
this.levelType = ProtocolUtils.readString(buf, 16); this.levelType = ProtocolUtils.readString(buf, 16);
} else {
this.levelType = "default"; // I didn't have the courage to rework this yet.
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_14) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_14) >= 0) {
this.viewDistance = ProtocolUtils.readVarInt(buf); this.viewDistance = ProtocolUtils.readVarInt(buf);
} }
@ -130,17 +185,26 @@ public class JoinGame implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) {
this.showRespawnScreen = buf.readBoolean(); this.showRespawnScreen = buf.readBoolean();
} }
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
isDebug = buf.readBoolean();
isFlat = buf.readBoolean();
}
} }
@Override @Override
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
buf.writeInt(entityId); buf.writeInt(entityId);
buf.writeByte(gamemode); buf.writeByte(gamemode);
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
ProtocolUtils.writeCompoundTag(buf, dimensionRegistry);
ProtocolUtils.writeString(buf, dimensionRegistryName);
} else {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {
buf.writeInt(dimension); buf.writeInt(dimension);
} else { } else {
buf.writeByte(dimension); buf.writeByte(dimension);
} }
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
buf.writeByte(difficulty); buf.writeByte(difficulty);
} }
@ -148,10 +212,12 @@ public class JoinGame implements MinecraftPacket {
buf.writeLong(partialHashedSeed); buf.writeLong(partialHashedSeed);
} }
buf.writeByte(maxPlayers); buf.writeByte(maxPlayers);
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
if (levelType == null) { if (levelType == null) {
throw new IllegalStateException("No level type specified."); throw new IllegalStateException("No level type specified.");
} }
ProtocolUtils.writeString(buf, levelType); ProtocolUtils.writeString(buf, levelType);
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_14) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_14) >= 0) {
ProtocolUtils.writeVarInt(buf,viewDistance); ProtocolUtils.writeVarInt(buf,viewDistance);
} }
@ -159,6 +225,10 @@ public class JoinGame implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) {
buf.writeBoolean(showRespawnScreen); buf.writeBoolean(showRespawnScreen);
} }
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
buf.writeBoolean(isDebug);
buf.writeBoolean(isFlat);
}
} }
@Override @Override

Datei anzeigen

@ -13,17 +13,25 @@ public class Respawn implements MinecraftPacket {
private short difficulty; private short difficulty;
private short gamemode; private short gamemode;
private String levelType = ""; private String levelType = "";
private boolean shouldKeepPlayerData;
private boolean isDebug;
private boolean isFlat;
private String dimensionRegistryName;
public Respawn() { public Respawn() {
} }
public Respawn(int dimension, long partialHashedSeed, short difficulty, short gamemode, public Respawn(int dimension, long partialHashedSeed, short difficulty, short gamemode,
String levelType) { String levelType, boolean shouldKeepPlayerData, boolean isDebug, boolean isFlat, String dimensionRegistryName) {
this.dimension = dimension; this.dimension = dimension;
this.partialHashedSeed = partialHashedSeed; this.partialHashedSeed = partialHashedSeed;
this.difficulty = difficulty; this.difficulty = difficulty;
this.gamemode = gamemode; this.gamemode = gamemode;
this.levelType = levelType; this.levelType = levelType;
this.shouldKeepPlayerData = shouldKeepPlayerData;
this.isDebug = isDebug;
this.isFlat = isFlat;
this.dimensionRegistryName = dimensionRegistryName;
} }
public int getDimension() { public int getDimension() {
@ -66,6 +74,38 @@ public class Respawn implements MinecraftPacket {
this.levelType = levelType; this.levelType = levelType;
} }
public boolean getShouldKeepPlayerData() {
return shouldKeepPlayerData;
}
public void setShouldKeepPlayerData(boolean shouldKeepPlayerData) {
this.shouldKeepPlayerData = shouldKeepPlayerData;
}
public boolean getIsDebug() {
return isDebug;
}
public void setIsDebug(boolean isDebug) {
this.isDebug = isDebug;
}
public boolean getIsFlat() {
return isFlat;
}
public void setIsFlat(boolean isFlat) {
this.isFlat = isFlat;
}
public String getDimensionRegistryName() {
return dimensionRegistryName;
}
public void setDimensionRegistryName(String dimensionRegistryName) {
this.dimensionRegistryName = dimensionRegistryName;
}
@Override @Override
public String toString() { public String toString() {
return "Respawn{" return "Respawn{"
@ -74,12 +114,20 @@ public class Respawn implements MinecraftPacket {
+ ", difficulty=" + difficulty + ", difficulty=" + difficulty
+ ", gamemode=" + gamemode + ", gamemode=" + gamemode
+ ", levelType='" + levelType + '\'' + ", levelType='" + levelType + '\''
+ ", shouldKeepPlayerData=" + shouldKeepPlayerData
+ ", isDebug=" + isDebug
+ ", isFlat='" + isFlat
+ ", dimensionRegistryName='" + dimensionRegistryName + '\''
+ '}'; + '}';
} }
@Override @Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
this.dimensionRegistryName = ProtocolUtils.readString(buf); // Not sure what the cap on that is
} else {
this.dimension = buf.readInt(); this.dimension = buf.readInt();
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
this.difficulty = buf.readUnsignedByte(); this.difficulty = buf.readUnsignedByte();
} }
@ -87,12 +135,22 @@ public class Respawn implements MinecraftPacket {
this.partialHashedSeed = buf.readLong(); this.partialHashedSeed = buf.readLong();
} }
this.gamemode = buf.readUnsignedByte(); this.gamemode = buf.readUnsignedByte();
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
isDebug = buf.readBoolean();
isFlat = buf.readBoolean();
shouldKeepPlayerData = buf.readBoolean();
} else {
this.levelType = ProtocolUtils.readString(buf, 16); this.levelType = ProtocolUtils.readString(buf, 16);
} }
}
@Override @Override
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
ProtocolUtils.writeString(buf, dimensionRegistryName);
} else {
buf.writeInt(dimension); buf.writeInt(dimension);
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
buf.writeByte(difficulty); buf.writeByte(difficulty);
} }
@ -100,8 +158,14 @@ public class Respawn implements MinecraftPacket {
buf.writeLong(partialHashedSeed); buf.writeLong(partialHashedSeed);
} }
buf.writeByte(gamemode); buf.writeByte(gamemode);
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
buf.writeBoolean(isDebug);
buf.writeBoolean(isFlat);
buf.writeBoolean(shouldKeepPlayerData);
} else {
ProtocolUtils.writeString(buf, levelType); ProtocolUtils.writeString(buf, levelType);
} }
}
@Override @Override
public boolean handle(MinecraftSessionHandler handler) { public boolean handle(MinecraftSessionHandler handler) {

Datei anzeigen

@ -45,7 +45,11 @@ public class ServerLoginSuccess implements MinecraftPacket {
@Override @Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
uuid = ProtocolUtils.readUuidIntArray(buf);
} else {
uuid = UUID.fromString(ProtocolUtils.readString(buf, 36)); uuid = UUID.fromString(ProtocolUtils.readString(buf, 36));
}
username = ProtocolUtils.readString(buf, 16); username = ProtocolUtils.readString(buf, 16);
} }
@ -54,7 +58,11 @@ public class ServerLoginSuccess implements MinecraftPacket {
if (uuid == null) { if (uuid == null) {
throw new IllegalStateException("No UUID specified!"); throw new IllegalStateException("No UUID specified!");
} }
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
ProtocolUtils.writeUuidIntArray(buf, uuid);
} else {
ProtocolUtils.writeString(buf, uuid.toString()); ProtocolUtils.writeString(buf, uuid.toString());
}
if (username == null) { if (username == null) {
throw new IllegalStateException("No username specified!"); throw new IllegalStateException("No username specified!");
} }

Datei anzeigen

@ -134,5 +134,6 @@ public class ArgumentPropertyRegistry {
dummy("minecraft:int_range", DUMMY); dummy("minecraft:int_range", DUMMY);
dummy("minecraft:float_range", DUMMY); dummy("minecraft:float_range", DUMMY);
dummy("minecraft:time", DUMMY); // added in 1.14 dummy("minecraft:time", DUMMY); // added in 1.14
dummy("minecraft:uuid", DUMMY);
} }
} }