@@ -63,16 +63,17 @@ import net.minecraft.entity.ItemEntity
6363import net.minecraft.util.math.BlockPos
6464import java.util.concurrent.ConcurrentLinkedQueue
6565
66- class BuildTask @Ta5kBuilder constructor(
66+ class BuildTask private constructor(
6767 private val blueprint : Blueprint ,
68- private val finishOnDone : Boolean = true ,
69- private val collectDrops : Boolean = TaskFlowModule .build.collectDrops,
70- private val build : BuildConfig = TaskFlowModule .build,
71- private val rotation : RotationConfig = TaskFlowModule .rotation,
72- private val interactionConfig : InteractionConfig = TaskFlowModule .interaction,
73- private val inventory : InventoryConfig = TaskFlowModule .inventory,
74- private val hotbar : HotbarConfig = TaskFlowModule .hotbar,
75- private val eat : EatConfig = TaskFlowModule .eat,
68+ private val finishOnDone : Boolean ,
69+ private val collectDrops : Boolean ,
70+ private val build : BuildConfig ,
71+ private val rotation : RotationConfig ,
72+ private val interactionConfig : InteractionConfig ,
73+ private val inventory : InventoryConfig ,
74+ private val hotbar : HotbarConfig ,
75+ private val eat : EatConfig ,
76+ private val lifeMaintenance : Boolean ,
7677) : Task<Structure>() {
7778 override val name: String get() = " Building $blueprint with ${(breaks / (age / 20.0 + 0.001 )).string} b/s ${(placements / (age / 20.0 + 0.001 )).string} p/s"
7879
@@ -98,9 +99,8 @@ class BuildTask @Ta5kBuilder constructor(
9899
99100 init {
100101 listen<TickEvent .Pre > {
101- // val parentEating = (parent as? BuildTask)?.eatTask != null
102102 when {
103- eatTask == null && reasonEating(eat).shouldEat() -> {
103+ lifeMaintenance && eatTask == null && reasonEating(eat).shouldEat() -> {
104104 eatTask = eat(eat)
105105 eatTask?.finally {
106106 eatTask = null
@@ -255,8 +255,9 @@ class BuildTask @Ta5kBuilder constructor(
255255 inventory : InventoryConfig = TaskFlowModule .inventory,
256256 hotbar : HotbarConfig = TaskFlowModule .hotbar,
257257 eat : EatConfig = TaskFlowModule .eat,
258+ lifeMaintenance : Boolean = false,
258259 blueprint : () -> Blueprint ,
259- ) = BuildTask (blueprint(), finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat)
260+ ) = BuildTask (blueprint(), finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat, lifeMaintenance )
260261
261262 @Ta5kBuilder
262263 fun Structure.build (
@@ -268,7 +269,8 @@ class BuildTask @Ta5kBuilder constructor(
268269 inventory : InventoryConfig = TaskFlowModule .inventory,
269270 hotbar : HotbarConfig = TaskFlowModule .hotbar,
270271 eat : EatConfig = TaskFlowModule .eat,
271- ) = BuildTask (toBlueprint(), finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat)
272+ lifeMaintenance : Boolean = false,
273+ ) = BuildTask (toBlueprint(), finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat, lifeMaintenance)
272274
273275 @Ta5kBuilder
274276 fun Blueprint.build (
@@ -280,7 +282,8 @@ class BuildTask @Ta5kBuilder constructor(
280282 inventory : InventoryConfig = TaskFlowModule .inventory,
281283 hotbar : HotbarConfig = TaskFlowModule .hotbar,
282284 eat : EatConfig = TaskFlowModule .eat,
283- ) = BuildTask (this , finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat)
285+ lifeMaintenance : Boolean = false,
286+ ) = BuildTask (this , finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat, lifeMaintenance)
284287
285288 @Ta5kBuilder
286289 fun breakAndCollectBlock (
@@ -293,9 +296,10 @@ class BuildTask @Ta5kBuilder constructor(
293296 inventory : InventoryConfig = TaskFlowModule .inventory,
294297 hotbar : HotbarConfig = TaskFlowModule .hotbar,
295298 eat : EatConfig = TaskFlowModule .eat,
299+ lifeMaintenance : Boolean = false,
296300 ) = BuildTask (
297301 blockPos.toStructure(TargetState .Air ).toBlueprint(),
298- finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat
302+ finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat, lifeMaintenance
299303 )
300304
301305 @Ta5kBuilder
@@ -309,9 +313,10 @@ class BuildTask @Ta5kBuilder constructor(
309313 inventory : InventoryConfig = TaskFlowModule .inventory,
310314 hotbar : HotbarConfig = TaskFlowModule .hotbar,
311315 eat : EatConfig = TaskFlowModule .eat,
316+ lifeMaintenance : Boolean = false,
312317 ) = BuildTask (
313318 blockPos.toStructure(TargetState .Air ).toBlueprint(),
314- finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat
319+ finishOnDone, collectDrops, build, rotation, interact, inventory, hotbar, eat, lifeMaintenance
315320 )
316321 }
317322}
0 commit comments