From b9f80754e05488e654e52a226bc69cfcfc28a8db Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 4 May 2022 19:15:23 +0200 Subject: [PATCH] 22w18a --- .../api/protocol/version/ProtocolVersion.java | 2 +- .../Protocol1_19To1_18_2.java | 28 +++++-- .../ServerboundPackets1_19.java | 83 +++++++++++++++++++ .../packets/EntityPackets.java | 40 +++++++++ .../packets/InventoryPackets.java | 12 +-- .../packets/WorldPackets.java | 4 +- gradle.properties | 2 +- 7 files changed, 156 insertions(+), 15 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/ServerboundPackets1_19.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index 5f131d4e6..616501984 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -80,7 +80,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_17_1 = register(756, "1.17.1"); public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1)); public static final ProtocolVersion v1_18_2 = register(758, "1.18.2"); - public static final ProtocolVersion v1_19 = register(759, 82, "1.19"); + public static final ProtocolVersion v1_19 = register(759, 83, "1.19"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static ProtocolVersion register(int version, String name) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java index 26f941780..efe559f3c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/Protocol1_19To1_18_2.java @@ -51,7 +51,7 @@ import java.security.PublicKey; import java.security.spec.EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; -public final class Protocol1_19To1_18_2 extends AbstractProtocol { +public final class Protocol1_19To1_18_2 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingDataBase("1.18", "1.19", true); private static final KeyFactory RSA_FACTORY; @@ -68,7 +68,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol { + final String command = wrapper.get(Type.STRING, 0); + wrapper.set(Type.STRING, 0, "/" + command); + + final int signatures = wrapper.read(Type.VAR_INT); + for (int i = 0; i < signatures; i++) { + wrapper.read(Type.STRING); // Argument name + wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature + } + }); + } + }); // Login changes registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketRemapper() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/ServerboundPackets1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/ServerboundPackets1_19.java new file mode 100644 index 000000000..b62eece1f --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/ServerboundPackets1_19.java @@ -0,0 +1,83 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2022 ViaVersion and 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.viaversion.viaversion.protocols.protocol1_19to1_18_2; + +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; + +public enum ServerboundPackets1_19 implements ServerboundPacketType { + + TELEPORT_CONFIRM, // 0x00 + QUERY_BLOCK_NBT, // 0x01 + SET_DIFFICULTY, // 0x02 + CHAT_COMMAND, // 0x03 + CHAT_MESSAGE, // 0x04 + CLIENT_STATUS, // 0x05 + CLIENT_SETTINGS, // 0x06 + TAB_COMPLETE, // 0x07 + CLICK_WINDOW_BUTTON, // 0x08 + CLICK_WINDOW, // 0x09 + CLOSE_WINDOW, // 0x0A + PLUGIN_MESSAGE, // 0x0B + EDIT_BOOK, // 0x0C + ENTITY_NBT_REQUEST, // 0x0D + INTERACT_ENTITY, // 0x0E + GENERATE_JIGSAW, // 0x0F + KEEP_ALIVE, // 0x10 + LOCK_DIFFICULTY, // 0x11 + PLAYER_POSITION, // 0x12 + PLAYER_POSITION_AND_ROTATION, // 0x13 + PLAYER_ROTATION, // 0x14 + PLAYER_MOVEMENT, // 0x15 + VEHICLE_MOVE, // 0x16 + STEER_BOAT, // 0x17 + PICK_ITEM, // 0x18 + CRAFT_RECIPE_REQUEST, // 0x19 + PLAYER_ABILITIES, // 0x1A + PLAYER_DIGGING, // 0x1B + ENTITY_ACTION, // 0x1C + STEER_VEHICLE, // 0x1D + PONG, // 0x1E + RECIPE_BOOK_DATA, // 0x1F + SEEN_RECIPE, // 0x20 + RENAME_ITEM, // 0x21 + RESOURCE_PACK_STATUS, // 0x22 + ADVANCEMENT_TAB, // 0x23 + SELECT_TRADE, // 0x24 + SET_BEACON_EFFECT, // 0x25 + HELD_ITEM_CHANGE, // 0x26 + UPDATE_COMMAND_BLOCK, // 0x27 + UPDATE_COMMAND_BLOCK_MINECART, // 0x28 + CREATIVE_INVENTORY_ACTION, // 0x29 + UPDATE_JIGSAW_BLOCK, // 0x2A + UPDATE_STRUCTURE_BLOCK, // 0x2B + UPDATE_SIGN, // 0x2C + ANIMATION, // 0x2D + SPECTATE, // 0x2E + PLAYER_BLOCK_PLACEMENT, // 0x2F + USE_ITEM; // 0x30 + + @Override + public int getId() { + return ordinal(); + } + + @Override + public String getName() { + return name(); + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java index e09495d18..cb12ee4a8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java @@ -171,6 +171,46 @@ public final class EntityPackets extends EntityRewriter { handler(worldDataTrackerHandler(0)); } }); + + protocol.registerClientbound(ClientboundPackets1_18.PLAYER_INFO, new PacketRemapper() { + @Override + public void registerMap() { + handler(wrapper -> { + final int action = wrapper.passthrough(Type.VAR_INT); + final int entries = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < entries; i++) { + wrapper.passthrough(Type.UUID); // UUID + if (action == 0) { // Add player + wrapper.passthrough(Type.STRING); // Player Name + + final int properties = wrapper.passthrough(Type.VAR_INT); + for (int j = 0; j < properties; j++) { + wrapper.passthrough(Type.STRING); // Name + wrapper.passthrough(Type.STRING); // Value + if (wrapper.passthrough(Type.BOOLEAN)) { + wrapper.passthrough(Type.STRING); // Signature + } + } + + wrapper.passthrough(Type.VAR_INT); // Gamemode + wrapper.passthrough(Type.VAR_INT); // Ping + if (wrapper.passthrough(Type.BOOLEAN)) { + wrapper.passthrough(Type.COMPONENT); // Display name + } + + // No public profile signature + wrapper.write(Type.BOOLEAN, false); + } else if (action == 1 || action == 2) { // Update gamemode/update latency + wrapper.passthrough(Type.VAR_INT); + } else if (action == 3) { // Update display name + if (wrapper.passthrough(Type.BOOLEAN)) { + wrapper.passthrough(Type.COMPONENT); + } + } + } + }); + } + }); } private static int to3dId(final int id) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java index 9740f79dc..59d0d49e4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java @@ -21,9 +21,9 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; -import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2; +import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage; import com.viaversion.viaversion.rewriter.ItemRewriter; @@ -58,12 +58,12 @@ public final class InventoryPackets extends ItemRewriter { } }); - registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); - registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); + registerClickWindow1_17_1(ServerboundPackets1_19.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); + registerCreativeInvAction(ServerboundPackets1_19.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); registerWindowPropertyEnchantmentHandler(ClientboundPackets1_18.WINDOW_PROPERTY); - protocol.registerServerbound(ServerboundPackets1_17.PLAYER_DIGGING, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_19.PLAYER_DIGGING, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // Action @@ -72,7 +72,7 @@ public final class InventoryPackets extends ItemRewriter { handler(sequenceHandler()); } }); - protocol.registerServerbound(ServerboundPackets1_17.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_19.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // Hand @@ -85,7 +85,7 @@ public final class InventoryPackets extends ItemRewriter { handler(sequenceHandler()); } }); - protocol.registerServerbound(ServerboundPackets1_17.USE_ITEM, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_19.USE_ITEM, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // Hand diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java index 080281111..c9d658f27 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java @@ -24,11 +24,11 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2; +import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.util.MathUtil; @@ -73,7 +73,7 @@ public final class WorldPackets { } }); - protocol.registerServerbound(ServerboundPackets1_17.SET_BEACON_EFFECT, new PacketRemapper() { + protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON_EFFECT, new PacketRemapper() { @Override public void registerMap() { handler(wrapper -> { diff --git a/gradle.properties b/gradle.properties index cc23328aa..e7579a659 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.3.0-22w17a-SNAPSHOT +projectVersion=4.3.0-22w18a-SNAPSHOT # Gradle properties org.gradle.daemon=true