3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 08:10:09 +01:00

Fix CONTAINER_SET_SLOT translation (#9)

Dieser Commit ist enthalten in:
RK_01 2024-10-09 16:37:03 +02:00 committet von Nassim Jahnke
Ursprung 886be3161e
Commit 093acc519e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F

Datei anzeigen

@ -108,8 +108,23 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
}); });
protocol.registerClientbound(ClientboundPackets1_21.CONTAINER_SET_SLOT, wrapper -> { protocol.registerClientbound(ClientboundPackets1_21.CONTAINER_SET_SLOT, wrapper -> {
updateContainerId(wrapper); updateContainerId(wrapper);
wrapper.passthrough(Types.VAR_INT); // State id final int containerId = wrapper.get(Types.VAR_INT, 0);
wrapper.passthrough(Types.SHORT); // Slot id if (containerId == -1) { // cursor item
wrapper.setPacketType(ClientboundPackets1_21_2.SET_CURSOR_ITEM);
wrapper.resetReader();
wrapper.read(Types.VAR_INT); // container id
wrapper.read(Types.VAR_INT); // State id
wrapper.read(Types.SHORT); // Slot id
} else if (containerId == -2) { // cursor item
wrapper.setPacketType(ClientboundPackets1_21_2.SET_PLAYER_INVENTORY);
wrapper.resetReader();
wrapper.read(Types.VAR_INT); // container id
wrapper.read(Types.VAR_INT); // State id
wrapper.write(Types.VAR_INT, (int) wrapper.read(Types.SHORT)); // Slot id
} else {
wrapper.passthrough(Types.VAR_INT); // State id
wrapper.passthrough(Types.SHORT); // Slot id
}
passthroughClientboundItem(wrapper); passthroughClientboundItem(wrapper);
}); });
protocol.registerClientbound(ClientboundPackets1_21.CONTAINER_CLOSE, this::updateContainerId); protocol.registerClientbound(ClientboundPackets1_21.CONTAINER_CLOSE, this::updateContainerId);
@ -378,7 +393,7 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
private void updateContainerId(final PacketWrapper wrapper) { private void updateContainerId(final PacketWrapper wrapper) {
// Container id handling was always a bit whack with most reading them as unsigned bytes, some as bytes, some already as var ints. // Container id handling was always a bit whack with most reading them as unsigned bytes, some as bytes, some already as var ints.
// In VV they're generally read as unsigned bytesto not have to look the type up every time, but we need to make sure they're // In VV they're generally read as unsigned bytes to not have to look the type up every time, but we need to make sure they're
// properly converted to ints when used // properly converted to ints when used
final short containerId = wrapper.read(Types.UNSIGNED_BYTE); final short containerId = wrapper.read(Types.UNSIGNED_BYTE);
final int intId = (byte) containerId; final int intId = (byte) containerId;