13
0
geforkt von Mirrors/Velocity

Add 1.8 support

Dieser Commit ist enthalten in:
Desetude 2018-08-06 09:03:44 +01:00
Ursprung 48822fe55c
Commit b4f1d64cb0
4 geänderte Dateien mit 36 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package com.velocitypowered.proxy.protocol;
import java.util.Arrays;
public enum ProtocolConstants { ;
public static final int MINECRAFT_1_8 = 47;
public static final int MINECRAFT_1_9 = 107;
public static final int MINECRAFT_1_9_1 = 108;
public static final int MINECRAFT_1_9_2 = 109;
@ -15,9 +16,10 @@ public enum ProtocolConstants { ;
public static final int MINECRAFT_1_12_2 = 340;
public static final int MINECRAFT_1_13 = 393;
public static final int MINIMUM_GENERIC_VERSION = MINECRAFT_1_9;
public static final int MINIMUM_GENERIC_VERSION = MINECRAFT_1_8;
public static final int[] SUPPORTED_VERSIONS = new int[] {
MINECRAFT_1_8,
MINECRAFT_1_9,
MINECRAFT_1_9_1,
MINECRAFT_1_9_2,

Datei anzeigen

@ -32,21 +32,25 @@ public enum StateRegistry {
PLAY {
{
SERVERBOUND.register(Chat.class, Chat::new,
map(0x01, MINECRAFT_1_8),
map(0x02, MINECRAFT_1_9),
map(0x03, MINECRAFT_1_12),
map(0x02, MINECRAFT_1_12_2),
map(0x02, MINECRAFT_1_13));
SERVERBOUND.register(ClientSettings.class, ClientSettings::new,
map(0x15, MINECRAFT_1_8),
map(0x04, MINECRAFT_1_9),
map(0x05, MINECRAFT_1_12),
map(0x04, MINECRAFT_1_12_1),
map(0x04, MINECRAFT_1_13));
SERVERBOUND.register(PluginMessage.class, PluginMessage::new,
map(0x17, MINECRAFT_1_8),
map(0x09, MINECRAFT_1_9),
map(0x0A, MINECRAFT_1_12),
map(0x09, MINECRAFT_1_12_1),
map(0x0A, MINECRAFT_1_13));
SERVERBOUND.register(KeepAlive.class, KeepAlive::new,
map(0x00, MINECRAFT_1_8),
map(0x0B, MINECRAFT_1_9),
map(0x0C, MINECRAFT_1_12),
map(0x0B, MINECRAFT_1_12_1),
@ -56,46 +60,56 @@ public enum StateRegistry {
map(0x0C, MINECRAFT_1_9),
map(0x0C, MINECRAFT_1_12));
CLIENTBOUND.register(Chat.class, Chat::new,
map(0x02, MINECRAFT_1_8),
map(0x0F, MINECRAFT_1_9),
map(0x0F, MINECRAFT_1_12),
map(0x0E, MINECRAFT_1_13));
CLIENTBOUND.register(PluginMessage.class, PluginMessage::new,
map(0x3F, MINECRAFT_1_8),
map(0x18, MINECRAFT_1_9),
map(0x18, MINECRAFT_1_12),
map(0x19, MINECRAFT_1_13));
CLIENTBOUND.register(Disconnect.class, Disconnect::new,
map(0x40, MINECRAFT_1_8),
map(0x1A, MINECRAFT_1_9),
map(0x1A, MINECRAFT_1_12),
map(0x1B, MINECRAFT_1_13));
CLIENTBOUND.register(KeepAlive.class, KeepAlive::new,
map(0x00, MINECRAFT_1_8),
map(0x1F, MINECRAFT_1_9),
map(0x1F, MINECRAFT_1_12),
map(0x21, MINECRAFT_1_13));
CLIENTBOUND.register(JoinGame.class, JoinGame::new,
map(0x01, MINECRAFT_1_8),
map(0x23, MINECRAFT_1_9),
map(0x23, MINECRAFT_1_12),
map(0x25, MINECRAFT_1_13));
CLIENTBOUND.register(Respawn.class, Respawn::new,
map(0x07, MINECRAFT_1_8),
map(0x33, MINECRAFT_1_9),
map(0x34, MINECRAFT_1_12),
map(0x35, MINECRAFT_1_12_2),
map(0x38, MINECRAFT_1_13));
CLIENTBOUND.register(ScoreboardDisplay.class, ScoreboardDisplay::new,
map(0x3D, MINECRAFT_1_8),
map(0x38, MINECRAFT_1_9),
map(0x3A, MINECRAFT_1_12),
map(0x3B, MINECRAFT_1_12_1),
map(0x3E, MINECRAFT_1_13));
CLIENTBOUND.register(ScoreboardObjective.class, ScoreboardObjective::new,
map(0x3B, MINECRAFT_1_8),
map(0x3F, MINECRAFT_1_9),
map(0x41, MINECRAFT_1_12),
map(0x42, MINECRAFT_1_12_1),
map(0x45, MINECRAFT_1_13));
CLIENTBOUND.register(ScoreboardTeam.class, ScoreboardTeam::new,
map(0x3E, MINECRAFT_1_8),
map(0x41, MINECRAFT_1_9),
map(0x43, MINECRAFT_1_12),
map(0x44, MINECRAFT_1_12_1),
map(0x47, MINECRAFT_1_13));
CLIENTBOUND.register(ScoreboardSetScore.class, ScoreboardSetScore::new,
map(0x3C, MINECRAFT_1_8),
map(0x42, MINECRAFT_1_9),
map(0x44, MINECRAFT_1_12),
map(0x45, MINECRAFT_1_12_1),
@ -266,6 +280,7 @@ public enum StateRegistry {
private static PacketMapping[] genericMappings(int id) {
return new PacketMapping[]{
map(id, MINECRAFT_1_8),
map(id, MINECRAFT_1_9),
map(id, MINECRAFT_1_12),
map(id, MINECRAFT_1_13)

Datei anzeigen

@ -80,8 +80,11 @@ public class ClientSettings implements MinecraftPacket {
this.chatVisibility = ProtocolUtils.readVarInt(buf);
this.chatColors = buf.readBoolean();
this.skinParts = buf.readUnsignedByte();
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_9) {
this.mainHand = ProtocolUtils.readVarInt(buf);
}
}
@Override
public void encode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
@ -90,6 +93,9 @@ public class ClientSettings implements MinecraftPacket {
ProtocolUtils.writeVarInt(buf, chatVisibility);
buf.writeBoolean(chatColors);
buf.writeByte(skinParts);
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_9) {
ProtocolUtils.writeVarInt(buf, mainHand);
}
}
}

Datei anzeigen

@ -87,7 +87,11 @@ public class JoinGame implements MinecraftPacket {
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
this.entityId = buf.readInt();
this.gamemode = buf.readUnsignedByte();
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_9_1) {
this.dimension = buf.readInt();
} else {
this.dimension = buf.readByte();
}
this.difficulty = buf.readUnsignedByte();
this.maxPlayers = buf.readUnsignedByte();
this.levelType = ProtocolUtils.readString(buf, 16);
@ -98,7 +102,11 @@ public class JoinGame implements MinecraftPacket {
public void encode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
buf.writeInt(entityId);
buf.writeByte(gamemode);
if (protocolVersion >= ProtocolConstants.MINECRAFT_1_9_1) {
buf.writeInt(dimension);
} else {
buf.writeByte(dimension);
}
buf.writeByte(difficulty);
buf.writeByte(maxPlayers);
ProtocolUtils.writeString(buf, levelType);