From 104481a7d5e72a5a86587a8fb35ffff7de93cb88 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sat, 17 Jan 2026 20:50:26 +0900 Subject: [PATCH] fix: fixture pickup mess with quickslots and needed empty hands --- .../terrarum/modulebasegame/TerrarumIngame.kt | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index 021faac3a..a97bb9667 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -795,16 +795,27 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { val itemOnGrip = ItemCodex[(actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)] if (!worldSecondaryClickLatch) { - // #1. Perform item's secondaryUse - val consumptionSuccessful = itemOnGrip?.startSecondaryUse(actor, delta) ?: -1 - if (consumptionSuccessful > -1) - (actor as Pocketed).inventory.consumeItem(itemOnGrip!!, consumptionSuccessful) - // #2. If #1 failed, try to pick up the fixture - else { - mouseInInteractableRange(actor) { mwx, mwy, mtx, mty -> - pickupFixtureOrDroppedItem(actor, delta, mwx, mwy, mtx, mty) + // #1. Try to pick up the fixture or dropped item first (if in range and there's something to pick up) + val pickupSuccessful = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty -> + val actorsUnderMouse = getActorsUnderMouse(mwx, mwy) + val hasPickupableActor = actorsUnderMouse.any { + (it is FixtureBase && it.canBeDespawned && System.nanoTime() - it.spawnRequestedTime > 50000000) || // give freshly spawned fixtures 0.05 seconds of immunity + (it is DroppedItem && it.noAutoPickup) + } + if (hasPickupableActor) { + pickupFixtureOrDroppedItem(actor, delta, mwx, mwy, mtx, mty, assignToQuickslot = (itemOnGrip == null)) 0L } + else { + -1L + } + } + + // #2. If pickup didn't happen, try to perform item's secondaryUse + if (pickupSuccessful < 0) { + val consumptionSuccessful = itemOnGrip?.startSecondaryUse(actor, delta) ?: -1 + if (consumptionSuccessful > -1) + (actor as Pocketed).inventory.consumeItem(itemOnGrip!!, consumptionSuccessful) } worldSecondaryClickLatch = true