Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public MinecraftPacket packet() {
CLIENT_LOG.debug("Can't move to hotbar, mouse stack is not empty: {}", this);
return null; // can't swap if mouse stack is not empty
}
final ItemStack clickStack = container.getItemStack(slotId);
if (isStackEmpty(clickStack)) {
CLIENT_LOG.debug("{} Can't swap empty stack", this);
return null; // can't swap if clickStack is empty
}
Int2ObjectMap<ItemStack> changedSlots = new Int2ObjectArrayMap<>();
int hotBarSlot = -1;
boolean playerInv = containerId == 0;
Expand All @@ -55,16 +50,19 @@ public MinecraftPacket packet() {
return null;
}
}
if (hotBarSlot != -1) {
final ItemStack swapStack = container.getItemStack(hotBarSlot);
final ItemStack clickStack = container.getItemStack(slotId);
final ItemStack swapStack = hotBarSlot == -1
? CACHE.getPlayerCache().getEquipment(EquipmentSlot.OFF_HAND)
: container.getItemStack(hotBarSlot);
if (isStackEmpty(clickStack) && isStackEmpty(swapStack)) {
CLIENT_LOG.debug("{} Can't swap two empty stacks with each other", this);
return null; // can't swap if clickStack and swapStack is empty
}
if (hotBarSlot != -1) { // -1 == Swapping with offhand while in a container
changedSlots.put(hotBarSlot, clickStack);
changedSlots.put(slotId, swapStack);
} else {
// there is no offhand slot id in the container, so only one slot is set as changed in the packet
var offhandStack = CACHE.getPlayerCache().getEquipment(EquipmentSlot.OFF_HAND);
changedSlots.put(slotId, offhandStack);
}

// there is no offhand slot id in the container, so only one slot is set as changed in the packet
changedSlots.put(slotId, swapStack);

return new ServerboundContainerClickPacket(
containerId,
Expand Down
Loading