From 82a7c9bc3d0562b2a7e9119fda2834b07b8fd2fd Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 11 Nov 2024 15:00:34 +0100 Subject: [PATCH] Update VV usage --- .../com/viaversion/viabackwards/api/ViaBackwardsPlatform.java | 2 +- .../viabackwards/api/rewriters/EntityRewriterBase.java | 2 +- .../v1_13to1_12_2/rewriter/PlayerPacketRewriter1_13.java | 4 ++-- .../v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java | 3 ++- gradle/libs.versions.toml | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java index d878aadb..a7160e5b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java @@ -71,7 +71,7 @@ import java.util.logging.Logger; public interface ViaBackwardsPlatform { - String MINIMUM_VV_VERSION = "5.1.1"; + String MINIMUM_VV_VERSION = "5.1.2"; /** * Initialize ViaBackwards. diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java index a0c6be46..cadd29c4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java @@ -240,7 +240,7 @@ public abstract class EntityRewriterBase tracker(wrapper.user()).addEntity((int) wrapper.get(Types.VAR_INT, 0), entityType); + return wrapper -> tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType); } protected PacketHandler getPlayerTrackerHandler() { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/PlayerPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/PlayerPacketRewriter1_13.java index 79581b75..602a29b8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/PlayerPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/PlayerPacketRewriter1_13.java @@ -469,7 +469,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase wrapper.write(Types.STRING, newChannel); if (newChannel.equals("minecraft:register") || newChannel.equals("minecraft:unregister")) { - String[] channels = new String(wrapper.read(Types.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0"); + String[] channels = new String(wrapper.read(Types.SERVERBOUND_CUSTOM_PAYLOAD_DATA), StandardCharsets.UTF_8).split("\0"); List rewrittenChannels = new ArrayList<>(); for (String s : channels) { String rewritten = ItemPacketRewriter1_13.getNewPluginChannelId(s); @@ -480,7 +480,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase } } if (!rewrittenChannels.isEmpty()) { - wrapper.write(Types.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8)); + wrapper.write(Types.SERVERBOUND_CUSTOM_PAYLOAD_DATA, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8)); } else { wrapper.cancel(); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java index aa4a4410..3b58cf1f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java @@ -38,6 +38,7 @@ import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacke import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.util.Key; +import com.viaversion.viaversion.util.Limit; import static com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2.downgradeItemData; import static com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2.updateItemData; @@ -143,7 +144,7 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem wrapper.passthrough(Types.SHORT); // Slot wrapper.passthrough(Types.BYTE); // Button wrapper.passthrough(Types.VAR_INT); // Mode - final int length = wrapper.passthrough(Types.VAR_INT); + final int length = Limit.max(wrapper.passthrough(Types.VAR_INT), 128); for (int i = 0; i < length; i++) { wrapper.passthrough(Types.SHORT); // Slot passthroughServerboundItem(wrapper); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 10364b62..f8118301 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "5.1.1" +viaver = "5.1.2-SNAPSHOT" # Common provided netty = "4.0.20.Final"