Skip to content

Commit bd00fb4

Browse files
committed
Nuker floor filling
1 parent 26c510a commit bd00fb4

File tree

1 file changed

+14
-18
lines changed
  • common/src/main/kotlin/com/lambda/module/modules/player

1 file changed

+14
-18
lines changed

common/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,51 @@
11
package com.lambda.module.modules.player
22

3-
import com.lambda.interaction.construction.DynamicBlueprint
43
import com.lambda.interaction.construction.DynamicBlueprint.Companion.blueprintOnTick
54
import com.lambda.interaction.construction.verify.TargetState
65
import com.lambda.module.Module
76
import com.lambda.module.tag.ModuleTag
8-
import com.lambda.task.Task
97
import com.lambda.task.Task.Companion.emptyTask
108
import com.lambda.task.tasks.BuildStructure.Companion.buildStructure
119
import com.lambda.util.BlockUtils.blockPos
1210
import com.lambda.util.BlockUtils.blockState
13-
import com.lambda.util.BlockUtils.instantBreakable
14-
import com.lambda.util.KeyCode
1511
import net.minecraft.util.math.BlockPos
16-
import net.minecraft.util.math.Vec3i
1712

1813
object Nuker : Module(
1914
name = "Nuker",
2015
description = "Breaks blocks around you",
2116
defaultTags = setOf(ModuleTag.PLAYER, ModuleTag.AUTOMATION)
2217
) {
18+
private val height by setting("Height", 4, 1..8, 1)
19+
private val width by setting("Width", 4, 1..8, 1)
2320
private val flatten by setting("Flatten", true)
2421
private val onlyBreakInstant by setting("Only Break Instant", true)
2522
private val fillFloor by setting("Fill Floor", false)
2623

27-
private val range = Vec3i(4, 4, 4) // TODO: Customizable
28-
private var task: Task<*> = emptyTask()
24+
private var task = emptyTask()
2925

3026
init {
3127
onEnable {
3228
task = buildStructure(
3329
pathing = false,
34-
finishOnDone = false
30+
finishOnDone = false,
31+
cancelOnUnsolvable = false
3532
) {
3633
blueprintOnTick { _ ->
37-
val selection = BlockPos.iterateOutwards(player.blockPos, range.x, range.y, range.z)
34+
val selection = BlockPos.iterateOutwards(player.blockPos, width, height, width)
3835
.asSequence()
3936
.map { it.blockPos }
4037
.filter { !world.isAir(it) }
4138
.filter { !flatten || it.y >= player.blockPos.y }
42-
.filter { !onlyBreakInstant || instantBreakable(it.blockState(world), it) }
39+
.filter { !onlyBreakInstant || it.blockState(world).getHardness(world, it) <= 1 }
40+
.filter { it.blockState(world).getHardness(world, it) >= 0 }
4341
.associateWith { TargetState.Air }
4442

45-
// if (fillFloor) {
46-
// // ToDo: Use smarter iteration pattern
47-
// val floor = BlockPos.iterateOutwards(player.blockPos, range.x, range.y, range.z)
48-
// .filter { it.y == player.blockPos.down().y }
49-
// .map { it.blockPos }
50-
// .associateWith { TargetState.Solid }
51-
// return@DynamicBlueprint selection + floor
52-
// }
43+
if (fillFloor) {
44+
val floor = BlockPos.iterateOutwards(player.blockPos.down(), width, 0, width)
45+
.map { it.blockPos }
46+
.associateWith { TargetState.Solid }
47+
return@blueprintOnTick selection + floor
48+
}
5349

5450
selection
5551
}

0 commit comments

Comments
 (0)