3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +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);
final int containerId = wrapper.get(Types.VAR_INT, 0);
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.VAR_INT); // State id
wrapper.passthrough(Types.SHORT); // Slot 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);