Support 1.20

This commit is contained in:
Pantera (Mad_Daniel) 2023-05-15 10:56:09 +09:00 committed by GitHub
parent dbeb7cc037
commit 0ddac89204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2827 additions and 22 deletions

View File

@ -20,13 +20,13 @@ repositories {
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
implementation 'org.spongepowered:configurate-yaml:4.1.2'
implementation 'io.netty:netty-all:4.1.85.Final'
implementation 'net.kyori:adventure-nbt:4.12.0'
implementation 'com.grack:nanojson:1.7'
implementation 'io.netty:netty-all:4.1.92.Final'
implementation 'net.kyori:adventure-nbt:4.13.1'
implementation 'com.grack:nanojson:1.8'
}
shadowJar {

View File

@ -201,7 +201,7 @@ public class PacketJoinGame implements PacketOut {
msg.writeBoolean(isFlat);
}
if (version.moreOrEqual(Version.V1_19)) {
if (version.fromTo(Version.V1_19, Version.V1_19_4)) {
msg.writeBoolean(isHardcore);
msg.writeByte(gameMode);
msg.writeByte(previousGameMode);
@ -229,6 +229,26 @@ public class PacketJoinGame implements PacketOut {
msg.writeBoolean(isFlat);
msg.writeBoolean(false);
}
if (version.moreOrEqual(Version.V1_20)) {
msg.writeBoolean(isHardcore);
msg.writeByte(gameMode);
msg.writeByte(previousGameMode);
msg.writeStringsArray(worldNames);
msg.writeCompoundTag(dimensionRegistry.getCodec_1_20());
msg.writeString(worldName); // World type
msg.writeString(worldName);
msg.writeLong(hashedSeed);
msg.writeVarInt(maxPlayers);
msg.writeVarInt(viewDistance);
msg.writeVarInt(viewDistance); // Simulation Distance
msg.writeBoolean(reducedDebugInfo);
msg.writeBoolean(enableRespawnScreen);
msg.writeBoolean(isDebug);
msg.writeBoolean(isFlat);
msg.writeBoolean(false);
msg.writeVarInt(0);
}
}
}

View File

@ -88,7 +88,7 @@ public enum State {
map(0x11, V1_19, V1_19),
map(0x12, V1_19_1, V1_19_1),
map(0x11, V1_19_3, V1_19_3),
map(0x12, V1_19_4, V1_19_4)
map(0x12, V1_19_4, V1_20)
);
clientBound.register(PacketDeclareCommands::new,
@ -99,7 +99,7 @@ public enum State {
map(0x12, V1_17, V1_18_2),
map(0x0F, V1_19, V1_19_1),
map(0x0E, V1_19_3, V1_19_3),
map(0x10, V1_19_4, V1_19_4)
map(0x10, V1_19_4, V1_20)
);
clientBound.register(PacketJoinGame::new,
map(0x01, V1_7_2, V1_8),
@ -112,7 +112,7 @@ public enum State {
map(0x23, V1_19, V1_19),
map(0x25, V1_19_1, V1_19_1),
map(0x24, V1_19_3, V1_19_3),
map(0x28, V1_19_4, V1_19_4)
map(0x28, V1_19_4, V1_20)
);
clientBound.register(PacketPluginMessage::new,
map(0x19, V1_13, V1_13_2),
@ -124,7 +124,7 @@ public enum State {
map(0x15, V1_19, V1_19),
map(0x16, V1_19_1, V1_19_1),
map(0x15, V1_19_3, V1_19_3),
map(0x17, V1_19_4, V1_19_4)
map(0x17, V1_19_4, V1_20)
);
clientBound.register(PacketPlayerAbilities::new,
map(0x39, V1_7_2, V1_8),
@ -139,7 +139,7 @@ public enum State {
map(0x2F, V1_19, V1_19),
map(0x31, V1_19_1, V1_19_1),
map(0x30, V1_19_3, V1_19_3),
map(0x34, V1_19_4, V1_19_4)
map(0x34, V1_19_4, V1_20)
);
clientBound.register(PacketPlayerPositionAndLook::new,
map(0x08, V1_7_2, V1_8),
@ -154,7 +154,7 @@ public enum State {
map(0x36, V1_19, V1_19),
map(0x39, V1_19_1, V1_19_1),
map(0x38, V1_19_3, V1_19_3),
map(0x3C, V1_19_4, V1_19_4)
map(0x3C, V1_19_4, V1_20)
);
clientBound.register(PacketKeepAlive::new,
map(0x00, V1_7_2, V1_8),
@ -168,7 +168,7 @@ public enum State {
map(0x1E, V1_19, V1_19),
map(0x20, V1_19_1, V1_19_1),
map(0x1F, V1_19_3, V1_19_3),
map(0x23, V1_19_4, V1_19_4)
map(0x23, V1_19_4, V1_20)
);
clientBound.register(PacketChatMessage::new,
map(0x02, V1_7_2, V1_8),
@ -180,7 +180,7 @@ public enum State {
map(0x5F, V1_19, V1_19),
map(0x62, V1_19_1, V1_19_1),
map(0x60, V1_19_3, V1_19_3),
map(0x64, V1_19_4, V1_19_4)
map(0x64, V1_19_4, V1_20)
);
clientBound.register(PacketBossBar::new,
map(0x0C, V1_9, V1_14_4),
@ -188,7 +188,7 @@ public enum State {
map(0x0C, V1_16, V1_16_4),
map(0x0D, V1_17, V1_18_2),
map(0x0A, V1_19, V1_19_3),
map(0x0B, V1_19_4, V1_19_4)
map(0x0B, V1_19_4, V1_20)
);
clientBound.register(PacketPlayerInfo::new,
map(0x38, V1_7_2, V1_8),
@ -203,7 +203,7 @@ public enum State {
map(0x34, V1_19, V1_19),
map(0x37, V1_19_1, V1_19_1),
map(0x36, V1_19_3, V1_19_3),
map(0x3A, V1_19_4, V1_19_4)
map(0x3A, V1_19_4, V1_20)
);
clientBound.register(PacketTitleLegacy::new,
map(0x45, V1_8, V1_11_1),
@ -219,21 +219,21 @@ public enum State {
map(0x5A, V1_18, V1_19),
map(0x5D, V1_19_1, V1_19_1),
map(0x5B, V1_19_3, V1_19_3),
map(0x5F, V1_19_4, V1_19_4)
map(0x5F, V1_19_4, V1_20)
);
clientBound.register(PacketTitleSetSubTitle::new,
map(0x57, V1_17, V1_17_1),
map(0x58, V1_18, V1_19),
map(0x5B, V1_19_1, V1_19_1),
map(0x59, V1_19_3, V1_19_3),
map(0x5D, V1_19_4, V1_19_4)
map(0x5D, V1_19_4, V1_20)
);
clientBound.register(PacketTitleTimes::new,
map(0x5A, V1_17, V1_17_1),
map(0x5B, V1_18, V1_19),
map(0x5E, V1_19_1, V1_19_1),
map(0x5C, V1_19_3, V1_19_3),
map(0x60, V1_19_4, V1_19_4)
map(0x60, V1_19_4, V1_20)
);
clientBound.register(PacketPlayerListHeader::new,
map(0x47, V1_8, V1_8),
@ -250,11 +250,11 @@ public enum State {
map(0x60, V1_19, V1_19),
map(0x63, V1_19_1, V1_19_1),
map(0x61, V1_19_3, V1_19_3),
map(0x65, V1_19_4, V1_19_4)
map(0x65, V1_19_4, V1_20)
);
clientBound.register(PacketSpawnPosition::new,
map(0x4C, V1_19_3, V1_19_3),
map(0x50, V1_19_4, V1_19_4)
map(0x50, V1_19_4, V1_20)
);
}
};

View File

@ -67,7 +67,8 @@ public enum Version {
V1_19_1(760),
// 1.19.2 has same protocol number
V1_19_3(761),
V1_19_4(762);
V1_19_4(762),
V1_20(763);
private static final Map<Integer, Version> VERSION_MAP;
private static final Version MAX;

View File

@ -39,6 +39,7 @@ public final class DimensionRegistry {
private CompoundBinaryTag codec_1_19;
private CompoundBinaryTag codec_1_19_1;
private CompoundBinaryTag codec_1_19_4;
private CompoundBinaryTag codec_1_20;
private CompoundBinaryTag oldCodec;
public DimensionRegistry(LimboServer server) {
@ -65,6 +66,10 @@ public final class DimensionRegistry {
return codec_1_19_4;
}
public CompoundBinaryTag getCodec_1_20() {
return codec_1_20;
}
public CompoundBinaryTag getOldCodec() {
return oldCodec;
}
@ -83,6 +88,7 @@ public final class DimensionRegistry {
codec_1_19 = readCodecFile("/dimension/codec_1_19.snbt");
codec_1_19_1 = readCodecFile("/dimension/codec_1_19_1.snbt");
codec_1_19_4 = readCodecFile("/dimension/codec_1_19_4.snbt");
codec_1_20 = readCodecFile("/dimension/codec_1_20.snbt");
// On 1.16-1.16.1 different codec format
oldCodec = readCodecFile("/dimension/codec_old.snbt");

File diff suppressed because it is too large Load Diff