From 36f6a123953780a99900689a048c18c64c6260d5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Mar 2025 22:55:17 +0700 Subject: [PATCH] Fix quick move to nearby chests treating every chest equally and possibly creating situation where items of one type of one of chests go into empty slots of different (unrelated) chest(s) --- .../ru/dbotthepony/mc/otm/menu/QuickMoveInput.kt | 3 +++ .../mc/otm/network/MatteryPlayerPackets.kt | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/QuickMoveInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/QuickMoveInput.kt index f57aaa260..2f9ed9df4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/QuickMoveInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/QuickMoveInput.kt @@ -22,6 +22,7 @@ class QuickMoveInput(private val menu: MatteryMenu, val from: Collection, Widgets18.RESTOCK_TO_STORAGE ) { override fun move(from: Collection, to: Collection, player: Player) { + if (from.isEmpty() || to.isEmpty()) return val (_, itemsFrom) = computeSlotLists(from, true) val (_, itemsTo) = computeSlotLists(to, false) @@ -39,6 +40,7 @@ class QuickMoveInput(private val menu: MatteryMenu, val from: Collection, Widgets18.RESTOCK_WITH_MOVE_TO_STORAGE ) { override fun move(from: Collection, to: Collection, player: Player) { + if (from.isEmpty() || to.isEmpty()) return val (_, itemsFrom) = computeSlotLists(from, true) val (emptyTo, itemsTo) = computeSlotLists(to, false) @@ -60,6 +62,7 @@ class QuickMoveInput(private val menu: MatteryMenu, val from: Collection, Widgets18.MOVE_EVERYTHING_TO_STORAGE ) { override fun move(from: Collection, to: Collection, player: Player) { + if (from.isEmpty() || to.isEmpty()) return val toSorted = prioritySortSlots(to) from.forEach { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt index 697e01acb..6eb691ae9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt @@ -470,8 +470,6 @@ class QuickStackPacket( val ignoreBlockstates = HashSet() findCaps.forEach { (b, _) -> ignoreBlockstates.add(b.blockState) } - val slots = ArrayList() - for ((blockEntity, cap) in findCaps) { // don't interact through walls val trace = player.serverLevel().isBlockInLine(ClipBlockStateContext(eyes, Vector.atCenterOf(blockEntity.blockPos)) { @@ -479,16 +477,12 @@ class QuickStackPacket( }) if (trace.blockPos == blockEntity.blockPos) { - slots.addAll(cap.getSlotsFor(player)) + if (fromExopack) + mode.move(player.matteryPlayer.exoPackMenu.playerCombinedInventorySlots, cap.getSlotsFor(player), player) + else + mode.move(cap.getSlotsFor(player), player.matteryPlayer.exoPackMenu.playerInventorySlots, player) } } - - if (slots.isEmpty()) return - - if (fromExopack) - mode.move(player.matteryPlayer.exoPackMenu.playerCombinedInventorySlots, slots, player) - else - mode.move(slots, player.matteryPlayer.exoPackMenu.playerInventorySlots, player) } override fun type(): CustomPacketPayload.Type {