From e36917e6c26a9221eed627f78734fabc9f0c97b0 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 16 Aug 2024 20:52:15 +0200 Subject: [PATCH] Update to VV container id types --- .../rewriter/BlockItemPacketRewriter1_11.java | 4 ++-- .../rewriter/BlockItemPacketRewriter1_12.java | 5 +++-- .../rewriter/ItemPacketRewriter1_13_2.java | 4 ++-- .../rewriter/BlockItemPacketRewriter1_13.java | 4 ++-- .../protocol/v1_17_1to1_17/Protocol1_17_1To1_17.java | 10 +++++----- .../v1_17_1to1_17/storage/InventoryStateIds.java | 4 ++-- .../rewriter/BlockItemPacketRewriter1_17.java | 6 +++--- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/BlockItemPacketRewriter1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/BlockItemPacketRewriter1_11.java index bb05ac61..b679efc7 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/BlockItemPacketRewriter1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/BlockItemPacketRewriter1_11.java @@ -60,7 +60,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter { short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE); - wrapper.user().get(InventoryStateIds.class).removeStateId(containerId); + wrapper.user().get(InventoryStateIds.class).removeStateId((byte) containerId); }); registerClientbound(ClientboundPackets1_17_1.CONTAINER_SET_SLOT, wrapper -> { - short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE); + byte containerId = wrapper.passthrough(Types.BYTE); int stateId = wrapper.read(Types.VAR_INT); wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId); }); registerClientbound(ClientboundPackets1_17_1.CONTAINER_SET_CONTENT, wrapper -> { short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE); int stateId = wrapper.read(Types.VAR_INT); - wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId); + wrapper.user().get(InventoryStateIds.class).setStateId((byte) containerId, stateId); // Length is encoded as a var int in 1.17.1 wrapper.write(Types.ITEM1_13_2_SHORT_ARRAY, wrapper.read(Types.ITEM1_13_2_ARRAY)); @@ -89,10 +89,10 @@ public final class Protocol1_17_1To1_17 extends BackwardsProtocol { short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE); - wrapper.user().get(InventoryStateIds.class).removeStateId(containerId); + wrapper.user().get(InventoryStateIds.class).removeStateId((byte) containerId); }); registerServerbound(ServerboundPackets1_17.CONTAINER_CLICK, wrapper -> { - short containerId = wrapper.passthrough(Types.UNSIGNED_BYTE); + byte containerId = wrapper.passthrough(Types.BYTE); int stateId = wrapper.user().get(InventoryStateIds.class).removeStateId(containerId); wrapper.write(Types.VAR_INT, stateId == Integer.MAX_VALUE ? 0 : stateId); }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17_1to1_17/storage/InventoryStateIds.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17_1to1_17/storage/InventoryStateIds.java index d24c723f..497849be 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17_1to1_17/storage/InventoryStateIds.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17_1to1_17/storage/InventoryStateIds.java @@ -29,11 +29,11 @@ public final class InventoryStateIds implements StorableObject { ids.defaultReturnValue(Integer.MAX_VALUE); } - public void setStateId(short containerId, int id) { + public void setStateId(byte containerId, int id) { ids.put(containerId, id); } - public int removeStateId(short containerId) { + public int removeStateId(byte containerId) { return ids.remove(containerId); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java index eee094a4..d65d5d10 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java @@ -91,7 +91,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter { short slot = wrapper.passthrough(Types.SHORT); // Slot byte button = wrapper.passthrough(Types.BYTE); // Button @@ -139,7 +139,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter { - short windowId = wrapper.passthrough(Types.UNSIGNED_BYTE); + byte windowId = wrapper.passthrough(Types.BYTE); short slot = wrapper.passthrough(Types.SHORT); Item carried = wrapper.read(Types.ITEM1_13_2); @@ -164,7 +164,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter