From 31e557c80b43e700f459c5b7e48a0aee442a20f5 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 27 Feb 2023 18:23:43 +0100 Subject: [PATCH] Start working on 1.19.4 --- .../api/network/ProtocolVersion.java | 3 +- .../brigadier/ArgumentPropertyRegistry.java | 7 +++- .../brigadier/TimeArgumentSerializer.java | 41 +++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index 502657c3d..62d09a32d 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -60,7 +60,8 @@ public enum ProtocolVersion { MINECRAFT_1_18_2(758, "1.18.2"), MINECRAFT_1_19(759, "1.19"), MINECRAFT_1_19_1(760, "1.19.1", "1.19.2"), - MINECRAFT_1_19_3(761, "1.19.3"); + MINECRAFT_1_19_3(761, "1.19.3"), + MINECRAFT_1_19_4(762, "1.19.4"); private static final int SNAPSHOT_BIT = 30; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java index 89235a9f2..df877b0b5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java @@ -19,6 +19,7 @@ package com.velocitypowered.proxy.protocol.packet.brigadier; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3; +import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_4; import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.id; import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet; import static com.velocitypowered.proxy.protocol.packet.brigadier.DoubleArgumentPropertySerializer.DOUBLE; @@ -232,8 +233,9 @@ public class ArgumentPropertyRegistry { empty(id("minecraft:entity_summon", mapSet(MINECRAFT_1_19_3, -1), mapSet(MINECRAFT_1_19, 40))); empty(id("minecraft:dimension", mapSet(MINECRAFT_1_19_3, 38), mapSet(MINECRAFT_1_19, 41))); empty(id("minecraft:gamemode", mapSet(MINECRAFT_1_19_3, 39))); // 1.19.3 + empty(id("minecraft:time", mapSet(MINECRAFT_1_19_3, 40), - mapSet(MINECRAFT_1_19, 42))); // added in 1.14 + mapSet(MINECRAFT_1_19, 42)), TimeArgumentSerializer.TIME); // added in 1.14 register( id("minecraft:resource_or_tag", mapSet(MINECRAFT_1_19_3, 41), mapSet(MINECRAFT_1_19, 43)), @@ -249,8 +251,9 @@ public class ArgumentPropertyRegistry { empty(id("minecraft:template_mirror", mapSet(MINECRAFT_1_19, 45))); // 1.19 empty(id("minecraft:template_rotation", mapSet(MINECRAFT_1_19, 46))); // 1.19 + empty(id("minecraft:heightmap", mapSet(MINECRAFT_1_19_4, 47))); // 1.19.4 - empty(id("minecraft:uuid", mapSet(MINECRAFT_1_19, 47))); // added in 1.16 + empty(id("minecraft:uuid", mapSet(MINECRAFT_1_19_4, 48), mapSet(MINECRAFT_1_19, 47))); // added in 1.16 // Crossstitch support register(id("crossstitch:mod_argument", mapSet(MINECRAFT_1_19, -256)), diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java new file mode 100644 index 000000000..1ddbcd68e --- /dev/null +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/TimeArgumentSerializer.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018-2023 Velocity Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.velocitypowered.proxy.protocol.packet.brigadier; + +import com.velocitypowered.api.network.ProtocolVersion; +import io.netty.buffer.ByteBuf; + +public class TimeArgumentSerializer implements ArgumentPropertySerializer { + + static final TimeArgumentSerializer TIME = new TimeArgumentSerializer(); + + @Override + public Integer deserialize(ByteBuf buf, ProtocolVersion protocolVersion) { + if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_19_4) >= 0) { + return buf.readInt(); + } + return 0; + } + + @Override + public void serialize(Integer object, ByteBuf buf, ProtocolVersion protocolVersion) { + if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_19_4) >= 0) { + buf.writeInt(object); + } + } +}