From c5e066e050fdbc20e9e5029219f701a6c927f90a Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 10 Aug 2023 13:35:47 +1000 Subject: [PATCH] 23w32a --- .../api/protocol/version/ProtocolVersion.java | 2 +- .../Protocol1_20_2To1_20.java | 9 ++ .../packet/ClientboundPackets1_20_2.java | 121 +++++++++--------- .../packet/ServerboundPackets1_20_2.java | 49 +++---- .../BlockItemPacketRewriter1_20_2.java | 31 ++++- gradle.properties | 2 +- 6 files changed, 127 insertions(+), 87 deletions(-) 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 a4633672e..7d69a2d81 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 @@ -84,7 +84,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_19_3 = register(761, "1.19.3"); public static final ProtocolVersion v1_19_4 = register(762, "1.19.4"); public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new VersionRange("1.20", 0, 1)); - public static final ProtocolVersion v1_20_2 = register(764, 144, "1.20.2"); + public static final ProtocolVersion v1_20_2 = register(764, 145, "1.20.2"); 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_20_2to1_20/Protocol1_20_2To1_20.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java index f4c1e7787..5c9397a3d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java @@ -109,6 +109,15 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol { + wrapper.cancel(); + final long time = wrapper.read(Type.LONG); + + final PacketWrapper responsePacket = wrapper.create(ClientboundPackets1_20_2.PONG_RESPONSE); + responsePacket.write(Type.LONG, time); + responsePacket.sendFuture(Protocol1_20_2To1_20.class); + }); } private PacketHandler queueServerboundPacket(final ServerboundPackets1_20_2 packetType) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ClientboundPackets1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ClientboundPackets1_20_2.java index 4ff89f898..9b56ea93c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ClientboundPackets1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ClientboundPackets1_20_2.java @@ -74,66 +74,67 @@ public enum ClientboundPackets1_20_2 implements ClientboundPacketType { OPEN_WINDOW, // 0x32 OPEN_SIGN_EDITOR, // 0x33 PING, // 0x34 - CRAFT_RECIPE_RESPONSE, // 0x35 - PLAYER_ABILITIES, // 0x36 - PLAYER_CHAT, // 0x37 - COMBAT_END, // 0x38 - COMBAT_ENTER, // 0x39 - COMBAT_KILL, // 0x3A - PLAYER_INFO_REMOVE, // 0x3B - PLAYER_INFO_UPDATE, // 0x3C - FACE_PLAYER, // 0x3D - PLAYER_POSITION, // 0x3E - UNLOCK_RECIPES, // 0x3F - REMOVE_ENTITIES, // 0x40 - REMOVE_ENTITY_EFFECT, // 0x41 - RESOURCE_PACK, // 0x42 - RESPAWN, // 0x43 - ENTITY_HEAD_LOOK, // 0x44 - MULTI_BLOCK_CHANGE, // 0x45 - SELECT_ADVANCEMENTS_TAB, // 0x46 - SERVER_DATA, // 0x47 - ACTIONBAR, // 0x48 - WORLD_BORDER_CENTER, // 0x49 - WORLD_BORDER_LERP_SIZE, // 0x4A - WORLD_BORDER_SIZE, // 0x4B - WORLD_BORDER_WARNING_DELAY, // 0x4C - WORLD_BORDER_WARNING_DISTANCE, // 0x4D - CAMERA, // 0x4E - HELD_ITEM_CHANGE, // 0x4F - UPDATE_VIEW_POSITION, // 0x50 - UPDATE_VIEW_DISTANCE, // 0x51 - SPAWN_POSITION, // 0x52 - DISPLAY_SCOREBOARD, // 0x53 - ENTITY_METADATA, // 0x54 - ATTACH_ENTITY, // 0x55 - ENTITY_VELOCITY, // 0x56 - ENTITY_EQUIPMENT, // 0x57 - SET_EXPERIENCE, // 0x58 - UPDATE_HEALTH, // 0x59 - SCOREBOARD_OBJECTIVE, // 0x5A - SET_PASSENGERS, // 0x5B - TEAMS, // 0x5C - UPDATE_SCORE, // 0x5D - SET_SIMULATION_DISTANCE, // 0x5E - TITLE_SUBTITLE, // 0x5F - TIME_UPDATE, // 0x60 - TITLE_TEXT, // 0x61 - TITLE_TIMES, // 0x62 - ENTITY_SOUND, // 0x63 - SOUND, // 0x64 - START_CONFIGURATION, // 0x65 - STOP_SOUND, // 0x66 - SYSTEM_CHAT, // 0x67 - TAB_LIST, // 0x68 - NBT_QUERY, // 0x69 - COLLECT_ITEM, // 0x6A - ENTITY_TELEPORT, // 0x6B - ADVANCEMENTS, // 0x6C - ENTITY_PROPERTIES, // 0x6D - ENTITY_EFFECT, // 0x6E - DECLARE_RECIPES, // 0x6F - TAGS; // 0x70 + PONG_RESPONSE, // 0x35 + CRAFT_RECIPE_RESPONSE, // 0x36 + PLAYER_ABILITIES, // 0x37 + PLAYER_CHAT, // 0x38 + COMBAT_END, // 0x39 + COMBAT_ENTER, // 0x3A + COMBAT_KILL, // 0x3B + PLAYER_INFO_REMOVE, // 0x3C + PLAYER_INFO_UPDATE, // 0x3D + FACE_PLAYER, // 0x3E + PLAYER_POSITION, // 0x3F + UNLOCK_RECIPES, // 0x40 + REMOVE_ENTITIES, // 0x41 + REMOVE_ENTITY_EFFECT, // 0x42 + RESOURCE_PACK, // 0x43 + RESPAWN, // 0x44 + ENTITY_HEAD_LOOK, // 0x45 + MULTI_BLOCK_CHANGE, // 0x46 + SELECT_ADVANCEMENTS_TAB, // 0x47 + SERVER_DATA, // 0x48 + ACTIONBAR, // 0x49 + WORLD_BORDER_CENTER, // 0x4A + WORLD_BORDER_LERP_SIZE, // 0x4B + WORLD_BORDER_SIZE, // 0x4C + WORLD_BORDER_WARNING_DELAY, // 0x4D + WORLD_BORDER_WARNING_DISTANCE, // 0x4E + CAMERA, // 0x4F + HELD_ITEM_CHANGE, // 0x50 + UPDATE_VIEW_POSITION, // 0x51 + UPDATE_VIEW_DISTANCE, // 0x52 + SPAWN_POSITION, // 0x53 + DISPLAY_SCOREBOARD, // 0x54 + ENTITY_METADATA, // 0x55 + ATTACH_ENTITY, // 0x56 + ENTITY_VELOCITY, // 0x57 + ENTITY_EQUIPMENT, // 0x58 + SET_EXPERIENCE, // 0x59 + UPDATE_HEALTH, // 0x5A + SCOREBOARD_OBJECTIVE, // 0x5B + SET_PASSENGERS, // 0x5C + TEAMS, // 0x5D + UPDATE_SCORE, // 0x5E + SET_SIMULATION_DISTANCE, // 0x5F + TITLE_SUBTITLE, // 0x60 + TIME_UPDATE, // 0x61 + TITLE_TEXT, // 0x62 + TITLE_TIMES, // 0x63 + ENTITY_SOUND, // 0x64 + SOUND, // 0x65 + START_CONFIGURATION, // 0x66 + STOP_SOUND, // 0x67 + SYSTEM_CHAT, // 0x68 + TAB_LIST, // 0x69 + NBT_QUERY, // 0x6A + COLLECT_ITEM, // 0x6B + ENTITY_TELEPORT, // 0x6C + ADVANCEMENTS, // 0x6D + ENTITY_PROPERTIES, // 0x6E + ENTITY_EFFECT, // 0x6F + DECLARE_RECIPES, // 0x70 + TAGS; // 0x71 @Override public int getId() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ServerboundPackets1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ServerboundPackets1_20_2.java index 153b980f4..1cfdba29c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ServerboundPackets1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/packet/ServerboundPackets1_20_2.java @@ -50,30 +50,31 @@ public enum ServerboundPackets1_20_2 implements ServerboundPacketType { VEHICLE_MOVE, // 0x1A STEER_BOAT, // 0x1B PICK_ITEM, // 0x1C - CRAFT_RECIPE_REQUEST, // 0x1D - PLAYER_ABILITIES, // 0x1E - PLAYER_DIGGING, // 0x1F - ENTITY_ACTION, // 0x20 - STEER_VEHICLE, // 0x21 - PONG, // 0x22 - RECIPE_BOOK_DATA, // 0x23 - SEEN_RECIPE, // 0x24 - RENAME_ITEM, // 0x25 - RESOURCE_PACK_STATUS, // 0x26 - ADVANCEMENT_TAB, // 0x27 - SELECT_TRADE, // 0x28 - SET_BEACON_EFFECT, // 0x29 - HELD_ITEM_CHANGE, // 0x2A - UPDATE_COMMAND_BLOCK, // 0x2B - UPDATE_COMMAND_BLOCK_MINECART, // 0x2C - CREATIVE_INVENTORY_ACTION, // 0x2D - UPDATE_JIGSAW_BLOCK, // 0x2E - UPDATE_STRUCTURE_BLOCK, // 0x2F - UPDATE_SIGN, // 0x30 - ANIMATION, // 0x31 - SPECTATE, // 0x32 - PLAYER_BLOCK_PLACEMENT, // 0x33 - USE_ITEM; // 0x34 + PING_REQUEST, // 0x1D + CRAFT_RECIPE_REQUEST, // 0x1E + PLAYER_ABILITIES, // 0x1F + PLAYER_DIGGING, // 0x20 + ENTITY_ACTION, // 0x21 + STEER_VEHICLE, // 0x22 + PONG, // 0x23 + RECIPE_BOOK_DATA, // 0x24 + SEEN_RECIPE, // 0x25 + RENAME_ITEM, // 0x26 + RESOURCE_PACK_STATUS, // 0x27 + ADVANCEMENT_TAB, // 0x28 + SELECT_TRADE, // 0x29 + SET_BEACON_EFFECT, // 0x2A + HELD_ITEM_CHANGE, // 0x2B + UPDATE_COMMAND_BLOCK, // 0x2C + UPDATE_COMMAND_BLOCK_MINECART, // 0x2D + CREATIVE_INVENTORY_ACTION, // 0x2E + UPDATE_JIGSAW_BLOCK, // 0x2F + UPDATE_STRUCTURE_BLOCK, // 0x30 + UPDATE_SIGN, // 0x31 + ANIMATION, // 0x32 + SPECTATE, // 0x33 + PLAYER_BLOCK_PLACEMENT, // 0x34 + USE_ITEM; // 0x35 @Override public int getId() { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java index b1efe7e7e..442df1737 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java @@ -17,8 +17,13 @@ */ package com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.IntTag; +import com.github.steveice10.opennbt.tag.builtin.StringTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.data.entity.EntityTracker; +import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition; @@ -34,6 +39,8 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_ import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4; import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.util.MathUtil; +import javax.swing.border.CompoundBorder; +import org.checkerframework.checker.nullness.qual.Nullable; public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { @@ -57,7 +64,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { wrapper.passthrough(Type.POSITION1_14); // Position wrapper.passthrough(Type.VAR_INT); // Type - wrapper.write(Type.NAMELESS_NBT, wrapper.read(Type.NBT)); + wrapper.write(Type.NAMELESS_NBT, handleBlockEntity(wrapper.read(Type.NBT))); }); protocol.registerClientbound(ClientboundPackets1_19_4.CHUNK_DATA, wrapper -> { @@ -71,6 +78,10 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter