|
30 | 30 | import net.minecraft.network.protocol.Packet;
|
31 | 31 | import net.minecraft.network.protocol.common.ServerboundClientInformationPacket;
|
32 | 32 | import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
| 33 | +import net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket; |
| 34 | +import net.minecraft.network.protocol.game.ClientboundSetPlayerInventoryPacket; |
33 | 35 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
34 | 36 | import net.minecraft.network.syncher.EntityDataAccessor;
|
35 | 37 | import net.minecraft.server.level.ServerLevel;
|
@@ -103,7 +105,7 @@ public static void handleSlotRestore(@Nullable final Player player, final @Nulla
|
103 | 105 | final org.spongepowered.api.item.inventory.ItemStack stack = snapshot.asMutable();
|
104 | 106 | slot.set(stack);
|
105 | 107 | ((net.minecraft.server.level.ServerPlayer) player).connection.send(
|
106 |
| - new ClientboundContainerSetSlotPacket(-2, player.inventoryMenu.getStateId(), ((SlotAdapter) slot).getOrdinal(), ItemStackUtil.toNative(stack))); |
| 108 | + new ClientboundSetPlayerInventoryPacket(((SlotAdapter) slot).getOrdinal(), ItemStackUtil.toNative(stack))); |
107 | 109 | } else {
|
108 | 110 | final int slotNumber = ((SlotAdapter) slot).getOrdinal();
|
109 | 111 | final Slot nmsSlot = containerMenu.getSlot(slotNumber);
|
@@ -138,15 +140,15 @@ public static void handleCursorRestore(final Player player, final Transaction<It
|
138 | 140 | player.containerMenu.setCarried(cursor);
|
139 | 141 | player.containerMenu.setRemoteCarried(cursor);
|
140 | 142 | if (player instanceof net.minecraft.server.level.ServerPlayer) {
|
141 |
| - ((net.minecraft.server.level.ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(-1, player.containerMenu.getStateId(), -1, cursor)); |
| 143 | + ((net.minecraft.server.level.ServerPlayer) player).connection.send(new ClientboundSetCursorItemPacket(cursor)); |
142 | 144 | }
|
143 | 145 | }
|
144 | 146 |
|
145 | 147 | public static void handleCustomCursor(final Player player, final ItemStackSnapshot customCursor) {
|
146 | 148 | final ItemStack cursor = ItemStackUtil.fromSnapshotToNative(customCursor);
|
147 | 149 | player.containerMenu.setCarried(cursor);
|
148 | 150 | if (player instanceof net.minecraft.server.level.ServerPlayer) {
|
149 |
| - ((net.minecraft.server.level.ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(-1, -1, -1, cursor)); |
| 151 | + ((net.minecraft.server.level.ServerPlayer) player).connection.send(new ClientboundSetCursorItemPacket(cursor)); |
150 | 152 | }
|
151 | 153 | }
|
152 | 154 |
|
|
0 commit comments