File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
src/main/kotlin/com/lambda
interaction/construction/simulation/checks Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ import com.lambda.threading.runSafe
5050import com.lambda.util.BlockUtils.blockState
5151import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
5252import com.lambda.util.BlockUtils.instantBreakable
53- import com.lambda.util.item.ItemStackUtils.inventoryIndex
53+ import com.lambda.util.item.ItemStackUtils.inventoryIndexOrSelected
5454import com.lambda.util.math.distSq
5555import com.lambda.util.world.raycast.RayCastUtils.blockResult
5656import io.ktor.util.collections.*
@@ -169,7 +169,7 @@ class BreakChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
169169 val breakContext = BreakContext (
170170 blockHit,
171171 rotationRequest,
172- swapStack.inventoryIndex ,
172+ swapStack.inventoryIndexOrSelected ,
173173 stackSelection,
174174 instant,
175175 state,
@@ -228,7 +228,7 @@ class BreakChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
228228 val breakContext = BreakContext (
229229 blockHit,
230230 rotationRequest,
231- swapStack.inventoryIndex ,
231+ swapStack.inventoryIndexOrSelected ,
232232 stackSelection,
233233 instant,
234234 state,
Original file line number Diff line number Diff line change @@ -81,6 +81,12 @@ object ItemStackUtils {
8181
8282 context(safeContext: SafeContext )
8383 val ItemStack .inventoryIndex get() = safeContext.player.inventory.getSlotWithStack(this )
84+ context(safeContext: SafeContext )
85+ val ItemStack .inventoryIndexOrSelected get() = with (safeContext) {
86+ player.inventory.getSlotWithStack(this @inventoryIndexOrSelected).let {
87+ if (it == - 1 ) player.inventory.selectedSlot else it
88+ }
89+ }
8490
8591 val List <ItemStack >.compressed: List <ItemStack >
8692 get() =
You can’t perform that action at this time.
0 commit comments