Skip to content

Commit 720c120

Browse files
committed
Added WorldEater
1 parent 462f2e7 commit 720c120

File tree

4 files changed

+82
-2
lines changed

4 files changed

+82
-2
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.lambda.interaction.construction.simulation.BuildSimulator.simulate
77
import com.lambda.module.modules.client.TaskFlow
88
import com.lambda.task.Task
99
import com.lambda.threading.runSafe
10+
import com.lambda.util.BlockUtils.blockState
1011
import com.lambda.util.Communication.info
1112
import com.lambda.util.world.FastVector
1213
import com.lambda.util.world.toBlockPos
@@ -15,6 +16,7 @@ import com.lambda.util.world.toVec3d
1516
import net.minecraft.client.network.ClientPlayerEntity
1617
import net.minecraft.util.math.BlockPos
1718
import net.minecraft.util.math.Box
19+
import net.minecraft.util.math.Direction
1820
import net.minecraft.util.math.Vec3d
1921

2022
data class Simulation(val blueprint: Blueprint) {
@@ -26,7 +28,9 @@ data class Simulation(val blueprint: Blueprint) {
2628
val view = pos.toView()
2729
runSafe {
2830
if (blueprint.isOutOfBounds(view) && blueprint.getClosestPointTo(view).distanceTo(view) > 10.0) return@computeIfAbsent emptySet()
29-
if (!playerFitsIn(Vec3d.ofBottomCenter(pos.toBlockPos()))) return@computeIfAbsent emptySet()
31+
val blockPos = pos.toBlockPos()
32+
if (!playerFitsIn(Vec3d.ofBottomCenter(blockPos))) return@computeIfAbsent emptySet()
33+
if (!blockPos.down().blockState(world).isSideSolidFullSquare(world, blockPos, Direction.UP)) return@computeIfAbsent emptySet()
3034
}
3135
blueprint.simulate(view, reach = TaskFlow.interact.reach - 1)
3236
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.lambda.module.modules.player
2+
3+
import com.lambda.event.events.RenderEvent
4+
import com.lambda.event.listener.SafeListener.Companion.listener
5+
import com.lambda.graphics.renderer.esp.builders.buildOutline
6+
import com.lambda.interaction.construction.Blueprint.Companion.toStructure
7+
import com.lambda.interaction.construction.StaticBlueprint.Companion.toBlueprint
8+
import com.lambda.interaction.construction.verify.TargetState
9+
import com.lambda.module.Module
10+
import com.lambda.module.tag.ModuleTag
11+
import com.lambda.task.Task
12+
import com.lambda.task.tasks.BuildTask.Companion.build
13+
import com.lambda.util.BaritoneUtils
14+
import net.minecraft.util.math.BlockBox
15+
import net.minecraft.util.math.BlockPos
16+
import net.minecraft.util.math.Box
17+
import java.awt.Color
18+
19+
object WorldEater : Module(
20+
name = "WorldEater",
21+
description = "Eats the world",
22+
defaultTags = setOf(ModuleTag.PLAYER, ModuleTag.AUTOMATION)
23+
) {
24+
// private val height by setting("Height", 4, 1..10, 1)
25+
// private val width by setting("Width", 6, 1..30, 1)
26+
private val pos1 by setting("Position 1", BlockPos(351, 104, 103))
27+
private val pos2 by setting("Position 2", BlockPos(361, 70, 113))
28+
private val layerSize by setting("Layer Size", 1, 1..10, 1)
29+
private var runningTask: Task<*>? = null
30+
private var area = BlockBox.create(pos1, pos2)
31+
private val work = mutableListOf<BlockBox>()
32+
33+
init {
34+
onEnable {
35+
area = BlockBox.create(pos1, pos2)
36+
val layerRanges = (area.minY..area.maxY step layerSize).reversed()
37+
work.addAll(layerRanges.mapNotNull { y ->
38+
if (y == area.minY) return@mapNotNull null
39+
BlockBox(area.minX, y - layerSize, area.minZ, area.maxX, y, area.maxZ)
40+
})
41+
42+
buildLayer()
43+
}
44+
45+
onDisable {
46+
runningTask?.cancel()
47+
runningTask = null
48+
work.clear()
49+
BaritoneUtils.cancel()
50+
}
51+
52+
listener<RenderEvent.StaticESP> {
53+
it.renderer.buildOutline(Box.enclosing(pos1, pos2), Color.BLUE)
54+
}
55+
}
56+
57+
private fun buildLayer() {
58+
work.firstOrNull()?.let { box ->
59+
runningTask = build {
60+
box.toStructure(TargetState.Air)
61+
.toBlueprint()
62+
}.onSuccess { _, _ ->
63+
work.removeFirstOrNull()
64+
buildLayer()
65+
}.start(null)
66+
} ?: disable()
67+
}
68+
}

common/src/main/kotlin/com/lambda/task/tasks/BreakBlock.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ class BreakBlock @Ta5kBuilder constructor(
9191
}
9292

9393
BaritoneUtils.setGoalAndPath(GoalBlock(itemDrop.blockPos))
94+
return@listener
9495
} ?: BaritoneUtils.cancel()
9596

9697
if (isValid || !rotate || ctx.instantBreak) {
9798
breakBlock(ctx.result.side)
9899
}
99100

100101
if (done()) {
101-
state = State.COLLECTING
102102
if (!collectDrop) {
103103
BaritoneUtils.cancel()
104104
success(null)
@@ -113,6 +113,7 @@ class BreakBlock @Ta5kBuilder constructor(
113113
&& it.entity.pos.isInRange(blockPos.toCenterPos(), 0.5)
114114
) {
115115
drop = it.entity
116+
state = State.COLLECTING
116117
}
117118
}
118119
}

common/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lambda.task.tasks
22

3+
import baritone.api.pathing.goals.GoalNear
34
import com.lambda.Lambda.LOG
45
import com.lambda.context.SafeContext
56
import com.lambda.event.events.RenderEvent
@@ -99,6 +100,12 @@ class BuildTask @Ta5kBuilder constructor(
99100
result.collectDrop = collectDrops
100101
}
101102

103+
if (!(result is BreakResult.Break && result.collectDrop)) {
104+
if (pathing) BaritoneUtils.setGoalAndPath(
105+
GoalNear(result.blockPos, 4)
106+
)
107+
}
108+
102109
pending.add(result)
103110
result.start(this@BuildTask, pauseParent = result.pausesParent)
104111
}

0 commit comments

Comments
 (0)