Skip to content

Commit

Permalink
1.19.1 support (#57, #58)
Browse files Browse the repository at this point in the history
* 1.19.1 support

* 1.19.1 block mappings

Co-authored-by: JNNGL <[email protected]>
  • Loading branch information
hevav and JNNGL authored Jul 31, 2022
1 parent 43af4ff commit 9fbc815
Show file tree
Hide file tree
Showing 6 changed files with 20,404 additions and 22 deletions.
2 changes: 1 addition & 1 deletion plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public LimboAPI(Logger logger, ProxyServer server, Metrics.Factory metricsFactor
this.nextServer = new HashMap<>();
this.initialID = new HashMap<>();

if (ProtocolVersion.MAXIMUM_VERSION.getProtocol() < 759) {
if (ProtocolVersion.MAXIMUM_VERSION.getProtocol() < 760) {
LOGGER.error("Please update Velocity (https://papermc.io/downloads#Velocity). LimboAPI support: https://ely.su/discord");
this.server.shutdown();
} else {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/java/net/elytrium/limboapi/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static class MAIN {
"Available versions:",
"1_7_2, 1_7_6, 1_8, 1_9, 1_9_1, 1_9_2, 1_9_4, 1_10, 1_11, 1_11_1, 1_12, 1_12_1, 1_12_2,",
"1_13, 1_13_1, 1_13_2, 1_14, 1_14_1, 1_14_2, 1_14_3, 1_14_4, 1_15, 1_15_1, 1_15_2,",
"1_16, 1_16_1, 1_16_2, 1_16_3, 1_16_4, 1_17, 1_17_1, 1_18, 1_18_2, 1_19, LATEST"
"1_16, 1_16_1, 1_16_2, 1_16_3, 1_16_4, 1_17, 1_17_1, 1_18, 1_18_2, 1_19, 1_19_1, LATEST"
})
public String PREPARE_MIN_VERSION = "1_7_2";
public String PREPARE_MAX_VERSION = "LATEST";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x1E, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x1D, ProtocolVersion.MINECRAFT_1_16_2, true),
createMapping(0x1E, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x1B, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x1B, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x1D, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
ChunkDataPacket.class, ChunkDataPacket::new,
Expand All @@ -182,7 +183,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x21, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x20, ProtocolVersion.MINECRAFT_1_16_2, true),
createMapping(0x22, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x1F, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x1F, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x21, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
DefaultSpawnPositionPacket.class, DefaultSpawnPositionPacket::new,
Expand All @@ -195,7 +197,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x4E, ProtocolVersion.MINECRAFT_1_15, true),
createMapping(0x42, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x4B, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x4A, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x4A, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x4D, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
MapDataPacket.class, MapDataPacket::new,
Expand All @@ -206,7 +209,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x26, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x25, ProtocolVersion.MINECRAFT_1_16_2, true),
createMapping(0x27, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x24, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x24, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x26, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
PlayerAbilitiesPacket.class, PlayerAbilitiesPacket::new,
Expand All @@ -219,7 +223,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x31, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x30, ProtocolVersion.MINECRAFT_1_16_2, true),
createMapping(0x32, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x2F, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x2F, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x31, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
PositionRotationPacket.class, PositionRotationPacket::new,
Expand All @@ -232,7 +237,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x35, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x34, ProtocolVersion.MINECRAFT_1_16_2, true),
createMapping(0x38, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x36, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x36, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x39, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
SetExperiencePacket.class, SetExperiencePacket::new,
Expand All @@ -243,7 +249,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x43, ProtocolVersion.MINECRAFT_1_13, true),
createMapping(0x47, ProtocolVersion.MINECRAFT_1_14, true),
createMapping(0x48, ProtocolVersion.MINECRAFT_1_15, true),
createMapping(0x51, ProtocolVersion.MINECRAFT_1_17, true)
createMapping(0x51, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x54, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
SetSlotPacket.class, SetSlotPacket::new,
Expand All @@ -268,15 +275,17 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x4F, ProtocolVersion.MINECRAFT_1_15, true),
createMapping(0x4E, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x58, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x59, ProtocolVersion.MINECRAFT_1_18, true)
createMapping(0x59, ProtocolVersion.MINECRAFT_1_18, true),
createMapping(0x5C, ProtocolVersion.MINECRAFT_1_19_1, true)
);
register(PacketDirection.CLIENTBOUND,
UpdateViewPositionPacket.class, UpdateViewPositionPacket::new, // ViewCentre, ChunkRenderDistanceCenter
createMapping(0x40, ProtocolVersion.MINECRAFT_1_14, true),
createMapping(0x41, ProtocolVersion.MINECRAFT_1_15, true),
createMapping(0x40, ProtocolVersion.MINECRAFT_1_16, true),
createMapping(0x49, ProtocolVersion.MINECRAFT_1_17, true),
createMapping(0x48, ProtocolVersion.MINECRAFT_1_19, true)
createMapping(0x48, ProtocolVersion.MINECRAFT_1_19, true),
createMapping(0x4B, ProtocolVersion.MINECRAFT_1_19_1, true)
);

register(PacketDirection.SERVERBOUND,
Expand All @@ -289,7 +298,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x12, ProtocolVersion.MINECRAFT_1_14, false),
createMapping(0x13, ProtocolVersion.MINECRAFT_1_16, false),
createMapping(0x12, ProtocolVersion.MINECRAFT_1_17, false),
createMapping(0x14, ProtocolVersion.MINECRAFT_1_19, false)
createMapping(0x14, ProtocolVersion.MINECRAFT_1_19, false),
createMapping(0x15, ProtocolVersion.MINECRAFT_1_19_1, false)
);
register(PacketDirection.SERVERBOUND,
MovePositionOnlyPacket.class, MovePositionOnlyPacket::new,
Expand All @@ -301,7 +311,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x11, ProtocolVersion.MINECRAFT_1_14, false),
createMapping(0x12, ProtocolVersion.MINECRAFT_1_16, false),
createMapping(0x11, ProtocolVersion.MINECRAFT_1_17, false),
createMapping(0x13, ProtocolVersion.MINECRAFT_1_19, false)
createMapping(0x13, ProtocolVersion.MINECRAFT_1_19, false),
createMapping(0x14, ProtocolVersion.MINECRAFT_1_19_1, false)
);
register(PacketDirection.SERVERBOUND,
MoveRotationOnlyPacket.class, MoveRotationOnlyPacket::new,
Expand All @@ -313,7 +324,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x13, ProtocolVersion.MINECRAFT_1_14, false),
createMapping(0x14, ProtocolVersion.MINECRAFT_1_16, false),
createMapping(0x13, ProtocolVersion.MINECRAFT_1_17, false),
createMapping(0x15, ProtocolVersion.MINECRAFT_1_19, false)
createMapping(0x15, ProtocolVersion.MINECRAFT_1_19, false),
createMapping(0x16, ProtocolVersion.MINECRAFT_1_19_1, false)
);
register(PacketDirection.SERVERBOUND,
MoveOnGroundOnlyPacket.class, MoveOnGroundOnlyPacket::new,
Expand All @@ -325,7 +337,8 @@ public static void init() throws ReflectiveOperationException {
createMapping(0x14, ProtocolVersion.MINECRAFT_1_14, false),
createMapping(0x15, ProtocolVersion.MINECRAFT_1_16, false),
createMapping(0x14, ProtocolVersion.MINECRAFT_1_17, false),
createMapping(0x16, ProtocolVersion.MINECRAFT_1_19, false)
createMapping(0x16, ProtocolVersion.MINECRAFT_1_19, false),
createMapping(0x17, ProtocolVersion.MINECRAFT_1_19_1, false)
);
register(PacketDirection.SERVERBOUND,
TeleportConfirmPacket.class, TeleportConfirmPacket::new,
Expand Down
59 changes: 52 additions & 7 deletions plugin/src/main/java/net/elytrium/limboapi/server/LimboImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class LimboImpl implements Limbo {
private static final Field ROOT_NODE_FIELD;

private static final CompoundBinaryTag CHAT_TYPE_119;
private static final CompoundBinaryTag CHAT_TYPE_1191;

private final Map<Class<? extends LimboSessionHandler>, PreparedPacket> brandMessages = new HashMap<>();
private final LimboAPI plugin;
Expand Down Expand Up @@ -135,21 +136,25 @@ public LimboImpl(LimboAPI plugin, VirtualWorld world) {
protected void refresh() {
this.built = true;
JoinGame legacyJoinGame = this.createLegacyJoinGamePacket();
JoinGame joinGame = this.createJoinGamePacket(false);
JoinGame joinGameModern = this.createJoinGamePacket(true);
JoinGame joinGame = this.createJoinGamePacket(false, CHAT_TYPE_119);
JoinGame joinGameModern = this.createJoinGamePacket(true, CHAT_TYPE_119);
JoinGame joinGame1191 = this.createJoinGamePacket(true, CHAT_TYPE_1191);

this.joinPackets = this.plugin.createPreparedPacket()
.prepare(legacyJoinGame, ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MINECRAFT_1_15_2)
.prepare(joinGame, ProtocolVersion.MINECRAFT_1_16, ProtocolVersion.MINECRAFT_1_18)
.prepare(joinGameModern, ProtocolVersion.MINECRAFT_1_18_2);
.prepare(joinGameModern, ProtocolVersion.MINECRAFT_1_18_2, ProtocolVersion.MINECRAFT_1_19)
.prepare(joinGame1191, ProtocolVersion.MINECRAFT_1_19_1);

this.fastRejoinPackets = this.plugin.createPreparedPacket();
this.createFastClientServerSwitch(legacyJoinGame, ProtocolVersion.MINECRAFT_1_7_2)
.forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MINECRAFT_1_15_2));
this.createFastClientServerSwitch(joinGame, ProtocolVersion.MINECRAFT_1_16)
.forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_16, ProtocolVersion.MINECRAFT_1_18));
this.createFastClientServerSwitch(joinGameModern, ProtocolVersion.MINECRAFT_1_18_2)
.forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_18_2));
.forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_18_2, ProtocolVersion.MINECRAFT_1_19));
this.createFastClientServerSwitch(joinGame1191, ProtocolVersion.MINECRAFT_1_19_1)
.forEach(minecraftPacket -> this.fastRejoinPackets.prepare(minecraftPacket, ProtocolVersion.MINECRAFT_1_19_1));
this.fastRejoinPackets.build();

this.safeRejoinPackets = this.plugin.createPreparedPacket().prepare(this.createSafeClientServerSwitch(legacyJoinGame)).build();
Expand Down Expand Up @@ -424,7 +429,7 @@ private DimensionData createDimensionData(Dimension dimension, boolean modern) {
);
}

private JoinGame createJoinGamePacket(boolean modern) {
private JoinGame createJoinGamePacket(boolean modern, CompoundBinaryTag chatTypeRegistry) {
Dimension dimension = this.world.getDimension();
JoinGame joinGame = new JoinGame();
joinGame.setEntityId(1);
Expand Down Expand Up @@ -458,13 +463,13 @@ private JoinGame createJoinGamePacket(boolean modern) {
}

joinGame.setBiomeRegistry(Biome.getRegistry());
joinGame.setChatTypeRegistry(CHAT_TYPE_119);
joinGame.setChatTypeRegistry(chatTypeRegistry);

return joinGame;
}

private JoinGame createLegacyJoinGamePacket() {
JoinGame joinGame = this.createJoinGamePacket(false);
JoinGame joinGame = this.createJoinGamePacket(false, CHAT_TYPE_119);
joinGame.setDimension(this.world.getDimension().getLegacyID());
return joinGame;
}
Expand Down Expand Up @@ -672,6 +677,46 @@ public Integer getReadTimeout() {
.build()
).build()
).build();

CHAT_TYPE_1191 = CompoundBinaryTag.builder()
.put("type", StringBinaryTag.of("minecraft:chat_type"))
.put(
"value",
ListBinaryTag.builder()
.add(
CompoundBinaryTag.builder()
.put("name", StringBinaryTag.of("minecraft:chat"))
.put("id", IntBinaryTag.of(1))
.put(
"element",
CompoundBinaryTag.builder()
.put(
"chat",
CompoundBinaryTag.builder()
.put("translation_key", StringBinaryTag.of("chat.type.text"))
.put(
"parameters",
ListBinaryTag.builder()
.add(StringBinaryTag.of("sender"))
.add(StringBinaryTag.of("content"))
.build()
).build()
)
.put(
"narration",
CompoundBinaryTag.builder()
.put("translation_key", StringBinaryTag.of("chat.type.text.narrate"))
.put(
"parameters",
ListBinaryTag.builder()
.add(StringBinaryTag.of("sender"))
.add(StringBinaryTag.of("content"))
.build()
).build()
).build()
).build()
).build()
).build();
} catch (NoSuchFieldException e) {
throw new ReflectionException(e);
}
Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/resources/mapping/flatteningblockdata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"MINECRAFT_1_19_1": {},
"MINECRAFT_1_19": {},
"MINECRAFT_1_18_2": {},
"MINECRAFT_1_18": {},
Expand Down
Loading

0 comments on commit 9fbc815

Please sign in to comment.