From 3c28fe8f7716fd300b93d3e5b57ba4cc7ee217b8 Mon Sep 17 00:00:00 2001 From: SMTP Date: Tue, 12 May 2026 17:36:38 +0500 Subject: [PATCH] fix: ContainerTransferTask crash when transferring 0-count selection BreakSim creates a StackSelection with count=0 to represent an empty hand being acceptable. When the build engine resolved a WrongItemSelection result with this selection, it unconditionally called transferByTask, spawning a ContainerTransferTask that tried to move 0 items out of a shulker box which always failed with NoMaterialAccessException. Two fixes: - GenericResult.WrongItemSelection.resolve(): skip the transfer when count == 0, since nothing needs to be acquired. - ContainerTransferTask.checkFail(): was calling failure() unconditionally via lso {}, making failIfNoMaterial only affect the (unused) return value. Now correctly calls failure() only when failIfNoMaterial is true, and success() otherwise. --- .../simulation/result/results/GenericResult.kt | 1 + .../kotlin/com/lambda/task/tasks/ContainerTransferTask.kt | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt index 31c5ced68..cc37de76d 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt @@ -99,6 +99,7 @@ sealed class GenericResult : BuildResult() { context(task: Task<*>, _: AutomatedSafeContext) override fun resolve() { + if (neededSelection.count == 0) return neededSelection.transferByTask(HotbarContainer)?.softFail()?.execute(task) } diff --git a/src/main/kotlin/com/lambda/task/tasks/ContainerTransferTask.kt b/src/main/kotlin/com/lambda/task/tasks/ContainerTransferTask.kt index 4d92b7202..64332c87a 100644 --- a/src/main/kotlin/com/lambda/task/tasks/ContainerTransferTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/ContainerTransferTask.kt @@ -96,10 +96,10 @@ class ContainerTransferTask( } - private fun checkFail(): Boolean = - failIfNoMaterial.also { - failure(NoMaterialAccessException(stackSelection)) - } + private fun checkFail() { + if (failIfNoMaterial) failure(NoMaterialAccessException(stackSelection)) + else success() + } private class NoMaterialAccessException(stackSelection: StackSelection) : IllegalStateException("Unable to access $stackSelection.") } \ No newline at end of file