|
1 | 1 | package com.lambda.module.modules.player |
2 | 2 |
|
3 | | -import com.lambda.interaction.construction.DynamicBlueprint |
4 | 3 | import com.lambda.interaction.construction.DynamicBlueprint.Companion.blueprintOnTick |
5 | 4 | import com.lambda.interaction.construction.verify.TargetState |
6 | 5 | import com.lambda.module.Module |
7 | 6 | import com.lambda.module.tag.ModuleTag |
8 | | -import com.lambda.task.Task |
9 | 7 | import com.lambda.task.Task.Companion.emptyTask |
10 | 8 | import com.lambda.task.tasks.BuildStructure.Companion.buildStructure |
11 | 9 | import com.lambda.util.BlockUtils.blockPos |
12 | 10 | import com.lambda.util.BlockUtils.blockState |
13 | | -import com.lambda.util.BlockUtils.instantBreakable |
14 | | -import com.lambda.util.KeyCode |
15 | 11 | import net.minecraft.util.math.BlockPos |
16 | | -import net.minecraft.util.math.Vec3i |
17 | 12 |
|
18 | 13 | object Nuker : Module( |
19 | 14 | name = "Nuker", |
20 | 15 | description = "Breaks blocks around you", |
21 | 16 | defaultTags = setOf(ModuleTag.PLAYER, ModuleTag.AUTOMATION) |
22 | 17 | ) { |
| 18 | + private val height by setting("Height", 4, 1..8, 1) |
| 19 | + private val width by setting("Width", 4, 1..8, 1) |
23 | 20 | private val flatten by setting("Flatten", true) |
24 | 21 | private val onlyBreakInstant by setting("Only Break Instant", true) |
25 | 22 | private val fillFloor by setting("Fill Floor", false) |
26 | 23 |
|
27 | | - private val range = Vec3i(4, 4, 4) // TODO: Customizable |
28 | | - private var task: Task<*> = emptyTask() |
| 24 | + private var task = emptyTask() |
29 | 25 |
|
30 | 26 | init { |
31 | 27 | onEnable { |
32 | 28 | task = buildStructure( |
33 | 29 | pathing = false, |
34 | | - finishOnDone = false |
| 30 | + finishOnDone = false, |
| 31 | + cancelOnUnsolvable = false |
35 | 32 | ) { |
36 | 33 | blueprintOnTick { _ -> |
37 | | - val selection = BlockPos.iterateOutwards(player.blockPos, range.x, range.y, range.z) |
| 34 | + val selection = BlockPos.iterateOutwards(player.blockPos, width, height, width) |
38 | 35 | .asSequence() |
39 | 36 | .map { it.blockPos } |
40 | 37 | .filter { !world.isAir(it) } |
41 | 38 | .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 } |
43 | 41 | .associateWith { TargetState.Air } |
44 | 42 |
|
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 | + } |
53 | 49 |
|
54 | 50 | selection |
55 | 51 | } |
|
0 commit comments