From 4cc3ea088395d7f629f40ee48d3df6ccbc0b5482 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Tue, 1 Jun 2021 23:57:54 +0200 Subject: [PATCH] Replace some hardcoded packet ids --- .../protocol/protocol1_11_1to1_12/data/ShoulderTracker.java | 5 +++-- .../protocol1_11_1to1_12/packets/BlockItemPackets1_12.java | 3 ++- .../protocol1_12_2to1_13/packets/EntityPackets1_13.java | 3 ++- .../protocol1_13_2to1_14/packets/EntityPackets1_14.java | 6 +++--- .../protocol1_13_2to1_14/packets/SoundPackets1_14.java | 3 ++- .../protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java index 06eab86a..eb7b2d8c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/data/ShoulderTracker.java @@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; public class ShoulderTracker extends StoredObject { @@ -36,13 +37,13 @@ public class ShoulderTracker extends StoredObject { } public void update() { - PacketWrapper wrapper = PacketWrapper.create(0x0F, null, getUser()); + PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12.CHAT_MESSAGE, null, getUser()); wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(generateString())); wrapper.write(Type.BYTE, (byte) 2); try { - wrapper.send(Protocol1_11_1To1_12.class); + wrapper.scheduleSend(Protocol1_11_1To1_12.class); } catch (Exception e) { ViaBackwards.getPlatform().getLogger().severe("Failed to send the shoulder indication"); e.printStackTrace(); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java index 542d5482..a8cbffca 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java @@ -33,6 +33,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; +import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @@ -146,7 +147,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { int y = (int) (entityStorage.getY() * 8D); int z = (int) (entityStorage.getZ() * 8D); - PacketWrapper soundPacket = wrapper.create(0x4D); + PacketWrapper soundPacket = wrapper.create(ClientboundPackets1_13.SOUND); soundPacket.write(Type.VAR_INT, newId); soundPacket.write(Type.VAR_INT, category); soundPacket.write(Type.INT, x); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java index 48c9301c..8125c1ca 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java @@ -79,7 +79,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol { - PacketWrapper soundPacket = wrapper.create(0x51); + PacketWrapper soundPacket = wrapper.create(ClientboundPackets1_14.SOUND); soundPacket.write(Type.VAR_INT, 243); // entity.generic.explode soundPacket.write(Type.VAR_INT, 4); // blocks category soundPacket.write(Type.INT, toEffectCoordinate(wrapper.get(Type.FLOAT, 0))); // x