Skip to content

Commit

Permalink
refactor(Scaffold): optimize block count calculation (#5678)
Browse files Browse the repository at this point in the history
  • Loading branch information
MukjepScarlet authored Feb 24, 2025
1 parent 346d85a commit 1d92ca5
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,13 @@ object ModuleScaffold : ClientModule("Scaffold", Category.WORLD) {

val blockCount: Int
get() {
val blockInMainHand = player.inventory.getStack(player.inventory.selectedSlot)
val blockInOffHand = player.offHandStack
fun ItemStack.blockCount() = if (isValidBlock(this)) this.count else 0

val blocks = hashSetOf(blockInMainHand, blockInOffHand)

if (ScaffoldAutoBlockFeature.enabled) {
findPlaceableSlots().mapTo(blocks) { it.value() }
return player.offHandStack.blockCount() + if (ScaffoldAutoBlockFeature.enabled) {
findPlaceableSlots().sumOf { it.value().blockCount() }
} else {
player.inventory.getStack(player.inventory.selectedSlot).blockCount()
}

return blocks.sumOf { if (isValidBlock(it)) it.count else 0 }
}

val isBlockBelow: Boolean
Expand Down

0 comments on commit 1d92ca5

Please sign in to comment.