Skip to content

Commit 5dbc953

Browse files
Fix #118
1 parent 2079bf4 commit 5dbc953

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

invui/src/main/java/xyz/xenondevs/invui/internal/menu/CustomContainerMenu.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ public void sendChangesToRemote(int pingId) {
251251

252252
var offHand = serverPlayer.getOffhandItem();
253253
if (!remoteOffHand.matches(offHand)) {
254-
packets.add(new ClientboundContainerSetSlotPacket(serverPlayer.inventoryMenu.containerId, incrementStateId(), OFF_HAND_SLOT, offHand.copy()));
254+
packets.add(new ClientboundContainerSetSlotPacket(
255+
serverPlayer.inventoryMenu.containerId,
256+
serverPlayer.inventoryMenu.incrementStateId(),
257+
OFF_HAND_SLOT,
258+
serverPlayer.getOffhandItem()
259+
));
255260
remoteOffHand.force(offHand);
256261
}
257262

@@ -274,15 +279,6 @@ public void sendChangesToRemote(int pingId) {
274279
PacketListener.getInstance().injectOutgoing(player, packets);
275280
}
276281

277-
/**
278-
* Sends the cursor item stack to the remote client.
279-
*/
280-
public void sendCarriedToRemote() {
281-
var content = new ClientboundSetCursorItemPacket(carried.copy());
282-
PacketListener.getInstance().injectOutgoing(player, content);
283-
remoteCarried.force(carried);
284-
}
285-
286282
/**
287283
* Sends all data to the remote client.
288284
*
@@ -321,9 +317,22 @@ private List<Packet<? super ClientGamePacketListener>> createContainerInitPacket
321317
Arrays.stream(items).map(ItemStack::copy).toList(),
322318
carried.copy()
323319
));
320+
321+
// cursor
322+
packets.add(new ClientboundSetCursorItemPacket(carried.copy()));
323+
324+
// off-hand
325+
packets.add(new ClientboundContainerSetSlotPacket(
326+
serverPlayer.inventoryMenu.containerId,
327+
serverPlayer.inventoryMenu.incrementStateId(),
328+
OFF_HAND_SLOT,
329+
serverPlayer.getOffhandItem()
330+
));
331+
324332
for (int i = 0; i < dataSlots.length; i++) {
325333
packets.add(new ClientboundContainerSetDataPacket(containerId, i, dataSlots[i]));
326334
}
335+
327336
if (pingId >= 0) {
328337
packets.add(createMaskedPingPacket(pingId));
329338
}

0 commit comments

Comments
 (0)