Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/main/kotlin/com/lambda/module/modules/player/Printer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
package com.lambda.module.modules.player

import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
import com.lambda.config.applyEdits
import com.lambda.interaction.construction.blueprint.TickingBlueprint
import com.lambda.interaction.construction.verify.TargetState
import com.lambda.interaction.managers.interacting.InteractConfig
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.task.RootTask.run
Expand All @@ -38,8 +36,8 @@ object Printer : Module(
description = "Automatically prints schematics",
tag = ModuleTag.PLAYER
) {
private val range by setting("Range", 5, 1..7, 1)
private val air by setting("Air", false)
private val range by setting("Range", 5, 1..7, 1, description = "The range around the player to check for blocks to print")
private val air by setting("Air", false, description = "Consider breaking blocks in the world that are air in the schematic.\nNote: Breaking can also be disabled in the Automation Config.")

private var buildTask: Task<*>? = null

Expand All @@ -57,7 +55,7 @@ object Printer : Module(
BlockPos.iterateOutwards(player.blockPos, range, range, range)
.map { it.blockPos }
.asSequence()
.filter { DataManager.getRenderLayerRange().isPositionWithinRange(it) }
.filter { DataManager.getRenderLayerRange().isPositionWithinRange(it) && inSchematic(it) }
.associateWith { TargetState.State(schematicWorld.getBlockState(it)) }
.filter { air || !it.value.blockState.isAir }
}.build(finishOnDone = false).run()
Expand All @@ -66,6 +64,14 @@ object Printer : Module(
onDisable { buildTask?.cancel(); buildTask = null }
}

private fun inSchematic(pos: BlockPos): Boolean {
val placementManager = DataManager.getSchematicPlacementManager()
placementManager?.getAllPlacementsTouchingChunk(pos)?.forEach {
if (it.placement.isEnabled && it.bb.containsPos(pos)) return true
}
return false
}

private fun litematicaAvailable(): Boolean = runCatching {
Class.forName("fi.dy.masa.litematica.Litematica")
true
Expand Down