From 596695b0fa55fd3ffe0cabd420588b9fddf167f9 Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Sat, 6 Dec 2025 05:57:42 +0000 Subject: [PATCH 1/7] working but needs major improvements --- .../com/lambda/config/AutomationConfig.kt | 6 +- .../lambda/config/MutableAutomationConfig.kt | 2 - .../com/lambda/config/groups/BreakSettings.kt | 2 +- .../lambda/config/groups/InteractSettings.kt | 19 +- .../com/lambda/config/groups/PlaceSettings.kt | 44 ---- .../kotlin/com/lambda/context/Automated.kt | 4 +- .../construction/context/InteractContext.kt | 24 ++- .../construction/context/PlaceContext.kt | 81 ------- .../processing/PlacementProcessor.kt | 19 +- .../processing/PreProcessingInfo.kt | 93 +++++++- .../PreProcessingInfoAccumulator.kt | 58 ----- .../processing/ProcessorRegistry.kt | 127 +++++------ .../preprocessors/DoorHingePreProcessor.kt | 58 ----- .../post/StandardInteractPreProcessor.kt | 35 +++ .../placement/pre}/AttachmentPreProcessor.kt | 27 ++- .../placement/pre}/AxisPreProcessor.kt | 19 +- .../placement/pre}/BlockFacePreProcessor.kt | 27 ++- .../placement/pre}/BlockHalfPreProcessor.kt | 17 +- .../placement/pre/DoorHingePreProcessor.kt | 55 +++++ .../pre}/HopperFacingPreProcessor.kt | 19 +- .../placement/pre}/SlabPreProcessor.kt | 25 +-- .../preprocessors/state/BambooPreProcessor.kt | 47 ++++ .../preprocessors/state/FirePreProcessor.kt | 39 ++++ .../state/FlowerPotPreProcessor.kt | 45 ++++ .../construction/result/Contextual.kt | 10 +- .../result/results/InteractResult.kt | 162 +++++++++++++- .../result/results/PlaceResult.kt | 204 ------------------ .../construction/simulation/BuildSimulator.kt | 25 +-- .../construction/simulation/ISimInfo.kt | 110 ---------- .../construction/simulation/Results.kt | 6 +- .../construction/simulation/Sim.kt | 10 +- .../construction/simulation/SimInfo.kt | 150 +++++++++++++ .../simulation/checks/BasicChecker.kt | 3 +- .../simulation/checks/BreakSim.kt | 17 +- .../checks/{PlaceSim.kt => InteractSim.kt} | 159 ++++++++------ .../simulation/checks/PostProcessingSim.kt | 167 -------------- .../construction/verify/TargetState.kt | 31 +-- .../request/breaking/BreakConfig.kt | 2 +- .../request/breaking/BreakManager.kt | 5 +- .../request/interacting/InteractConfig.kt | 36 +++- .../request/interacting/InteractInfo.kt | 17 +- .../InteractManager.kt} | 198 ++++++++--------- .../request/interacting/InteractRequest.kt | 75 ++++++- .../interacting/InteractedBlockHandler.kt | 26 +-- .../request/interacting/InteractionManager.kt | 180 ---------------- .../request/inventory/InventoryManager.kt | 6 +- .../request/placing/PlaceConfig.kt | 58 ----- .../interaction/request/placing/PlaceInfo.kt | 42 ---- .../request/placing/PlaceRequest.kt | 109 ---------- .../request/placing/PlacedBlockHandler.kt | 75 ------- .../rotating/visibilty/VisibilityChecker.kt | 2 +- .../lambda/module/modules/combat/KillAura.kt | 2 +- .../lambda/module/modules/player/FastBreak.kt | 2 +- .../lambda/module/modules/player/Printer.kt | 4 +- .../lambda/module/modules/player/Scaffold.kt | 17 +- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 24 +-- .../com/lambda/task/tasks/PlaceContainer.kt | 4 +- 57 files changed, 1137 insertions(+), 1693 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/config/groups/PlaceSettings.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfoAccumulator.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/DoorHingePreProcessor.kt create mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt rename src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/{ => property/placement/pre}/AttachmentPreProcessor.kt (60%) rename src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/{ => property/placement/pre}/AxisPreProcessor.kt (67%) rename src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/{ => property/placement/pre}/BlockFacePreProcessor.kt (60%) rename src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/{ => property/placement/pre}/BlockHalfPreProcessor.kt (74%) create mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt rename src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/{ => property/placement/pre}/HopperFacingPreProcessor.kt (64%) rename src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/{ => property/placement/pre}/SlabPreProcessor.kt (68%) create mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt create mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt create mode 100644 src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/construction/result/results/PlaceResult.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/construction/simulation/ISimInfo.kt create mode 100644 src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt rename src/main/kotlin/com/lambda/interaction/construction/simulation/checks/{PlaceSim.kt => InteractSim.kt} (67%) delete mode 100644 src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PostProcessingSim.kt rename src/main/kotlin/com/lambda/interaction/request/{placing/PlaceManager.kt => interacting/InteractManager.kt} (65%) delete mode 100644 src/main/kotlin/com/lambda/interaction/request/interacting/InteractionManager.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/request/placing/PlaceConfig.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/request/placing/PlaceInfo.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/request/placing/PlaceRequest.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/request/placing/PlacedBlockHandler.kt diff --git a/src/main/kotlin/com/lambda/config/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/AutomationConfig.kt index 4e1039ad5..03b6640bc 100644 --- a/src/main/kotlin/com/lambda/config/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/AutomationConfig.kt @@ -22,9 +22,8 @@ import com.lambda.config.groups.BreakSettings import com.lambda.config.groups.BuildSettings import com.lambda.config.groups.EatSettings import com.lambda.config.groups.HotbarSettings -import com.lambda.config.groups.InteractSettings import com.lambda.config.groups.InventorySettings -import com.lambda.config.groups.PlaceSettings +import com.lambda.config.groups.InteractSettings import com.lambda.config.groups.RotationSettings import com.lambda.context.Automated import com.lambda.event.events.onStaticRender @@ -52,8 +51,7 @@ open class AutomationConfig( override val buildConfig = BuildSettings(this, Group.Build) override val breakConfig = BreakSettings(this, Group.Break) - override val placeConfig = PlaceSettings(this, Group.Place) - override val interactConfig = InteractSettings(this, Group.Interact) + override val interactConfig = InteractSettings(this, Group.Place) override val rotationConfig = RotationSettings(this, Group.Rotation) override val inventoryConfig = InventorySettings(this, Group.Inventory) override val hotbarConfig = HotbarSettings(this, Group.Hotbar) diff --git a/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt index ee9bf5aca..c7142ae45 100644 --- a/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt @@ -24,7 +24,6 @@ import com.lambda.interaction.request.breaking.BreakConfig import com.lambda.interaction.request.hotbar.HotbarConfig import com.lambda.interaction.request.interacting.InteractConfig import com.lambda.interaction.request.inventory.InventoryConfig -import com.lambda.interaction.request.placing.PlaceConfig import com.lambda.interaction.request.rotating.RotationConfig interface MutableAutomationConfig : Automated { @@ -34,7 +33,6 @@ interface MutableAutomationConfig : Automated { override val buildConfig: BuildConfig get() = automationConfig.buildConfig override val breakConfig: BreakConfig get() = automationConfig.breakConfig - override val placeConfig: PlaceConfig get() = automationConfig.placeConfig override val interactConfig: InteractConfig get() = automationConfig.interactConfig override val rotationConfig: RotationConfig get() = automationConfig.rotationConfig override val inventoryConfig: InventoryConfig get() = automationConfig.inventoryConfig diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt index 503dafe58..a3117d806 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt @@ -67,7 +67,7 @@ open class BreakSettings( override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None }.group(baseGroup, Group.General).index() // Rotate - override val rotateForBreak by c.setting("Rotate For Break", false, "Rotate towards block while breaking").group(baseGroup, Group.General).index() + override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking").group(baseGroup, Group.General).index() // Pending / Post override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking").group(baseGroup, Group.General).index() diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index c939a1198..0b273157f 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -22,16 +22,23 @@ import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.interaction.request.interacting.InteractConfig +import com.lambda.interaction.request.interacting.InteractConfig.AirPlaceMode +import com.lambda.interaction.request.interacting.InteractConfig.PlaceConfirmationMode import com.lambda.util.NamedEnum class InteractSettings( c: Configurable, baseGroup: NamedEnum ) : SettingGroup(c), InteractConfig { - override val rotate by c.setting("Rotate For Interact", true, "Rotates the player to look at the block when interacting").group(baseGroup).index() - override val sorter by c.setting("Interact Sorter", ActionConfig.SortMode.Tool, "The order in which interactions are performed").group(baseGroup).index() - override val swingHand by c.setting("Swing On Interact", true, "Swings the players hand after interacting").group(baseGroup).index() - override val tickStageMask by c.setting("Interact Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which interact actions are performed").group(baseGroup).index() - override val interactSwingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swingHand }.group(baseGroup).index() - override val interactConfirmationMode by c.setting("Interact Confirmation Mode", InteractConfig.InteractConfirmationMode.InteractThenAwait, "The style of confirmation for interactions").group(baseGroup).index() + override val rotate by c.setting("Rotate For Place", true, "Rotate towards block while placing").group(baseGroup).index() + override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index() + override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled }.group(baseGroup).index() + override val sorter by c.setting("Place Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index() + override val tickStageMask by c.setting("Place Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which place actions are performed").group(baseGroup).index() + override val placeConfirmationMode by c.setting("Place Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index() + override val maxPendingPlacements by c.setting("Max Pending Placements", 5, 0..30, 1, "The maximum amount of pending placements").group(baseGroup).index() + override val placementsPerTick by c.setting("Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index() + override val swing by c.setting("Swing On Place", true, "Swings the players hand when placing").group(baseGroup).index() + override val swingType by c.setting("Place Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing }.group(baseGroup).index() + override val sounds by c.setting("Place Sounds", true, "Plays the placing sounds").group(baseGroup).index() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/PlaceSettings.kt b/src/main/kotlin/com/lambda/config/groups/PlaceSettings.kt deleted file mode 100644 index 332ddeaeb..000000000 --- a/src/main/kotlin/com/lambda/config/groups/PlaceSettings.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Configurable -import com.lambda.config.SettingGroup -import com.lambda.event.events.TickEvent -import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.request.placing.PlaceConfig -import com.lambda.interaction.request.placing.PlaceConfig.AirPlaceMode -import com.lambda.interaction.request.placing.PlaceConfig.PlaceConfirmationMode -import com.lambda.util.NamedEnum - -class PlaceSettings( - c: Configurable, - baseGroup: NamedEnum -) : SettingGroup(c), PlaceConfig { - override val rotateForPlace by c.setting("Rotate For Place", true, "Rotate towards block while placing").group(baseGroup).index() - override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index() - override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled }.group(baseGroup).index() - override val sorter by c.setting("Place Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index() - override val tickStageMask by c.setting("Place Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which place actions are performed").group(baseGroup).index() - override val placeConfirmationMode by c.setting("Place Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index() - override val maxPendingPlacements by c.setting("Max Pending Placements", 5, 0..30, 1, "The maximum amount of pending placements").group(baseGroup).index() - override val placementsPerTick by c.setting("Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index() - override val swing by c.setting("Swing On Place", true, "Swings the players hand when placing").group(baseGroup).index() - override val swingType by c.setting("Place Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing }.group(baseGroup).index() - override val sounds by c.setting("Place Sounds", true, "Plays the placing sounds").group(baseGroup).index() -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/context/Automated.kt b/src/main/kotlin/com/lambda/context/Automated.kt index e5e6bbea5..efada2284 100644 --- a/src/main/kotlin/com/lambda/context/Automated.kt +++ b/src/main/kotlin/com/lambda/context/Automated.kt @@ -21,15 +21,13 @@ import com.lambda.config.groups.BuildConfig import com.lambda.config.groups.EatConfig import com.lambda.interaction.request.breaking.BreakConfig import com.lambda.interaction.request.hotbar.HotbarConfig -import com.lambda.interaction.request.interacting.InteractConfig import com.lambda.interaction.request.inventory.InventoryConfig -import com.lambda.interaction.request.placing.PlaceConfig +import com.lambda.interaction.request.interacting.InteractConfig import com.lambda.interaction.request.rotating.RotationConfig interface Automated { val buildConfig: BuildConfig val breakConfig: BreakConfig - val placeConfig: PlaceConfig val interactConfig: InteractConfig val rotationConfig: RotationConfig val inventoryConfig: InventoryConfig diff --git a/src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt b/src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt index 22cff3a99..5b3aabc0b 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt @@ -32,18 +32,20 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box import java.awt.Color -class InteractContext( +data class InteractContext( override val hitResult: BlockHitResult, override val rotationRequest: RotationRequest, override var hotbarIndex: Int, + override val blockPos: BlockPos, override var cachedState: BlockState, override val expectedState: BlockState, - val automated: Automated + val placing: Boolean, + val sneak: Boolean, + val currentDirIsValid: Boolean = false, + private val automated: Automated ) : BuildContext(), LogContext, Automated by automated { - private val baseColor = Color(35, 254, 79, 25) - private val sideColor = Color(35, 254, 79, 100) - - override val blockPos: BlockPos = hitResult.blockPos + private val baseColor = Color(35, 188, 254, 50) + private val sideColor = Color(35, 188, 254, 100) override val sorter get() = interactConfig.sorter @@ -58,19 +60,23 @@ class InteractContext( } fun requestDependencies(request: InteractRequest): Boolean { - val hotbarRequest = submit(HotbarRequest(hotbarIndex, request), false) - val validRotation = if (request.interactConfig.rotate) submit(rotationRequest, false).done else true + val hotbarRequest = submit(HotbarRequest(hotbarIndex, this), false) + val validRotation = if (request.interactConfig.rotate) { + submit(rotationRequest, false).done && currentDirIsValid + } else true return hotbarRequest.done && validRotation } override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = { - group("Interaction Context") { + group("Place Context") { text(blockPos.getLogContextBuilder()) text(hitResult.getLogContextBuilder()) text(rotationRequest.getLogContextBuilder()) value("Hotbar Index", hotbarIndex) value("Cached State", cachedState) value("Expected State", expectedState) + value("Sneak", sneak) + value("Current Dir Is Valid", currentDirIsValid) } } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt b/src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt deleted file mode 100644 index 781bd4086..000000000 --- a/src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.construction.context - -import com.lambda.context.Automated -import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.LogContext.Companion.getLogContextBuilder -import com.lambda.interaction.request.Request.Companion.submit -import com.lambda.interaction.request.hotbar.HotbarRequest -import com.lambda.interaction.request.placing.PlaceRequest -import com.lambda.interaction.request.rotating.RotationRequest -import net.minecraft.block.BlockState -import net.minecraft.util.hit.BlockHitResult -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box -import java.awt.Color - -data class PlaceContext( - override val hitResult: BlockHitResult, - override val rotationRequest: RotationRequest, - override var hotbarIndex: Int, - override val blockPos: BlockPos, - override var cachedState: BlockState, - override val expectedState: BlockState, - val sneak: Boolean, - val currentDirIsValid: Boolean = false, - private val automated: Automated -) : BuildContext(), LogContext, Automated by automated { - private val baseColor = Color(35, 188, 254, 50) - private val sideColor = Color(35, 188, 254, 100) - - override val sorter get() = placeConfig.sorter - - override fun ShapeBuilder.buildRenderer() { - val box = with(hitResult.pos) { - Box( - x - 0.05, y - 0.05, z - 0.05, - x + 0.05, y + 0.05, z + 0.05, - ).offset(hitResult.side.doubleVector.multiply(0.05)) - } - box(box, baseColor, sideColor) - } - - fun requestDependencies(request: PlaceRequest): Boolean { - val hotbarRequest = submit(HotbarRequest(hotbarIndex, this), false) - val validRotation = if (request.placeConfig.rotateForPlace) { - submit(rotationRequest, false).done && currentDirIsValid - } else true - return hotbarRequest.done && validRotation - } - - override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = { - group("Place Context") { - text(blockPos.getLogContextBuilder()) - text(hitResult.getLogContextBuilder()) - text(rotationRequest.getLogContextBuilder()) - value("Hotbar Index", hotbarIndex) - value("Cached State", cachedState) - value("Expected State", expectedState) - value("Sneak", sneak) - value("Current Dir Is Valid", currentDirIsValid) - } - } -} diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt index 5fa00bfa2..b4b23e453 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.construction.processing +import com.lambda.context.SafeContext import net.minecraft.block.BlockState import net.minecraft.util.math.BlockPos @@ -25,7 +26,19 @@ import net.minecraft.util.math.BlockPos * optimize how blocks are simulated. Some blocks might only be placeable on certain sides, so it is * unnecessary to scan all of them, for example. */ -abstract class PlacementProcessor { - abstract fun acceptsState(state: BlockState): Boolean - abstract fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) + +interface StateProcessor { + fun acceptsState(state: BlockState, targetState: BlockState): Boolean + context(safeContext: SafeContext) + fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) +} + +interface PropertyPreProcessor { + fun acceptsState(targetState: BlockState): Boolean + fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) +} + +interface PropertyPostProcessor { + fun acceptsState(state: BlockState, targetState: BlockState): Boolean + fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt index 83247f93c..37fc2f062 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt @@ -17,20 +17,103 @@ package com.lambda.interaction.construction.processing +import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.construction.verify.SurfaceScan +import com.lambda.interaction.construction.verify.TargetState +import net.minecraft.block.BlockState +import net.minecraft.item.Item import net.minecraft.state.property.Property +import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction interface PreProcessingInfo { val surfaceScan: SurfaceScan val ignore: Set> val sides: Set + val item: Item? + val expectedState: BlockState + val placing: Boolean + val noCaching: Boolean companion object { - val DEFAULT = object : PreProcessingInfo { - override val surfaceScan = SurfaceScan.DEFAULT - override val ignore = setOf>() - override val sides = Direction.entries.toSet() - } + context(_: AutomatedSafeContext) + fun default(targetState: TargetState, pos: BlockPos) = object : PreProcessingInfo { + override val surfaceScan = SurfaceScan.DEFAULT + override val ignore = setOf>() + override val sides = Direction.entries.toSet() + override val item = targetState.getStack(pos).item + override val expectedState = targetState.getState(pos) + override val placing = true + override val noCaching = true + } } +} + +class PreProcessingInfoAccumulator( + override var expectedState: BlockState, + override var item: Item?, + override var surfaceScan: SurfaceScan = SurfaceScan.DEFAULT, + override val ignore: MutableSet> = ProcessorRegistry.postProcessedProperties.toMutableSet(), + override val sides: MutableSet = Direction.entries.toMutableSet(), + override var placing: Boolean = true, + override var noCaching: Boolean = false, + var omitPlacement: Boolean = false +) : PreProcessingInfo { + @InfoAccumulator + fun offerSurfaceScan(scan: SurfaceScan) { + if (scan.mode.priority > surfaceScan.mode.priority) { + surfaceScan = scan + } + } + + @InfoAccumulator + fun addIgnores(vararg properties: Property<*>) { + ignore.addAll(properties) + } + + @InfoAccumulator + fun retainSides(predicate: (Direction) -> Boolean) { + sides.retainAll(predicate) + } + + @InfoAccumulator + fun retainSides(vararg sides: Direction) { + this.sides.retainAll(sides.toSet()) + } + + @InfoAccumulator + @JvmName("setExpectedState1") + fun setExpectedState(expectedState: BlockState) { + this.expectedState = expectedState + } + + @InfoAccumulator + @JvmName("setItem1") + fun setItem(item: Item?) { + this.item = item + } + + @InfoAccumulator + @JvmName("setPlacing1") + fun setPlacing(placing: Boolean) { + this.placing = placing + } + + @InfoAccumulator + fun noCaching() { + noCaching = true + } + + @InfoAccumulator + fun omitPlacement() { + omitPlacement = true + } + + @InfoAccumulator + fun complete(): PreProcessingInfo = this + + companion object { + @DslMarker + private annotation class InfoAccumulator + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfoAccumulator.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfoAccumulator.kt deleted file mode 100644 index 846a2ca87..000000000 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfoAccumulator.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.construction.processing - -import com.lambda.interaction.construction.verify.SurfaceScan -import net.minecraft.state.property.Property -import net.minecraft.util.math.Direction - -class PreProcessingInfoAccumulator( - override var surfaceScan: SurfaceScan = SurfaceScan.DEFAULT, - override val ignore: MutableSet> = ProcessorRegistry.postProcessedProperties.toMutableSet(), - override val sides: MutableSet = Direction.entries.toMutableSet(), -) : PreProcessingInfo { - @InfoAccumulator - fun offerSurfaceScan(scan: SurfaceScan) { - if (scan.mode.priority > surfaceScan.mode.priority) { - surfaceScan = scan - } - } - - @InfoAccumulator - fun addIgnores(vararg properties: Property<*>) { - ignore.addAll(properties) - } - - @InfoAccumulator - fun retainSides(predicate: (Direction) -> Boolean) { - sides.retainAll(predicate) - } - - @InfoAccumulator - fun retainSides(vararg sides: Direction) { - this.sides.retainAll(sides.toSet()) - } - - @InfoAccumulator - fun complete() = this as PreProcessingInfo - - companion object { - @DslMarker - private annotation class InfoAccumulator - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt index 90922d1c8..2b856f3fa 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt @@ -17,26 +17,24 @@ package com.lambda.interaction.construction.processing +import com.lambda.context.AutomatedSafeContext +import com.lambda.context.SafeContext import com.lambda.core.Loadable -import com.lambda.interaction.construction.processing.ProcessorRegistry.IntermediaryInfo.Companion.intermediaryInfo +import com.lambda.interaction.construction.processing.PreProcessingInfo.Companion.default +import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.verify.TargetState -import com.lambda.util.BlockUtils -import com.lambda.util.BlockUtils.item import com.lambda.util.reflections.getInstances -import net.minecraft.block.Block import net.minecraft.block.BlockState -import net.minecraft.block.Blocks -import net.minecraft.block.FlowerPotBlock -import net.minecraft.item.Item -import net.minecraft.item.Items +import net.minecraft.item.ItemStack import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Direction import java.util.* -object ProcessorRegistry : Loadable { - private val processors = getInstances() - private val processorCache = Collections.synchronizedMap(mutableMapOf()) +object ProcessorRegistry : Loadable{ + private val stateProcessors = getInstances() + private val propertyPreProcessors = getInstances() + private val propertyPostProcessors = getInstances() + private val processorCache = Collections.synchronizedMap, PreProcessingInfo?>(mutableMapOf()) /** * List of properties that can be processed after the block is placed. This is often used to ignore these properties @@ -91,7 +89,6 @@ object ProcessorRegistry : Loadable { Properties.POWER, Properties.STAGE, Properties.CHARGES, - Properties.CHEST_TYPE, Properties.COMPARATOR_MODE, Properties.INSTRUMENT, Properties.STAIR_SHAPE, @@ -117,23 +114,16 @@ object ProcessorRegistry : Loadable { Properties.DISTANCE_1_7 ) - /** - * Map of blocks that get placed as a different [Block] type, to then be updated afterward. Bamboo and potted flowers are - * two examples. - * - * @see IntermediaryInfo - */ - val intermediaryBlockMap = buildMap { - this[Blocks.BAMBOO] = intermediaryInfo(IntermediaryProcess(Blocks.BAMBOO_SAPLING, item = Items.BAMBOO)) - BlockUtils.pottedBlocks.forEach { - this[it] = intermediaryInfo( - IntermediaryProcess(Blocks.FLOWER_POT, item = Items.FLOWER_POT), - IntermediaryProcess(Blocks.FLOWER_POT, it, (it as FlowerPotBlock).content.item) - ) - } - } + val standardInteractProperties = setOf( + Properties.INVERTED, + Properties.DELAY, + Properties.COMPARATOR_MODE, + Properties.OPEN, + Properties.NOTE, - override fun load() = "Loaded ${processors.size} pre processors" + ) + + override fun load() = "Loaded ${propertyPreProcessors.size} pre processors" /** * [PreProcessingInfo]'s are cached to avoid duplicate computations as block states are immutable. @@ -142,58 +132,43 @@ object ProcessorRegistry : Loadable { * each pre-processor checking if the state can be accepted. If so, the state is passed through the pre-processor * which can call the functions within the [PreProcessingInfoAccumulator] DSL to modify the information. */ - fun TargetState.getProcessingInfo(pos: BlockPos): PreProcessingData? { - if (this !is TargetState.State) return PreProcessingData(PreProcessingInfo.DEFAULT, pos) - - val get: () -> PreProcessingInfo? = get@{ - val infoAccumulator = PreProcessingInfoAccumulator() + @SimDsl + fun AutomatedSafeContext.getProcessingInfo(state: BlockState, targetState: TargetState, pos: BlockPos): PreProcessingData? { + val targetBlockState = (targetState as? TargetState.State)?.blockState + ?: return PreProcessingData(default(targetState, pos), pos) - processors.forEach { processor -> - if (!processor.acceptsState(blockState)) return@forEach - processor.preProcess(blockState, pos, infoAccumulator) - } - - infoAccumulator.complete() + val processorCacheKey = state to targetBlockState + val preProcessingInfo = processorCache.getOrElse(processorCacheKey) { + preProcess(pos, state, targetBlockState, targetState.getStack(pos)).also { info -> + if (info?.noCaching != true) processorCache[processorCacheKey] = info + } } - val preProcessingInfo = processorCache.getOrPut(blockState, get) ?: return null - return PreProcessingData(preProcessingInfo, pos) - } - /** - * Contains the starting initial block placement and any subsequent intermediary processes to transform the placement - * into the final block. - * - * @see IntermediaryProcess - */ - data class IntermediaryInfo private constructor( - val startBlock: IntermediaryProcess, - val intermediaryProcesses: List = emptyList(), - ) { - fun getIntermediaryProcess(state: BlockState) = intermediaryProcesses.firstOrNull { it.block === state.block } - fun isIntermediaryBlock(state: BlockState) = intermediaryProcesses.any { - it.block === state.block || it.targetBlock === state.block - } || startBlock.targetBlock === state.block - - companion object { - fun intermediaryInfo( - startingBlock: IntermediaryProcess, - vararg intermediaryProcesses: IntermediaryProcess - ) = IntermediaryInfo(startingBlock, intermediaryProcesses.toList()) - } + return PreProcessingData(preProcessingInfo ?: return null, pos) } - /** - * Holds the required information for placing a [Block] with more than one placement to achieve its target. - * - * The use of [Block] instead of [BlockState] here is intentional as we would only have to alter the [Properties]s - * if the placement was the correct [BlockState]. This is only used when one [Block] needs to transform into another. - */ - data class IntermediaryProcess( - val block: Block, - val targetBlock: Block = block, - val item: Item, - val sides: Set = Direction.entries.toSet() - ) + context(safeContext: SafeContext) + private fun preProcess(pos: BlockPos, state: BlockState, targetState: BlockState, itemStack: ItemStack) = + PreProcessingInfoAccumulator(targetState, itemStack.item).run { + val stateProcessing = stateProcessors.any { processor -> + processor.acceptsState(state, targetState).also { accepted -> + if (accepted) + with(processor) { preProcess(state, targetState, pos) } + } + } + if (omitPlacement) return@run complete() + if (!stateProcessing) { + if (!state.isReplaceable && state.block != expectedState.block) return@run null + if (state.block != expectedState.block) propertyPreProcessors.forEach { processor -> + if (processor.acceptsState(targetState)) + with(processor) { preProcess(state, expectedState) } + } else propertyPostProcessors.forEach { processor -> + if (processor.acceptsState(state, expectedState)) + with(processor) { preProcess(state, expectedState) } + } + } + complete() + } } data class PreProcessingData(val info: PreProcessingInfo, val pos: BlockPos) diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/DoorHingePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/DoorHingePreProcessor.kt deleted file mode 100644 index 251965755..000000000 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/DoorHingePreProcessor.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.construction.processing.preprocessors - -import com.lambda.interaction.construction.processing.PlacementProcessor -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.verify.ScanMode -import com.lambda.interaction.construction.verify.SurfaceScan -import com.lambda.threading.runSafe -import net.minecraft.block.BlockState -import net.minecraft.block.enums.DoorHinge -import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Direction - -// Collected using reflections and then accessed from a collection in ProcessorRegistry -@Suppress("unused") -object DoorHingePreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = - state.properties.contains(Properties.DOOR_HINGE) - - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) = - runSafe { - val side = state.get(Properties.DOOR_HINGE) ?: return@runSafe - val scanner = when (state.get(Properties.HORIZONTAL_FACING) ?: return@runSafe) { - Direction.NORTH -> - if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.X) - else SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.X) - Direction.EAST -> - if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Z) - else SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Z) - Direction.SOUTH -> - if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.X) - else SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.X) - Direction.DOWN, - Direction.UP, - Direction.WEST -> - if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Z) - else SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Z) - } - accumulator.offerSurfaceScan(scanner) - } ?: Unit -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt new file mode 100644 index 000000000..6510755bf --- /dev/null +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2025 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.interaction.construction.processing.preprocessors.property.placement.post + +import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.ProcessorRegistry.standardInteractProperties +import com.lambda.interaction.construction.processing.PropertyPostProcessor +import net.minecraft.block.BlockState + +object StandardInteractPreProcessor : PropertyPostProcessor { + override fun acceptsState(state: BlockState, targetState: BlockState) = + standardInteractProperties.any { + it in targetState && state.get(it) != targetState.get(it) + } + + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + setItem(null) + setPlacing(false) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/AttachmentPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt similarity index 60% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/AttachmentPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt index 08c27312f..64d0b0e63 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/AttachmentPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt @@ -15,30 +15,27 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PlacementProcessor import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.block.enums.Attachment import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction // Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") -object AttachmentPreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = - state.properties.contains(Properties.ATTACHMENT) +object AttachmentPreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = + Properties.ATTACHMENT in targetState - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) { - val attachment = state.get(Properties.ATTACHMENT) ?: return - with(accumulator) { - when (attachment) { - Attachment.FLOOR -> retainSides(Direction.DOWN) - Attachment.CEILING -> retainSides(Direction.UP) - else -> retainSides { it in Direction.Type.HORIZONTAL } - } - } + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val attachment = targetState.get(Properties.ATTACHMENT) ?: return + when (attachment) { + Attachment.FLOOR -> retainSides(Direction.DOWN) + Attachment.CEILING -> retainSides(Direction.UP) + else -> retainSides { it in Direction.Type.HORIZONTAL } + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/AxisPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt similarity index 67% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/AxisPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt index 0142ae768..8564b46e4 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/AxisPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt @@ -15,24 +15,21 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PlacementProcessor import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos // Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") -object AxisPreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = - state.getOrEmpty(Properties.AXIS).isPresent +object AxisPreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = + Properties.AXIS in targetState - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) { - val axis = state.get(Properties.AXIS) - accumulator.retainSides { side -> - side.axis == axis - } + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val axis = targetState.get(Properties.AXIS) + retainSides { side -> side.axis == axis } } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/BlockFacePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt similarity index 60% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/BlockFacePreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt index b39dd5f04..59117c858 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/BlockFacePreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt @@ -15,30 +15,27 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PlacementProcessor import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.block.enums.BlockFace import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction // Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") -object BlockFacePreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = - state.getOrEmpty(Properties.BLOCK_FACE).isPresent +object BlockFacePreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = + Properties.BLOCK_FACE in targetState - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) { - val property = state.get(Properties.BLOCK_FACE) ?: return - with(accumulator) { - when (property) { - BlockFace.FLOOR -> retainSides(Direction.DOWN) - BlockFace.CEILING -> retainSides(Direction.UP) - BlockFace.WALL -> retainSides { it in Direction.Type.HORIZONTAL } - } - } + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val property = targetState.get(Properties.BLOCK_FACE) ?: return + when (property) { + BlockFace.FLOOR -> retainSides(Direction.DOWN) + BlockFace.CEILING -> retainSides(Direction.UP) + BlockFace.WALL -> retainSides { it in Direction.Type.HORIZONTAL } + } } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/BlockHalfPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt similarity index 74% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/BlockHalfPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt index 4b883645f..2bac9c78a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/BlockHalfPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt @@ -15,32 +15,31 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PlacementProcessor import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan import net.minecraft.block.BlockState import net.minecraft.block.enums.BlockHalf import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction // Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") -object BlockHalfPreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = - state.getOrEmpty(Properties.BLOCK_HALF).isPresent +object BlockHalfPreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = + Properties.BLOCK_HALF in targetState - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) { - val slab = state.get(Properties.BLOCK_HALF) ?: return + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val slab = targetState.get(Properties.BLOCK_HALF) ?: return val surfaceScan = when (slab) { BlockHalf.BOTTOM -> SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Y) BlockHalf.TOP -> SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Y) } - accumulator.offerSurfaceScan(surfaceScan) + offerSurfaceScan(surfaceScan) } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt new file mode 100644 index 000000000..6f41d2e39 --- /dev/null +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2025 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre + +import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.verify.ScanMode +import com.lambda.interaction.construction.verify.SurfaceScan +import net.minecraft.block.BlockState +import net.minecraft.block.enums.DoorHinge +import net.minecraft.state.property.Properties +import net.minecraft.util.math.Direction + +// Collected using reflections and then accessed from a collection in ProcessorRegistry +@Suppress("unused") +object DoorHingePreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = + Properties.DOOR_HINGE in targetState + + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val side = targetState.get(Properties.DOOR_HINGE) ?: return + val scanner = when (targetState.get(Properties.HORIZONTAL_FACING) ?: return) { + Direction.NORTH -> + if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.X) + else SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.X) + Direction.EAST -> + if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Z) + else SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Z) + Direction.SOUTH -> + if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.X) + else SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.X) + Direction.DOWN, + Direction.UP, + Direction.WEST -> + if (side == DoorHinge.LEFT) SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Z) + else SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Z) + } + return offerSurfaceScan(scanner) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/HopperFacingPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt similarity index 64% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/HopperFacingPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt index f37848f58..eb091d8ba 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/HopperFacingPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt @@ -15,26 +15,25 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PlacementProcessor import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction // Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") -object HopperFacingPreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = - state.properties.contains(Properties.HOPPER_FACING) +object HopperFacingPreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = + Properties.HOPPER_FACING in targetState - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) { - val facing = state.get(Properties.HOPPER_FACING) ?: return + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val facing = targetState.get(Properties.HOPPER_FACING) ?: return when { - facing.axis == Direction.Axis.Y -> accumulator.retainSides { it.axis == Direction.Axis.Y } - else -> accumulator.retainSides(facing) + facing.axis == Direction.Axis.Y -> retainSides { it.axis == Direction.Axis.Y } + else -> retainSides(facing) } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/SlabPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt similarity index 68% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/SlabPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt index d1fefe8ba..d826afb2f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/SlabPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt @@ -15,43 +15,40 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors +package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PlacementProcessor import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.PropertyPreProcessor import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan -import com.lambda.threading.runSafe -import com.lambda.util.BlockUtils.blockState import net.minecraft.block.BlockState import net.minecraft.block.SlabBlock import net.minecraft.block.enums.SlabType import net.minecraft.state.property.Properties -import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction // Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") -object SlabPreProcessor : PlacementProcessor() { - override fun acceptsState(state: BlockState) = state.block is SlabBlock +object SlabPreProcessor : PropertyPreProcessor { + override fun acceptsState(targetState: BlockState) = targetState.block is SlabBlock - override fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator) { - val slab = state.get(Properties.SLAB_TYPE) ?: return - val currentState = runSafe { blockState(pos) } ?: return + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) { + val slab = targetState.get(Properties.SLAB_TYPE) ?: return val surfaceScan = when (slab) { SlabType.BOTTOM -> SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Y) SlabType.TOP -> SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Y) SlabType.DOUBLE -> { - accumulator.addIgnores(Properties.SLAB_TYPE) - if (currentState.block !is SlabBlock) SurfaceScan.DEFAULT - else when (currentState.get(Properties.SLAB_TYPE)) { + if (state.block !is SlabBlock) { + addIgnores(Properties.SLAB_TYPE) + SurfaceScan.DEFAULT + } else when (state.get(Properties.SLAB_TYPE)) { SlabType.BOTTOM -> SurfaceScan(ScanMode.GreaterBlockHalf, Direction.Axis.Y) else -> SurfaceScan(ScanMode.LesserBlockHalf, Direction.Axis.Y) } } } - accumulator.offerSurfaceScan(surfaceScan) + offerSurfaceScan(surfaceScan) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt new file mode 100644 index 000000000..602181080 --- /dev/null +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2025 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.interaction.construction.processing.preprocessors.state + +import com.lambda.context.SafeContext +import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.StateProcessor +import com.lambda.util.BlockUtils.blockState +import com.lambda.util.BlockUtils.item +import net.minecraft.block.BlockState +import net.minecraft.block.Blocks +import net.minecraft.item.Items +import net.minecraft.util.math.BlockPos + +// Collected using reflections and then accessed from a collection in ProcessorRegistry +@Suppress("unused") +object BambooPreProcessor : StateProcessor { + override fun acceptsState(state: BlockState, targetState: BlockState) = + (state.isReplaceable || state.block == Blocks.BAMBOO_SAPLING) && targetState.block == Blocks.BAMBOO + + context(safeContext: SafeContext) + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) { + if (state.block == Blocks.BAMBOO_SAPLING) { + omitPlacement() + return + } + noCaching() + if (safeContext.blockState(pos.down()).block.item != Items.BAMBOO) { + setExpectedState(Blocks.BAMBOO_SAPLING.defaultState) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt new file mode 100644 index 000000000..ea16ecfa6 --- /dev/null +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2025 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.interaction.construction.processing.preprocessors.state + +import com.lambda.context.SafeContext +import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.StateProcessor +import net.minecraft.block.BlockState +import net.minecraft.block.Blocks +import net.minecraft.item.Items +import net.minecraft.util.math.BlockPos + +// Collected using reflections and then accessed from a collection in ProcessorRegistry +@Suppress("unused") +object FirePreProcessor : StateProcessor { + override fun acceptsState(state: BlockState, targetState: BlockState) = + state.isReplaceable && targetState.block == Blocks.FIRE + + context(safeContext: SafeContext) + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) { + setItem(Items.FLINT_AND_STEEL) + setPlacing(false) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt new file mode 100644 index 000000000..31775feca --- /dev/null +++ b/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2025 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.interaction.construction.processing.preprocessors.state + +import com.lambda.context.SafeContext +import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.processing.StateProcessor +import net.minecraft.block.BlockState +import net.minecraft.block.Blocks +import net.minecraft.block.FlowerPotBlock +import net.minecraft.item.Items +import net.minecraft.util.math.BlockPos + +// Collected using reflections and then accessed from a collection in ProcessorRegistry +@Suppress("unused") +object FlowerPotPreProcessor : StateProcessor { + override fun acceptsState(state: BlockState, targetState: BlockState) = + (state.isReplaceable || state.block == Blocks.FLOWER_POT) && + (targetState.block is FlowerPotBlock && targetState.block != Blocks.FLOWER_POT) + + context(safeContext: SafeContext) + override fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) { + if (state.block != Blocks.FLOWER_POT) { + setExpectedState(Blocks.FLOWER_POT.defaultState) + setItem(Items.FLOWER_POT) + return + } + setPlacing(false) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt b/src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt index e178549ae..a4dcc1152 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt @@ -20,7 +20,7 @@ package com.lambda.interaction.construction.result import com.lambda.config.groups.ActionConfig import com.lambda.interaction.construction.context.BreakContext import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.context.PlaceContext +import com.lambda.interaction.construction.context.InteractContext import com.lambda.interaction.request.hotbar.HotbarManager import com.lambda.threading.runSafe import com.lambda.util.BlockUtils @@ -34,13 +34,13 @@ interface Contextual : ComparableResult { override fun compareResult(other: ComparableResult) = runSafe { when (other) { is Contextual -> compareBy { - if (it is PlaceContext) BlockUtils.fluids.indexOf(it.cachedState.fluidState.fluid) + if (it is InteractContext) BlockUtils.fluids.indexOf(it.cachedState.fluidState.fluid) else BlockUtils.fluids.size }.thenByDescending { - if (it is PlaceContext && it.cachedState.fluidState.level != 0) it.blockPos.y + if (it is InteractContext && it.cachedState.fluidState.level != 0) it.blockPos.y else Int.MIN_VALUE }.thenByDescending { - if (it is PlaceContext) it.cachedState.fluidState.level + if (it is InteractContext) it.cachedState.fluidState.level else Int.MIN_VALUE }.thenByDescending { context.sorter == ActionConfig.SortMode.Tool && it.hotbarIndex == HotbarManager.serverSlot @@ -53,7 +53,7 @@ interface Contextual : ComparableResult { ActionConfig.SortMode.Random -> it.random } }.thenByDescending { - it is PlaceContext && it.sneak == player.isSneaking + it is InteractContext && it.sneak == player.isSneaking }.thenByDescending { it.hotbarIndex == HotbarManager.serverSlot }.thenByDescending { diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt b/src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt index 271457a14..cff5a7254 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt @@ -17,38 +17,188 @@ package com.lambda.interaction.construction.result.results +import baritone.api.pathing.goals.GoalBlock +import baritone.api.pathing.goals.GoalInverted import com.lambda.graphics.renderer.esp.ShapeBuilder import com.lambda.interaction.construction.context.InteractContext import com.lambda.interaction.construction.result.BuildResult import com.lambda.interaction.construction.result.Contextual import com.lambda.interaction.construction.result.Dependent import com.lambda.interaction.construction.result.Drawable +import com.lambda.interaction.construction.result.Navigable import com.lambda.interaction.construction.result.Rank +import net.minecraft.block.BlockState +import net.minecraft.entity.Entity +import net.minecraft.item.ItemPlacementContext +import net.minecraft.item.ItemStack import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Box +import net.minecraft.util.math.Direction +import net.minecraft.util.math.Vec3d +import java.awt.Color +/** + * [InteractResult] represents the result of a placement simulation. + * Holds data about the placement and the result of the simulation. + * Every [GenericResult] can [resolve] its own problem. + * Every [GenericResult] can be compared to another [GenericResult]. + * First based on the context, then based on the [com.lambda.interaction.construction.result.Rank]. + */ sealed class InteractResult : BuildResult() { override val name: String get() = "${this::class.simpleName} at ${pos.toShortString()}" /** - * Represents a successful interaction. All checks have been passed. - * @param context The context of the interaction. + * Represents a successful placement. All checks have been passed. + * @param context The context of the placement. */ data class Interact( - override val pos: BlockPos, - override val context: InteractContext + override val pos: BlockPos, + override val context: InteractContext, ) : Contextual, Drawable, InteractResult() { - override val rank = Rank.InteractSuccess + override val rank = Rank.PlaceSuccess override fun ShapeBuilder.buildRenderer() { with(context) { buildRenderer() } } } + /** + * Represents a placement result where the block placement does not meet integrity expectations. + * + * This class is used to provide details about a block placement issue in which the actual block + * placed does not match the expected state, or additional integrity conditions are not met. + * + * @property pos The position of the block being inspected or placed. + * @property expected The expected state of the block. + * @property simulated The context of the item placement simulation. + * @property actual The expected + */ + data class NoIntegrity( + override val pos: BlockPos, + val expected: BlockState, + val simulated: ItemPlacementContext, + val actual: BlockState? = null, + ) : Drawable, InteractResult() { + override val rank = Rank.PlaceNoIntegrity + private val color = Color(252, 3, 3, 100) + + override fun ShapeBuilder.buildRenderer() { + val box = with(simulated.hitPos) { + Box( + x - 0.05, y - 0.05, z - 0.05, + x + 0.05, y + 0.05, z + 0.05, + ).offset(simulated.side.doubleVector.multiply(0.05)) + } + box(box, color, color) + } + } + + /** + * Represents a scenario where block placement is obstructed by the player itself. + * + * @property pos The position of the block that was attempted to be placed. + */ + data class BlockedBySelf( + override val pos: BlockPos + ) : Navigable, InteractResult() { + override val rank = Rank.PlaceBlockedByPlayer + override val goal = GoalInverted(GoalBlock(pos)) + } + + /** + * Represents a scenario where the block placement is obstructed by an entity. + * + * @property pos The position of the block that was attempted to be placed. + */ + data class BlockedByEntity( + override val pos: BlockPos, + val entities: List, + val hitPos: Vec3d, + val side: Direction + ) : Drawable, InteractResult() { + override val rank = Rank.PlaceBlockedByEntity + private val color = Color(252, 3, 3, 100) + + override fun ShapeBuilder.buildRenderer() { + val box = with(hitPos) { + Box( + x - 0.05, y - 0.05, z - 0.05, + x + 0.05, y + 0.05, z + 0.05, + ).offset(side.doubleVector.multiply(0.05)) + } + box(box, color, color) + } + } + + /** + * Represents a result indicating that a block cannot be replaced during a placement operation. + * + * @property pos The position of the block that cannot be replaced. + * @property simulated The context of the item placement simulation. + */ + data class CantReplace( + override val pos: BlockPos, + val simulated: ItemPlacementContext, + ) : InteractResult() { + override val rank = Rank.PlaceCantReplace + } + + /** + * Represents a placement result indicating that the scaffolding placement has exceeded the allowed limits. + * + * @property pos The position of the block where the placement attempt occurred. + */ + data class ScaffoldExceeded( + override val pos: BlockPos + ) : InteractResult() { + override val rank = Rank.PlaceScaffoldExceeded + } + + /** + * Represents a result where a block placement operation was prevented because + * the relevant block feature is disabled. + * + * @property pos The position of the block that could not be placed. + * @property itemStack The item stack associated with the attempted placement. + */ + data class BlockFeatureDisabled( + override val pos: BlockPos, + val itemStack: ItemStack, + ) : InteractResult() { + override val rank = Rank.PlaceBlockFeatureDisabled + } + + /** + * Represents a result state where the placement or manipulation of a block resulted in an unexpected position. + * + * @property pos The intended position of the block. + * @property actualPos The actual position of the block, which differs from the intended position. + */ + data class UnexpectedPosition( + override val pos: BlockPos, + val actualPos: BlockPos, + ) : InteractResult() { + override val rank = Rank.UnexpectedPosition + } + + /** + * Represents a result indicating an illegal usage during a placement operation. + * E.g., the player can't modify the world or the block cannot be placed against the surface. + * + * @property pos The position of the block associated with the illegal usage result. + * @property rank The ranking of this result, which is always `PLACE_ILLEGAL_USAGE`. + */ + data class IllegalUsage( + override val pos: BlockPos, + ) : InteractResult() { + override val rank = Rank.PlaceIllegalUsage + } + data class Dependency( override val pos: BlockPos, override val dependency: BuildResult ) : InteractResult(), Dependent by Dependent.Nested(dependency) { - override val rank = dependency.rank + override val rank = lastDependency.rank override val compareBy = lastDependency } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/PlaceResult.kt b/src/main/kotlin/com/lambda/interaction/construction/result/results/PlaceResult.kt deleted file mode 100644 index 7f10bca2a..000000000 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/PlaceResult.kt +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.construction.result.results - -import baritone.api.pathing.goals.GoalBlock -import baritone.api.pathing.goals.GoalInverted -import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.construction.context.PlaceContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Contextual -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.construction.result.Navigable -import com.lambda.interaction.construction.result.Rank -import net.minecraft.block.BlockState -import net.minecraft.entity.Entity -import net.minecraft.item.ItemPlacementContext -import net.minecraft.item.ItemStack -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box -import net.minecraft.util.math.Direction -import net.minecraft.util.math.Vec3d -import java.awt.Color - -/** - * [PlaceResult] represents the result of a placement simulation. - * Holds data about the placement and the result of the simulation. - * Every [GenericResult] can [resolve] its own problem. - * Every [GenericResult] can be compared to another [GenericResult]. - * First based on the context, then based on the [com.lambda.interaction.construction.result.Rank]. - */ -sealed class PlaceResult : BuildResult() { - override val name: String get() = "${this::class.simpleName} at ${pos.toShortString()}" - - /** - * Represents a successful placement. All checks have been passed. - * @param context The context of the placement. - */ - data class Place( - override val pos: BlockPos, - override val context: PlaceContext, - ) : Contextual, Drawable, PlaceResult() { - override val rank = Rank.PlaceSuccess - - override fun ShapeBuilder.buildRenderer() { - with(context) { buildRenderer() } - } - } - - /** - * Represents a placement result where the block placement does not meet integrity expectations. - * - * This class is used to provide details about a block placement issue in which the actual block - * placed does not match the expected state, or additional integrity conditions are not met. - * - * @property pos The position of the block being inspected or placed. - * @property expected The expected state of the block. - * @property simulated The context of the item placement simulation. - * @property actual The expected - */ - data class NoIntegrity( - override val pos: BlockPos, - val expected: BlockState, - val simulated: ItemPlacementContext, - val actual: BlockState? = null, - ) : Drawable, PlaceResult() { - override val rank = Rank.PlaceNoIntegrity - private val color = Color(252, 3, 3, 100) - - override fun ShapeBuilder.buildRenderer() { - val box = with(simulated.hitPos) { - Box( - x - 0.05, y - 0.05, z - 0.05, - x + 0.05, y + 0.05, z + 0.05, - ).offset(simulated.side.doubleVector.multiply(0.05)) - } - box(box, color, color) - } - } - - /** - * Represents a scenario where block placement is obstructed by the player itself. - * - * @property pos The position of the block that was attempted to be placed. - */ - data class BlockedBySelf( - override val pos: BlockPos - ) : Navigable, PlaceResult() { - override val rank = Rank.PlaceBlockedByPlayer - override val goal = GoalInverted(GoalBlock(pos)) - } - - /** - * Represents a scenario where the block placement is obstructed by an entity. - * - * @property pos The position of the block that was attempted to be placed. - */ - data class BlockedByEntity( - override val pos: BlockPos, - val entities: List, - val hitPos: Vec3d, - val side: Direction - ) : Drawable, PlaceResult() { - override val rank = Rank.PlaceBlockedByEntity - private val color = Color(252, 3, 3, 100) - - override fun ShapeBuilder.buildRenderer() { - val box = with(hitPos) { - Box( - x - 0.05, y - 0.05, z - 0.05, - x + 0.05, y + 0.05, z + 0.05, - ).offset(side.doubleVector.multiply(0.05)) - } - box(box, color, color) - } - } - - /** - * Represents a result indicating that a block cannot be replaced during a placement operation. - * - * @property pos The position of the block that cannot be replaced. - * @property simulated The context of the item placement simulation. - */ - data class CantReplace( - override val pos: BlockPos, - val simulated: ItemPlacementContext, - ) : PlaceResult() { - override val rank = Rank.PlaceCantReplace - } - - /** - * Represents a placement result indicating that the scaffolding placement has exceeded the allowed limits. - * - * @property pos The position of the block where the placement attempt occurred. - */ - data class ScaffoldExceeded( - override val pos: BlockPos - ) : PlaceResult() { - override val rank = Rank.PlaceScaffoldExceeded - } - - /** - * Represents a result where a block placement operation was prevented because - * the relevant block feature is disabled. - * - * @property pos The position of the block that could not be placed. - * @property itemStack The item stack associated with the attempted placement. - */ - data class BlockFeatureDisabled( - override val pos: BlockPos, - val itemStack: ItemStack, - ) : PlaceResult() { - override val rank = Rank.PlaceBlockFeatureDisabled - } - - /** - * Represents a result state where the placement or manipulation of a block resulted in an unexpected position. - * - * @property pos The intended position of the block. - * @property actualPos The actual position of the block, which differs from the intended position. - */ - data class UnexpectedPosition( - override val pos: BlockPos, - val actualPos: BlockPos, - ) : PlaceResult() { - override val rank = Rank.UnexpectedPosition - } - - /** - * Represents a result indicating an illegal usage during a placement operation. - * E.g., the player can't modify the world or the block cannot be placed against the surface. - * - * @property pos The position of the block associated with the illegal usage result. - * @property rank The ranking of this result, which is always `PLACE_ILLEGAL_USAGE`. - */ - data class IllegalUsage( - override val pos: BlockPos, - ) : PlaceResult() { - override val rank = Rank.PlaceIllegalUsage - } - - data class Dependency( - override val pos: BlockPos, - override val dependency: BuildResult - ) : PlaceResult(), Dependent by Dependent.Nested(dependency) { - override val rank = lastDependency.rank - override val compareBy = lastDependency - } -} diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt index 7f447fa09..f3aabfb47 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt @@ -20,11 +20,9 @@ package com.lambda.interaction.construction.simulation import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.construction.result.BuildResult import com.lambda.interaction.construction.result.results.PostSimResult -import com.lambda.interaction.construction.simulation.ISimInfo.Companion.sim +import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak -import com.lambda.interaction.construction.simulation.checks.PlaceSim.Companion.simPlacement -import com.lambda.interaction.construction.simulation.checks.PostProcessingSim.Companion.simPostProcessing -import com.lambda.interaction.construction.verify.TargetState +import com.lambda.interaction.construction.simulation.checks.InteractSim.Companion.simInteraction import com.lambda.util.BlockUtils.blockState import com.lambda.util.extension.Structure import io.ktor.util.collections.* @@ -40,9 +38,9 @@ object BuildSimulator : Sim() { * the provided concurrent set. This method uses coroutines to perform the simulations in parallel. The results * will likely not be returned in the same order they were simulated due to the parallel nature of the simulations. * - * @see ISimInfo.sim + * @see SimInfo.sim * @see simPostProcessing - * @see simPlacement + * @see simInteraction * @see simBreak */ context(automatedSafeContext: AutomatedSafeContext) @@ -55,14 +53,13 @@ object BuildSimulator : Sim() { with(automatedSafeContext) { forEach { (pos, targetState) -> launch { - sim(pos, blockState(pos), targetState, pov, concurrentSet) { - if (targetState is TargetState.State && matchesTarget(complete = false)) { - simPostProcessing() - return@sim - } - if (!targetState.isEmpty() && state.isReplaceable) simPlacement() - else simBreak() - } + sim( + pos, + blockState(pos), + targetState, + pov, + concurrentSet + ) } } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/ISimInfo.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/ISimInfo.kt deleted file mode 100644 index 642540dcf..000000000 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/ISimInfo.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.construction.simulation - -import com.lambda.context.Automated -import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.processing.PreProcessingData -import com.lambda.interaction.construction.processing.ProcessorRegistry.getProcessingInfo -import com.lambda.interaction.construction.processing.ProcessorRegistry.intermediaryBlockMap -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.simulation.checks.BasicChecker.hasBasicRequirements -import com.lambda.interaction.construction.verify.TargetState -import net.minecraft.block.BlockState -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Vec3d -import java.util.* - -/** - * An interface representing all the information required to simulate a state. All simulators must present their public api - * as an extension of the [SimInfo] class to allow easy access through the DSL style sim builder. - */ -interface ISimInfo : Automated { - val pos: BlockPos - val state: BlockState - val targetState: TargetState - val preProcessing: PreProcessingData - val pov: Vec3d - val concurrentResults: MutableSet - val dependencyStack: Stack> - - fun AutomatedSafeContext.matchesTarget(state: BlockState = this@ISimInfo.state, complete: Boolean = true): Boolean { - if (targetState.matches(state, pos, if (!complete) preProcessing.info.ignore else emptySet())) return true - else if (complete) return false - - intermediaryBlockMap[targetState.getState(pos).block]?.let { intermediaryInfo -> - return intermediaryInfo.isIntermediaryBlock(state) - } - - return false - } - - companion object { - /** - * Creates a [SimInfo], checks its basic requirements, and runs the [simBuilder] block. - */ - @SimDsl - context(_: BuildSimulator) - suspend fun AutomatedSafeContext.sim( - pos: BlockPos, - state: BlockState, - targetState: TargetState, - pov: Vec3d, - concurrentResults: MutableSet, - simBuilder: suspend SimInfo.() -> Unit - ) { - SimInfo( - pos, state, targetState, - targetState.getProcessingInfo(pos) ?: return, - pov, Stack(), concurrentResults, this - ).takeIf { it.hasBasicRequirements() }?.run { simBuilder() } - } - - /** - * Creates a new [SimInfo] using the current [ISimInfo]'s [dependencyStack] and [concurrentResults], - * checks its basic requirements, and runs the [simBuilder] block. As simulations tend to make use of - * concurrency, a new stack is created and the dependencies from the previous stack are added. - */ - @SimDsl - context(_: AutomatedSafeContext) - suspend fun ISimInfo.sim( - pos: BlockPos = this.pos, - state: BlockState = this.state, - targetState: TargetState = this.targetState, - pov: Vec3d = this.pov, - simBuilder: suspend SimInfo.() -> Unit - ) { - SimInfo( - pos, state, targetState, - targetState.getProcessingInfo(pos) ?: return, - pov, Stack>().apply { addAll(dependencyStack) }, concurrentResults, this - ).takeIf { it.hasBasicRequirements() }?.run { simBuilder() } - } - } -} - -data class SimInfo( - override val pos: BlockPos, - override val state: BlockState, - override val targetState: TargetState, - override val preProcessing: PreProcessingData, - override val pov: Vec3d, - override val dependencyStack: Stack>, - override val concurrentResults: MutableSet, - private val automated: Automated -) : ISimInfo, Automated by automated \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt index 4111218ac..ccab8eed0 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt @@ -22,10 +22,10 @@ import com.lambda.interaction.construction.result.results.GenericResult @SimDsl interface Results { - fun ISimInfo.result(result: GenericResult) = addResult(result) - fun ISimInfo.result(result: T) = addResult(result) + fun SimInfo.result(result: GenericResult) = addResult(result) + fun SimInfo.result(result: T) = addResult(result) - private fun ISimInfo.addResult(result: BuildResult) { + private fun SimInfo.addResult(result: BuildResult) { concurrentResults.add( dependencyStack .asReversed() diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt index c4294859b..5832cecf6 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt @@ -53,7 +53,7 @@ annotation class SimDsl * Assuming the dependency stack has not reached max capacity, the original sim is then added to the dependency stack * kept within the [SimInfo] object. Each [BuildResult] added is then iterated over the dependency stack, calling * [dependentUpon] on each one. By the end, the result will be a nested group, with your initial [BuildResult] at - * the very bottom, which is then added to the [ISimInfo.concurrentResults] set. After a sim is completed, the dependency + * the very bottom, which is then added to the [SimInfo.concurrentResults] set. After a sim is completed, the dependency * is then popped from the stack. * * @param T The type of [BuildResult] this sim produces. @@ -75,7 +75,7 @@ abstract class Sim : Results { /** * Pushes and pops the [dependent] onto and off of the dependency stack unless the [maxSimDependencies] is reached. */ - protected suspend fun ISimInfo.withDependent(dependent: Sim<*>, block: suspend () -> Unit) { + protected suspend fun SimInfo.withDependent(dependent: Sim<*>, block: suspend () -> Unit) { // +1 because the build sim counts as a dependent if (dependencyStack.size >= buildConfig.maxBuildDependencies + 1) return dependencyStack.push(dependent) @@ -86,12 +86,12 @@ abstract class Sim : Results { /** * Scans a [voxelShape] on the given [sides] at the [pos] from the [pov]. */ - suspend fun ISimInfo.scanShape( + suspend fun SimInfo.scanShape( pov: Vec3d, voxelShape: VoxelShape, pos: BlockPos, sides: Set, - preProcessing: PreProcessingData + preProcessing: PreProcessingData? ): Set? { val boxes = voxelShape.boundingBoxes.map { it.offset(pos) } @@ -108,7 +108,7 @@ abstract class Sim : Results { else sides if (!buildConfig.strictRayCast) { - box.getClosestPoints(pov, sides, preProcessing, placeConfig.airPlace.isEnabled) { vec, side -> + box.getClosestPoints(pov, sides, preProcessing, interactConfig.airPlace.isEnabled) { vec, side -> if (pov distSq vec > reachSq) misses.add(Pair(vec, side)) else { diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt new file mode 100644 index 000000000..92867db59 --- /dev/null +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt @@ -0,0 +1,150 @@ +/* + * Copyright 2025 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.interaction.construction.simulation + +import com.lambda.context.Automated +import com.lambda.context.AutomatedSafeContext +import com.lambda.interaction.construction.processing.PreProcessingData +import com.lambda.interaction.construction.processing.ProcessorRegistry.getProcessingInfo +import com.lambda.interaction.construction.result.BuildResult +import com.lambda.interaction.construction.simulation.checks.BasicChecker.hasBasicRequirements +import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak +import com.lambda.interaction.construction.simulation.checks.InteractSim.Companion.simInteraction +import com.lambda.interaction.construction.verify.TargetState +import com.lambda.util.BlockUtils.matches +import net.minecraft.block.BlockState +import net.minecraft.item.Item +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Vec3d +import java.util.* + +/** + * An interface representing all the information required to simulate a state. All simulators must present their public api + * as an extension of the [SimInfo] class to allow easy access through the DSL style sim builder. + */ +interface SimInfo : Automated { + val pos: BlockPos + val state: BlockState + val targetState: TargetState + val pov: Vec3d + val dependencyStack: Stack> + val concurrentResults: MutableSet + + @SimDsl + context(_: AutomatedSafeContext, _: Sim<*>) + suspend fun sim() + + companion object { + /** + * Creates a [SimInfo], checks its basic requirements, and runs the [simBuilder] block. + */ + @SimDsl + context(_: BuildSimulator) + suspend fun AutomatedSafeContext.sim( + pos: BlockPos, + state: BlockState, + targetState: TargetState, + pov: Vec3d, + concurrentResults: MutableSet + ) = getTypedInfo( + pos, + state, + targetState, + pov, + Stack(), + concurrentResults + ).takeIf { it.hasBasicRequirements() }?.sim() + + /** + * Creates a new [SimInfo] using the current [SimInfo]'s [dependencyStack] and [concurrentResults], + * checks its basic requirements, and runs the [simBuilder] block. As simulations tend to make use of + * concurrency, a new stack is created and the dependencies from the previous stack are added. + */ + @SimDsl + context(automatedSafeContext: AutomatedSafeContext, _: Sim<*>) + suspend fun SimInfo.sim( + pos: BlockPos = this.pos, + state: BlockState = this.state, + targetState: TargetState = this.targetState, + pov: Vec3d = this.pov + ) = automatedSafeContext.getTypedInfo( + pos, + state, + targetState, + pov, + Stack>().apply { addAll(dependencyStack) }, + concurrentResults + ).takeIf { it.hasBasicRequirements() }?.sim() + + @SimDsl + private fun AutomatedSafeContext.getTypedInfo( + pos: BlockPos, + state: BlockState, + targetState: TargetState, + pov: Vec3d, + dependencyStack: Stack>, + concurrentResults: MutableSet + ): SimInfo { + if (!targetState.isEmpty()) { + getProcessingInfo(state, targetState, pos)?.let { preProcessing -> + return object : InteractSimInfo, Automated by this { + override val pos = pos + override val state = state + override val targetState = targetState + override val pov = pov + override val dependencyStack = dependencyStack + override val concurrentResults = concurrentResults + override val preProcessing = preProcessing + override val expectedState = preProcessing.info.expectedState + override val item = preProcessing.info.item + override val placing = preProcessing.info.placing + + context(_: AutomatedSafeContext, _: Sim<*>) + override suspend fun sim() = simInteraction() + + override fun AutomatedSafeContext.matchesTarget(state: BlockState, completely: Boolean) = + expectedState.matches(state, if (!completely) preProcessing.info.ignore else emptySet()) + } + } + } + + return object : BreakSimInfo, Automated by this { + override val pos = pos + override val state = state + override val targetState = targetState + override val pov = pov + override val dependencyStack = dependencyStack + override val concurrentResults = concurrentResults + + context(_: AutomatedSafeContext, _: Sim<*>) + override suspend fun sim() = simBreak() + } + } + } +} + +interface InteractSimInfo : SimInfo { + val preProcessing: PreProcessingData + val expectedState: BlockState + val item: Item? + val placing: Boolean + + fun AutomatedSafeContext.matchesTarget(state: BlockState, completely: Boolean): Boolean +} + +interface BreakSimInfo : SimInfo \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt index 55a7662a6..a714afebe 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt @@ -23,7 +23,6 @@ import com.lambda.interaction.construction.result.results.PreSimResult import com.lambda.interaction.construction.simulation.Results import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo -import com.lambda.interaction.construction.verify.TargetState import com.lambda.util.player.gamemode import com.lambda.util.world.WorldUtils.isLoaded import net.minecraft.block.OperatorBlock @@ -48,7 +47,7 @@ object BasicChecker : Results { } // block should be ignored - if (state.block in breakConfig.ignoredBlocks && targetState.type == TargetState.Type.Air) { + if (state.block in breakConfig.ignoredBlocks && targetState.isEmpty()) { result(GenericResult.Ignored(pos)) return false } diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt index 02f351bd8..bd983adc3 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt @@ -22,12 +22,11 @@ import com.lambda.interaction.construction.context.BreakContext import com.lambda.interaction.construction.result.BuildResult import com.lambda.interaction.construction.result.results.BreakResult import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.simulation.ISimInfo -import com.lambda.interaction.construction.simulation.ISimInfo.Companion.sim +import com.lambda.interaction.construction.simulation.BreakSimInfo import com.lambda.interaction.construction.simulation.Sim import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo -import com.lambda.interaction.construction.simulation.checks.PlaceSim.Companion.simPlacement +import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection @@ -65,9 +64,9 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import kotlin.jvm.optionals.getOrNull -class BreakSim private constructor(simInfo: ISimInfo) +class BreakSim private constructor(simInfo: SimInfo) : Sim(), - ISimInfo by simInfo + SimInfo by simInfo { override fun dependentUpon(buildResult: BuildResult) = BreakResult.Dependency(pos, buildResult) @@ -75,7 +74,7 @@ class BreakSim private constructor(simInfo: ISimInfo) companion object { @SimDsl context(automatedSafeContext: AutomatedSafeContext, dependent: Sim<*>) - suspend fun SimInfo.simBreak() = + suspend fun BreakSimInfo.simBreak() = BreakSim(this).run { withDependent(dependent) { automatedSafeContext.simBreaks() @@ -90,9 +89,9 @@ class BreakSim private constructor(simInfo: ISimInfo) return } - if (targetState.getState(pos).isAir && !state.fluidState.isEmpty && state.isReplaceable) { + if (!state.fluidState.isEmpty && state.isReplaceable) { result(BreakResult.Submerge(pos, state)) - sim(pos, state, TargetState.Solid(emptySet())) { simPlacement() } + sim(pos, state, TargetState.Solid(emptySet())) return } @@ -126,7 +125,7 @@ class BreakSim private constructor(simInfo: ISimInfo) return } - val validHits = scanShape(pov, shape, pos, Direction.entries.toSet(), preProcessing) ?: return + val validHits = scanShape(pov, shape, pos, Direction.entries.toSet(), null) ?: return val bestHit = buildConfig.pointSelection.select(validHits) ?: return val target = lookAt(bestHit.rotation) diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PlaceSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt similarity index 67% rename from src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PlaceSim.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt index 31a81dd60..6b66d5456 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PlaceSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt @@ -18,18 +18,17 @@ package com.lambda.interaction.construction.simulation.checks import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.context.PlaceContext +import com.lambda.interaction.construction.context.InteractContext import com.lambda.interaction.construction.result.BuildResult import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.PlaceResult -import com.lambda.interaction.construction.simulation.ISimInfo -import com.lambda.interaction.construction.simulation.ISimInfo.Companion.sim +import com.lambda.interaction.construction.result.results.InteractResult +import com.lambda.interaction.construction.simulation.InteractSimInfo import com.lambda.interaction.construction.simulation.Sim import com.lambda.interaction.construction.simulation.SimDsl -import com.lambda.interaction.construction.simulation.SimInfo -import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak +import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer +import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.interaction.material.container.ContainerManager.containerWithMaterial import com.lambda.interaction.material.container.MaterialContainer @@ -61,6 +60,7 @@ import net.minecraft.block.pattern.CachedBlockPosition import net.minecraft.client.network.ClientPlayerEntity import net.minecraft.entity.Entity import net.minecraft.item.BlockItem +import net.minecraft.item.Item import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemStack import net.minecraft.state.property.Properties @@ -70,31 +70,31 @@ import net.minecraft.util.math.Direction import net.minecraft.util.math.RotationPropertyHelper import net.minecraft.util.shape.VoxelShapes -class PlaceSim private constructor(simInfo: ISimInfo) - : Sim(), - ISimInfo by simInfo +class InteractSim private constructor(simInfo: InteractSimInfo) + : Sim(), + InteractSimInfo by simInfo { override fun dependentUpon(buildResult: BuildResult) = - PlaceResult.Dependency(pos, buildResult) + InteractResult.Dependency(pos, buildResult) companion object { context(automatedSafeContext: AutomatedSafeContext, dependent: Sim<*>) @SimDsl - suspend fun SimInfo.simPlacement() = - PlaceSim(this).run { + suspend fun InteractSimInfo.simInteraction() = + InteractSim(this).run { withDependent(dependent) { - automatedSafeContext.simPlacements() + automatedSafeContext.simInteraction() } } } - private suspend fun AutomatedSafeContext.simPlacements() = + private suspend fun AutomatedSafeContext.simInteraction() = supervisorScope { preProcessing.info.sides.forEach { side -> val neighborPos = pos.offset(side) val neighborSide = side.opposite - launch { testBlock(neighborPos, neighborSide, this@supervisorScope) } - launch { testBlock(pos, side, this@supervisorScope) } + launch { testBlock(pos, side, this@supervisorScope) } + if (placing) launch { testBlock(neighborPos, neighborSide, this@supervisorScope) } } } @@ -103,16 +103,15 @@ class PlaceSim private constructor(simInfo: ISimInfo) val testBlockState = blockState(pos) val shape = testBlockState.getOutlineShape(world, pos).let { outlineShape -> - if (!outlineShape.isEmpty || !placeConfig.airPlace.isEnabled) outlineShape + if (!outlineShape.isEmpty || !interactConfig.airPlace.isEnabled) outlineShape else VoxelShapes.fullCube() } if (shape.isEmpty) return - // ToDo: For each hand val fakePlayer = copyPlayer(player).apply { val newPos = pov - (this.eyePos - this.pos) setPos(newPos.x, newPos.y, newPos.z) - if (testBlockState.block::class in BlockUtils.interactionBlocks) { + if (testBlockState.block::class in BlockUtils.interactionBlocks && preProcessing.info.placing) { input.sneaking = true updatePose() } @@ -121,93 +120,116 @@ class PlaceSim private constructor(simInfo: ISimInfo) val validHits = scanShape(pov, shape, pos, setOf(side), preProcessing) ?: return - selectHitPos(validHits, fakePlayer, targetState.getStack(this@PlaceSim.pos).blockItem, supervisorScope) - } - - private fun AutomatedSafeContext.getSwapStack(): ItemStack? { - val optimalStack = targetState.getStack(pos) - val stackSelection = optimalStack.item.select() - val containerSelection = selectContainer { ofAnyType(MaterialContainer.Rank.Hotbar) } - val container = stackSelection.containerWithMaterial(containerSelection).firstOrNull() ?: run { - result(GenericResult.WrongItemSelection(pos, optimalStack.item.select(), player.mainHandStack)) - return null - } - return stackSelection.filterStacks(container.stacks).run { - firstOrNull { it.inventoryIndex == player.inventory.selectedSlot } - ?: firstOrNull() - } + selectHitPos(validHits, fakePlayer, supervisorScope) } private suspend fun AutomatedSafeContext.selectHitPos( validHits: Collection, fakePlayer: ClientPlayerEntity, - item: BlockItem, supervisorScope: CoroutineScope ) { buildConfig.pointSelection.select(validHits)?.let { checkedHit -> val hitResult = checkedHit.hit.blockResult ?: return - val context = item.getPlacementContext( + val swapStack = getSwapStack(item) + + if (!placing) { + if (swapStack == null) return + + val interactContext = InteractContext( + hitResult, + RotationRequest(lookAt(checkedHit.rotation), this@InteractSim), + swapStack.inventoryIndex, + pos, + state, + expectedState, + false, + fakePlayer.isSneaking, + true, + this@InteractSim + ) + result(InteractResult.Interact(pos, interactContext)) + return + } + + val blockItem = item as BlockItem + + val context = blockItem.getPlacementContext( ItemPlacementContext( world, fakePlayer, Hand.MAIN_HAND, - item.defaultStack, + blockItem.defaultStack, hitResult, ) ) ?: run { - result(PlaceResult.ScaffoldExceeded(pos)) + result(InteractResult.ScaffoldExceeded(pos)) return } if (context.blockPos != pos) { - result(PlaceResult.UnexpectedPosition(pos, context.blockPos)) + result(InteractResult.UnexpectedPosition(pos, context.blockPos)) return } val cachePos = CachedBlockPosition(context.world, context.blockPos, false) - if (!player.abilities.allowModifyWorld && !item.defaultStack.canPlaceOn(cachePos)) { - result(PlaceResult.IllegalUsage(pos)) + if (!player.abilities.allowModifyWorld && !blockItem.defaultStack.canPlaceOn(cachePos)) { + result(InteractResult.IllegalUsage(pos)) return } if (!context.canPlace()) { - result(PlaceResult.CantReplace(pos, context)) + result(InteractResult.CantReplace(pos, context)) return } - val rotatePlaceTest = simRotatePlace(fakePlayer, checkedHit, context) ?: return + val rotatePlaceTest = simRotation(fakePlayer, checkedHit, context) ?: return - val rotationRequest = if (placeConfig.axisRotate && (targetState as? TargetState.State)?.blockState?.contains(Properties.ROTATION) != true) + val rotationRequest = if (interactConfig.axisRotate && !expectedState.contains(Properties.ROTATION)) lookInDirection(PlaceDirection.fromRotation(rotatePlaceTest.rotation)) else lookAt(rotatePlaceTest.rotation) - val swapStack = getSwapStack() ?: return + if (swapStack == null) return if (!swapStack.item.isEnabled(world.enabledFeatures)) { - result(PlaceResult.BlockFeatureDisabled(pos, swapStack)) + result(InteractResult.BlockFeatureDisabled(pos, swapStack)) supervisorScope.cancel() return } - val placeContext = PlaceContext( + val interactContext = InteractContext( hitResult, - RotationRequest(rotationRequest, this@PlaceSim), + RotationRequest(rotationRequest, this@InteractSim), swapStack.inventoryIndex, pos, state, rotatePlaceTest.resultState, + true, fakePlayer.isSneaking, rotatePlaceTest.currentDirIsValid, - this@PlaceSim + this@InteractSim ) - result(PlaceResult.Place(pos, placeContext)) + result(InteractResult.Interact(pos, interactContext)) } return } - private suspend fun AutomatedSafeContext.simRotatePlace( + private fun AutomatedSafeContext.getSwapStack(item: Item?): ItemStack? { + val stackSelection = item?.select() + ?: StackSelection.selectStack(0, sorter = compareByDescending { it.inventoryIndex == player.inventory.selectedSlot }) + val containerSelection = selectContainer { ofAnyType(MaterialContainer.Rank.Hotbar) } + val container = stackSelection.containerWithMaterial(containerSelection).firstOrNull() ?: run { + result(GenericResult.WrongItemSelection(pos, stackSelection, player.mainHandStack)) + return null + } + return stackSelection.filterStacks(container.stacks).run { + firstOrNull { it.inventoryIndex == player.inventory.selectedSlot } + ?: firstOrNull() + } + } + + private suspend fun AutomatedSafeContext.simRotation( fakePlayer: ClientPlayerEntity, checkedHit: CheckedHit, context: ItemPlacementContext @@ -215,7 +237,7 @@ class PlaceSim private constructor(simInfo: ISimInfo) fakePlayer.rotation = RotationManager.serverRotation val currentDirIsValid = testPlaceState(context) != null - if (!placeConfig.axisRotate) { + if (!interactConfig.axisRotate) { fakePlayer.rotation = checkedHit.rotation return testPlaceState(context)?.let { RotatePlaceTest(it, currentDirIsValid, fakePlayer.rotation) } } @@ -225,19 +247,18 @@ class PlaceSim private constructor(simInfo: ISimInfo) return RotatePlaceTest(playerRotTest, currentDirIsValid, fakePlayer.rotation) } - (targetState as? TargetState.State)?.blockState?.let { targetState -> - if (Properties.ROTATION !in targetState) return@let - val rotation = targetState.get(Properties.ROTATION) - fakePlayer.yaw = RotationPropertyHelper.toDegrees(rotation) - listOf(rotation, rotation + 8).forEach { yaw -> - listOf(90f, 0f, -90f).forEach { pitch -> - fakePlayer.rotation = Rotation(RotationPropertyHelper.toDegrees(yaw), pitch) - testPlaceState(context)?.let { axisRotateTest -> - return RotatePlaceTest(axisRotateTest, currentDirIsValid, fakePlayer.rotation) - } - } - } - } + if (Properties.ROTATION in expectedState) { + val rotation = expectedState.get(Properties.ROTATION) + fakePlayer.yaw = RotationPropertyHelper.toDegrees(rotation) + listOf(rotation, rotation + 8).forEach { yaw -> + listOf(90f, 0f, -90f).forEach { pitch -> + fakePlayer.rotation = Rotation(RotationPropertyHelper.toDegrees(yaw), pitch) + testPlaceState(context)?.let { axisRotateTest -> + return RotatePlaceTest(axisRotateTest, currentDirIsValid, fakePlayer.rotation) + } + } + } + } PlaceDirection.entries.asReversed().forEach direction@{ direction -> fakePlayer.rotation = direction.rotation @@ -257,7 +278,7 @@ class PlaceSim private constructor(simInfo: ISimInfo) } return if (!matchesTarget(resultState, false)) { - result(PlaceResult.NoIntegrity(pos, resultState, context, (targetState as? TargetState.State)?.blockState)) + result(InteractResult.NoIntegrity(pos, expectedState, context, resultState)) null } else resultState } @@ -281,7 +302,7 @@ class PlaceSim private constructor(simInfo: ISimInfo) ?.run { mapNotNull { entity -> if (entity === player) { - result(PlaceResult.BlockedBySelf(pos)) + result(InteractResult.BlockedBySelf(pos)) return@mapNotNull null } val hitbox = entity.boundingBox @@ -292,10 +313,10 @@ class PlaceSim private constructor(simInfo: ISimInfo) } .flatten() .forEach { support -> - sim(support, blockState(support), TargetState.Empty) { simBreak() } + sim(support, blockState(support), TargetState.Empty) } } - result(PlaceResult.BlockedByEntity(pos, collidingEntities, context.hitPos, context.side)) + result(InteractResult.BlockedByEntity(pos, collidingEntities, context.hitPos, context.side)) } return collidingEntities diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PostProcessingSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PostProcessingSim.kt deleted file mode 100644 index f22c56b7b..000000000 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PostProcessingSim.kt +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.construction.simulation.checks - -import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.construction.processing.ProcessorRegistry.intermediaryBlockMap -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.InteractResult -import com.lambda.interaction.construction.simulation.ISimInfo -import com.lambda.interaction.construction.simulation.ISimInfo.Companion.sim -import com.lambda.interaction.construction.simulation.Sim -import com.lambda.interaction.construction.simulation.SimDsl -import com.lambda.interaction.construction.simulation.SimInfo -import com.lambda.interaction.construction.simulation.checks.PlaceSim.Companion.simPlacement -import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer -import com.lambda.interaction.material.StackSelection.Companion.select -import com.lambda.interaction.material.container.ContainerManager.containerWithMaterial -import com.lambda.interaction.material.container.MaterialContainer -import com.lambda.interaction.request.rotating.RotationRequest -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.CheckedHit -import com.lambda.interaction.request.rotating.visibilty.lookAt -import com.lambda.util.item.ItemStackUtils.inventoryIndex -import com.lambda.util.world.raycast.RayCastUtils.blockResult -import net.minecraft.block.BlockState -import net.minecraft.item.Item -import net.minecraft.item.ItemStack -import net.minecraft.state.property.Properties -import net.minecraft.util.math.Direction - -class PostProcessingSim private constructor(simInfo: ISimInfo) - : Sim(), - ISimInfo by simInfo -{ - override fun dependentUpon(buildResult: BuildResult) = - InteractResult.Dependency(pos, buildResult) - - companion object { - context(automatedSafeContext: AutomatedSafeContext, dependent: Sim<*>) - @SimDsl - suspend fun SimInfo.simPostProcessing() = - PostProcessingSim(this).run { - withDependent(dependent) { - automatedSafeContext.simPostProcessing() - } - } - } - - private suspend fun AutomatedSafeContext.simPostProcessing() { - val targetState = (targetState as? TargetState.State) ?: return - - intermediaryBlockMap[targetState.getState(pos).block]?.let { intermediaryInfo -> - intermediaryInfo.getIntermediaryProcess(state)?.let { intermediaryBlock -> - simInteraction( - intermediaryBlock.targetBlock.defaultState, - intermediaryBlock.sides, - intermediaryBlock.item - ) - } - return - } - - val mismatchedProperties = state.properties.filter { state.get(it) != targetState.blockState.get(it) } - mismatchedProperties.forEach { property -> - when (property) { - Properties.EYE -> { - if (state.get(Properties.EYE)) return@forEach - val expectedState = state.with(Properties.EYE, true) - simInteraction(expectedState) - } - - Properties.INVERTED -> { - val expectedState = state.with(Properties.INVERTED, !state.get(Properties.INVERTED)) - simInteraction(expectedState) - } - - Properties.DELAY -> { - val expectedState = - state.with(Properties.DELAY, state.cycle(Properties.DELAY).get(Properties.DELAY)) - simInteraction(expectedState) - } - - Properties.COMPARATOR_MODE -> { - val expectedState = state.with( - Properties.COMPARATOR_MODE, - state.cycle(Properties.COMPARATOR_MODE).get(Properties.COMPARATOR_MODE) - ) - simInteraction(expectedState) - } - - Properties.OPEN -> { - val expectedState = state.with(Properties.OPEN, !state.get(Properties.OPEN)) - simInteraction(expectedState) - } - - Properties.SLAB_TYPE -> sim { simPlacement() } - } - } - } - - private suspend fun AutomatedSafeContext.simInteraction( - expectedState: BlockState, - sides: Set = Direction.entries.toSet(), - item: Item? = null - ) { - val validHits = scanShape(pov, state.getOutlineShape(world, pos), pos, sides, preProcessing) - ?: return - - val swapStack = getSwapStack(item ?: player.mainHandStack.item) ?: return - - selectHit(validHits, expectedState, swapStack) - } - - private fun AutomatedSafeContext.getSwapStack(item: Item): ItemStack? { - val stackSelection = item.select() - val hotbarCandidates = selectContainer { - ofAnyType(MaterialContainer.Rank.Hotbar) - }.let { predicate -> - stackSelection.containerWithMaterial( predicate) - } - - if (hotbarCandidates.isEmpty()) { - result(GenericResult.WrongItemSelection(pos, stackSelection, player.mainHandStack)) - return null - } - - return hotbarCandidates.first().matchingStacks(stackSelection).first() - } - - private fun AutomatedSafeContext.selectHit( - validHits: Collection, - expectedState: BlockState, - swapStack: ItemStack - ) { - buildConfig.pointSelection.select(validHits)?.let { checkedHit -> - val checkedResult = checkedHit.hit.blockResult ?: return - val rotationTarget = lookAt(checkedHit.rotation) - val context = InteractContext( - checkedResult, - RotationRequest(rotationTarget, this), - swapStack.inventoryIndex, - state, - expectedState, - this - ) - - result(InteractResult.Interact(pos, context)) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt b/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt index 3642d133b..aa7eaacaf 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt @@ -19,7 +19,6 @@ package com.lambda.interaction.construction.verify import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext -import com.lambda.interaction.construction.processing.ProcessorRegistry.intermediaryBlockMap import com.lambda.interaction.material.container.ContainerManager.findDisposable import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.emptyState @@ -35,13 +34,8 @@ import net.minecraft.state.property.Property import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -sealed class TargetState(val type: Type) : StateMatcher { - - enum class Type { - Empty, Air, Solid, Support, State, Block, Stack - } - - data object Empty : TargetState(Type.Empty) { +sealed class TargetState() : StateMatcher { + data object Empty : TargetState() { override fun toString() = "Empty" context(safeContext: SafeContext) @@ -60,7 +54,7 @@ sealed class TargetState(val type: Type) : StateMatcher { override fun isEmpty() = true } - data object Air : TargetState(Type.Air) { + data object Air : TargetState() { override fun toString() = "Air" context(safeContext: SafeContext) @@ -79,7 +73,7 @@ sealed class TargetState(val type: Type) : StateMatcher { override fun isEmpty() = true } - data class Solid(val replace: Collection) : TargetState(Type.Solid) { + data class Solid(val replace: Collection) : TargetState() { override fun toString() = "Solid" context(safeContext: SafeContext) @@ -103,7 +97,7 @@ sealed class TargetState(val type: Type) : StateMatcher { override fun isEmpty() = false } - data class Support(val direction: Direction) : TargetState(Type.Support) { + data class Support(val direction: Direction) : TargetState() { override fun toString() = "Support for ${direction.name}" context(safeContext: SafeContext) @@ -130,7 +124,7 @@ sealed class TargetState(val type: Type) : StateMatcher { override fun isEmpty() = false } - data class State(val blockState: BlockState) : TargetState(Type.State) { + data class State(val blockState: BlockState) : TargetState() { override fun toString() = "State of $blockState" context(safeContext: SafeContext) @@ -138,13 +132,11 @@ sealed class TargetState(val type: Type) : StateMatcher { state: BlockState, pos: BlockPos, ignoredProperties: Collection> - ) = - state.matches(blockState, ignoredProperties) + ) = state.matches(blockState, ignoredProperties) context(automatedSafeContext: AutomatedSafeContext) override fun getStack(pos: BlockPos): ItemStack = - intermediaryBlockMap[blockState.block]?.startBlock?.item?.defaultStack - ?: blockState.block.getPickStack(automatedSafeContext.world, pos, blockState, true) + blockState.block.getPickStack(automatedSafeContext.world, pos, blockState, true) context(_: AutomatedSafeContext) override fun getState(pos: BlockPos): BlockState = blockState @@ -152,7 +144,7 @@ sealed class TargetState(val type: Type) : StateMatcher { override fun isEmpty() = blockState.isEmpty } - data class Block(val block: net.minecraft.block.Block) : TargetState(Type.Block) { + data class Block(val block: net.minecraft.block.Block) : TargetState() { override fun toString() = "Block of ${block.name.string.capitalize()}" context(safeContext: SafeContext) @@ -172,7 +164,7 @@ sealed class TargetState(val type: Type) : StateMatcher { override fun isEmpty() = block.defaultState.isEmpty } - data class Stack(val itemStack: ItemStack) : TargetState(Type.Stack) { + data class Stack(val itemStack: ItemStack) : TargetState() { private val startStack: ItemStack = itemStack.copy() override fun toString() = "Stack of ${startStack.item.name.string.capitalize()}" @@ -186,8 +178,7 @@ sealed class TargetState(val type: Type) : StateMatcher { ) = state.block == block context(automatedSafeContext: AutomatedSafeContext) - override fun getStack(pos: BlockPos): ItemStack = - intermediaryBlockMap[getState(pos).block]?.startBlock?.item?.defaultStack ?: itemStack + override fun getStack(pos: BlockPos): ItemStack = itemStack context(_: AutomatedSafeContext) override fun getState(pos: BlockPos): BlockState = block.defaultState diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt b/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt index 61c9f2e14..4ad56a376 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt @@ -44,7 +44,7 @@ interface BreakConfig : ActionConfig, ISettingGroup { val swing: SwingMode val swingType: BuildConfig.SwingType - val rotateForBreak: Boolean + val rotate: Boolean val breakConfirmation: BreakConfirmationMode val breaksPerTick: Int diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt index 861253876..4c128e397 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt @@ -75,8 +75,6 @@ import com.lambda.interaction.request.breaking.BrokenBlockHandler.startPending import com.lambda.interaction.request.breaking.RebreakHandler.getRebreakPotential import com.lambda.interaction.request.breaking.SwapInfo.Companion.getSwapInfo import com.lambda.interaction.request.hotbar.HotbarRequest -import com.lambda.interaction.request.interacting.InteractionManager -import com.lambda.interaction.request.placing.PlaceManager import com.lambda.interaction.request.rotating.RotationRequest import com.lambda.module.hud.ManagerDebugLoggers.breakManagerLogger import com.lambda.threading.runSafeAutomated @@ -309,7 +307,6 @@ object BreakManager : RequestHandler( */ override fun AutomatedSafeContext.handleRequest(request: BreakRequest) { if (activeRequest != null || request.contexts.isEmpty()) return - if (PlaceManager.activeThisTick || InteractionManager.activeThisTick) return activeRequest = request processRequest(request) @@ -451,7 +448,7 @@ object BreakManager : RequestHandler( .filter { it.updatedThisTick } .let { infos -> rotationRequest = infos.lastOrNull { info -> - info.breakConfig.rotateForBreak + info.breakConfig.rotate }?.let { info -> val rotation = info.context.rotationRequest logger.debug("Requesting rotation", rotation) diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt index c68b3d427..67e92740f 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt @@ -25,16 +25,34 @@ import com.lambda.util.NamedEnum interface InteractConfig : ActionConfig, ISettingGroup { val rotate: Boolean - val swingHand: Boolean - val interactSwingType: BuildConfig.SwingType - val interactConfirmationMode: InteractConfirmationMode + val airPlace: AirPlaceMode + val axisRotateSetting: Boolean + val axisRotate get() = rotate && airPlace.isEnabled && axisRotateSetting + val placeConfirmationMode: PlaceConfirmationMode + val maxPendingPlacements: Int + val placementsPerTick: Int + val swing: Boolean + val swingType: BuildConfig.SwingType + val sounds: Boolean - enum class InteractConfirmationMode( + enum class AirPlaceMode( override val displayName: String, override val description: String - ): NamedEnum, Describable { - None("No confirmation", "Send the interaction and don’t wait for the server. Lowest latency, but effects may briefly appear if the server rejects it."), - InteractThenAwait("Interact now, confirm later", "Show interaction effects immediately, then wait for the server to confirm. Feels instant while still verifying the result."), - AwaitThenInteract("Confirm first, then interact", "Wait for the server response before showing any effects. Most accurate and safe, but adds a short delay.") + ) : NamedEnum, Describable { + None("None", "Do not attempt air placements; only place against valid supports."), + Standard("Standard", "Try common air-place techniques for convenience; moderate compatibility."), + Grim("Grim", "Use grim specific air placing.") + ; + + val isEnabled get() = this != None + } + + enum class PlaceConfirmationMode( + override val displayName: String, + override val description: String + ) : NamedEnum, Describable { + None("No confirmation", "Place immediately without waiting for the server; lowest latency, possible brief desync."), + PlaceThenAwait("Place now, confirm later", "Show placement right away, then wait for server confirmation to verify."), + AwaitThenPlace("Confirm first, then place", "Wait for server response before showing placement; most accurate, adds a short delay.") } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt index e4b701cfc..7ddbede43 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt @@ -17,21 +17,26 @@ package com.lambda.interaction.request.interacting -import com.lambda.context.Automated +import com.lambda.context.SafeContext import com.lambda.interaction.construction.context.BuildContext import com.lambda.interaction.construction.context.InteractContext import com.lambda.interaction.request.ActionInfo import com.lambda.interaction.request.LogContext import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder +import net.minecraft.util.math.BlockPos data class InteractInfo( - override val context: InteractContext, - override val pendingInteractionsList: MutableCollection, - private val automated: Automated -) : ActionInfo, Automated by automated, LogContext { + override val context: InteractContext, + override val pendingInteractionsList: MutableCollection, + val onPlace: (SafeContext.(BlockPos) -> Unit)?, + val interactConfig: InteractConfig +) : ActionInfo, LogContext { override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = { - group("Interaction Info") { + group("Place Info") { text(context.getLogContextBuilder()) + group("Callbacks") { + value("onPlace", onPlace != null) + } } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt similarity index 65% rename from src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt rename to src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt index 3153710db..f091bbe43 100644 --- a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.placing +package com.lambda.interaction.request.interacting import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext @@ -26,7 +26,7 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.events.TickEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.context.PlaceContext +import com.lambda.interaction.construction.context.InteractContext import com.lambda.interaction.request.Logger import com.lambda.interaction.request.ManagerUtils.isPosBlocked import com.lambda.interaction.request.ManagerUtils.newStage @@ -34,21 +34,19 @@ import com.lambda.interaction.request.ManagerUtils.newTick import com.lambda.interaction.request.PositionBlocking import com.lambda.interaction.request.RequestHandler import com.lambda.interaction.request.breaking.BreakManager -import com.lambda.interaction.request.interacting.InteractionManager +import com.lambda.interaction.request.interacting.InteractManager.activeRequest +import com.lambda.interaction.request.interacting.InteractManager.maxPlacementsThisTick +import com.lambda.interaction.request.interacting.InteractManager.populateFrom +import com.lambda.interaction.request.interacting.InteractManager.potentialPlacements +import com.lambda.interaction.request.interacting.InteractManager.processRequest +import com.lambda.interaction.request.interacting.InteractedBlockHandler.pendingActions +import com.lambda.interaction.request.interacting.InteractedBlockHandler.setPendingConfigs +import com.lambda.interaction.request.interacting.InteractedBlockHandler.startPending import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest -import com.lambda.interaction.request.placing.PlaceManager.activeRequest -import com.lambda.interaction.request.placing.PlaceManager.maxPlacementsThisTick -import com.lambda.interaction.request.placing.PlaceManager.placeBlock -import com.lambda.interaction.request.placing.PlaceManager.populateFrom -import com.lambda.interaction.request.placing.PlaceManager.potentialPlacements -import com.lambda.interaction.request.placing.PlaceManager.processRequest -import com.lambda.interaction.request.placing.PlacedBlockHandler.pendingActions -import com.lambda.interaction.request.placing.PlacedBlockHandler.setPendingConfigs -import com.lambda.interaction.request.placing.PlacedBlockHandler.startPending import com.lambda.module.hud.ManagerDebugLoggers.placeManagerLogger import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState -import com.lambda.util.Communication.warn +import com.lambda.util.item.ItemUtils.blockItem import com.lambda.util.player.MovementUtils.sneaking import com.lambda.util.player.gamemode import com.lambda.util.player.isItemOnCooldown @@ -63,22 +61,23 @@ import net.minecraft.item.ItemUsageContext import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket import net.minecraft.sound.SoundCategory import net.minecraft.util.ActionResult +import net.minecraft.util.ActionResult.PassToDefaultBlockAction import net.minecraft.util.Hand import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos import net.minecraft.world.GameMode import kotlin.math.min -object PlaceManager : RequestHandler( +object InteractManager : RequestHandler( 0, onOpen = { if (potentialPlacements.isNotEmpty()) - PlaceManager.logger.newStage(PlaceManager.tickStage) + InteractManager.logger.newStage(InteractManager.tickStage) activeRequest?.let { it.runSafeAutomated { processRequest(it) } } } ), PositionBlocking, Logger { - private var activeRequest: PlaceRequest? = null - private var potentialPlacements = mutableListOf() + private var activeRequest: InteractRequest? = null + private var potentialPlacements = mutableListOf() private var placementsThisTick = 0 private var maxPlacementsThisTick = 0 @@ -122,9 +121,8 @@ object PlaceManager : RequestHandler( * * @see processRequest */ - override fun AutomatedSafeContext.handleRequest(request: PlaceRequest) { + override fun AutomatedSafeContext.handleRequest(request: InteractRequest) { if (activeRequest != null || request.contexts.isEmpty()) return - if (BreakManager.activeThisTick || InteractionManager.activeThisTick) return activeRequest = request processRequest(request) @@ -136,15 +134,15 @@ object PlaceManager : RequestHandler( } /** - * Returns immediately if [BreakManager] or [InteractionManager] have been active this tick. + * Returns immediately if [BreakManager] or [InteractManager] have been active this tick. * Otherwise, for fresh requests, [populateFrom] is called to fill the [potentialPlacements] collection. * It then attempts to perform as many placements as possible from the [potentialPlacements] collection within * the [maxPlacementsThisTick] limit. * * @see populateFrom - * @see placeBlock + * @see interactBlock */ - fun AutomatedSafeContext.processRequest(request: PlaceRequest) { + fun AutomatedSafeContext.processRequest(request: InteractRequest) { logger.debug("Processing request", request) if (request.fresh) populateFrom(request) @@ -160,12 +158,22 @@ object PlaceManager : RequestHandler( return } if (!validSneak(player)) return - if (tickStage !in placeConfig.tickStageMask) return + if (tickStage !in interactConfig.tickStageMask) return - val actionResult = placeBlock(ctx, request, Hand.MAIN_HAND) + val actionResult = if (ctx.placing) placeBlock(ctx, request, Hand.MAIN_HAND) + else interaction.interactBlock(player, Hand.MAIN_HAND, ctx.hitResult) if (!actionResult.isAccepted) { logger.warning("Placement interaction failed with $actionResult", ctx, request) - warn("Placement interaction failed with $actionResult") + } else { + if (interactConfig.swing) { + swingHand(interactConfig.swingType, Hand.MAIN_HAND) + + val stackInHand = player.getStackInHand(Hand.MAIN_HAND) + val stackCountPre = stackInHand.count + if (!stackInHand.isEmpty && (stackInHand.count != stackCountPre || player.isInCreativeMode)) { + mc.gameRenderer.firstPersonRenderer.resetEquipProgress(Hand.MAIN_HAND) + } + } } placementsThisTick++ iterator.remove() @@ -179,12 +187,12 @@ object PlaceManager : RequestHandler( } /** - * Filters the [request]'s [PlaceContext]s, placing them into the [potentialPlacements] collection, and + * Filters the [request]'s [InteractContext]s, placing them into the [potentialPlacements] collection, and * setting other configurations. * * @see isPosBlocked */ - private fun Automated.populateFrom(request: PlaceRequest) { + private fun Automated.populateFrom(request: InteractRequest) { logger.debug("Populating from request", request) setPendingConfigs() potentialPlacements = request.contexts @@ -192,14 +200,14 @@ object PlaceManager : RequestHandler( .filter { !isPosBlocked(it.blockPos) } .take( min( - placeConfig.maxPendingPlacements - pendingActions.size, + interactConfig.maxPendingPlacements - pendingActions.size, buildConfig.maxPendingInteractions - request.pendingInteractions.size ).coerceAtLeast(0) ) .toMutableList() logger.debug("${potentialPlacements.size} potential placements") - maxPlacementsThisTick = placeConfig.placementsPerTick + maxPlacementsThisTick = interactConfig.placementsPerTick } /** @@ -208,18 +216,18 @@ object PlaceManager : RequestHandler( * * @see net.minecraft.client.network.ClientPlayerInteractionManager.interactBlock */ - private fun AutomatedSafeContext.placeBlock(placeContext: PlaceContext, request: PlaceRequest, hand: Hand): ActionResult { + private fun AutomatedSafeContext.placeBlock(interactContext: InteractContext, request: InteractRequest, hand: Hand): ActionResult { interaction.syncSelectedSlot() - val hitResult = placeContext.hitResult + val hitResult = interactContext.hitResult if (!world.worldBorder.contains(hitResult.blockPos)) { - logger.error("Placement position outside the world border", placeContext, request) + logger.error("Placement position outside the world border", interactContext, request) return ActionResult.FAIL } if (gamemode == GameMode.SPECTATOR) { - logger.error("Player is in spectator mode", placeContext, request) + logger.error("Player is in spectator mode", interactContext, request) return ActionResult.PASS } - return interactBlockInternal(placeContext, request, hand, hitResult) + return interactBlockInternal(interactContext, request, hand, hitResult) } /** @@ -228,25 +236,27 @@ object PlaceManager : RequestHandler( * @see net.minecraft.client.network.ClientPlayerInteractionManager.interactBlockInternal */ private fun AutomatedSafeContext.interactBlockInternal( - placeContext: PlaceContext, - request: PlaceRequest, - hand: Hand, - hitResult: BlockHitResult + interactContext: InteractContext, + request: InteractRequest, + hand: Hand, + hitResult: BlockHitResult ): ActionResult { val handNotEmpty = player.getStackInHand(hand).isEmpty.not() val cantInteract = player.shouldCancelInteraction() && handNotEmpty if (!cantInteract) { val blockState = blockState(hitResult.blockPos) if (!connection.hasFeature(blockState.block.requiredFeatures)) { - logger.error("Required features not met for $blockState", placeContext, request) + logger.error("Required features not met for $blockState", interactContext, request) return ActionResult.FAIL } - val actionResult = blockState.onUse(world, player, hitResult) - if (actionResult.isAccepted) { - logger.error("Block state ($blockState) onUse not accepted", placeContext, request) - return actionResult - } + val actionResult = blockState.onUseWithItem(player.getStackInHand(hand), world, player, hand, hitResult) + if (actionResult.isAccepted) return actionResult + + if (actionResult is PassToDefaultBlockAction && hand == Hand.MAIN_HAND) { + val actionResult2 = blockState.onUse(world, player, hitResult) + if (actionResult2.isAccepted) return actionResult2 + } } val stack = player.mainHandStack @@ -255,12 +265,9 @@ object PlaceManager : RequestHandler( val itemUsageContext = ItemUsageContext(player, hand, hitResult) return if (gamemode.isCreative) { val i = stack.count - useOnBlock(placeContext, request, hand, hitResult, stack, itemUsageContext) - .also { - stack.count = i - } - } else - useOnBlock(placeContext, request, hand, hitResult, stack, itemUsageContext) + useOnBlock(interactContext, request, hand, hitResult, stack, itemUsageContext) + .also { stack.count = i } + } else useOnBlock(interactContext, request, hand, hitResult, stack, itemUsageContext) } return ActionResult.PASS } @@ -271,28 +278,22 @@ object PlaceManager : RequestHandler( * @see net.minecraft.item.Item.useOnBlock */ private fun AutomatedSafeContext.useOnBlock( - placeContext: PlaceContext, - request: PlaceRequest, - hand: Hand, - hitResult: BlockHitResult, - itemStack: ItemStack, - context: ItemUsageContext + interactContext: InteractContext, + request: InteractRequest, + hand: Hand, + hitResult: BlockHitResult, + itemStack: ItemStack, + context: ItemUsageContext ): ActionResult { - val cachedBlockPosition = CachedBlockPosition(world, context.blockPos, false) - - val cantModifyWorld = !player.abilities.allowModifyWorld - val cantPlaceOn = !itemStack.canPlaceOn(cachedBlockPosition) - if (cantModifyWorld && cantPlaceOn) { - logger.error("Cannot modify world", placeContext, request) - return ActionResult.PASS - } - - val item = (itemStack.item as? BlockItem) ?: run { - logger.error("Item ${itemStack.item.name} is not a block item", placeContext, request) - return ActionResult.PASS - } - - return place(placeContext, request, hand, hitResult, item, ItemPlacementContext(context)) + val blockPos = context.blockPos + return if (!player.abilities.allowModifyWorld && + !itemStack.canPlaceOn(CachedBlockPosition(world, blockPos, false)) + ) { + ActionResult.PASS + } else { + val item = itemStack.blockItem + place(interactContext, request, hand, hitResult, item, ItemPlacementContext(context)) + } } /** @@ -301,69 +302,58 @@ object PlaceManager : RequestHandler( * @see net.minecraft.item.BlockItem.place */ private fun AutomatedSafeContext.place( - placeContext: PlaceContext, - request: PlaceRequest, - hand: Hand, - hitResult: BlockHitResult, - item: BlockItem, - context: ItemPlacementContext + interactContext: InteractContext, + request: InteractRequest, + hand: Hand, + hitResult: BlockHitResult, + item: BlockItem, + context: ItemPlacementContext ): ActionResult { if (!item.block.isEnabled(world.enabledFeatures)) { - logger.error("Block ${item.block.name} is not enabled", placeContext, request) + logger.error("Block ${item.block.name} is not enabled", interactContext, request) return ActionResult.FAIL } if (!context.canPlace()) { - logger.error("Cannot place at ${placeContext.blockPos} with current state ${placeContext.cachedState}", placeContext, request) + logger.error("Cannot place at ${interactContext.blockPos} with current state ${interactContext.cachedState}", interactContext, request) return ActionResult.FAIL } val itemPlacementContext = item.getPlacementContext(context) ?: run { - logger.error("Could not retrieve item placement context", placeContext, request) + logger.error("Could not retrieve item placement context", interactContext, request) return ActionResult.FAIL } val blockState = item.getPlacementState(itemPlacementContext) ?: run { - logger.error("Could not retrieve placement state", placeContext, request) + logger.error("Could not retrieve placement state", interactContext, request) return ActionResult.FAIL } - if (placeConfig.airPlace == PlaceConfig.AirPlaceMode.Grim) { + if (interactConfig.airPlace == InteractConfig.AirPlaceMode.Grim) { val placeHand = if (hand == Hand.MAIN_HAND) Hand.OFF_HAND else Hand.MAIN_HAND val inventoryRequest = inventoryRequest { swapHands() - action { sendPlacePacket(placeHand, hitResult) } + action { sendInteractPacket(placeHand, hitResult) } swapHands() }.submit(queueIfMismatchedStage = false) if (!inventoryRequest.done) return ActionResult.FAIL } else { - sendPlacePacket(hand, hitResult) - } - - if (placeConfig.placeConfirmationMode != PlaceConfig.PlaceConfirmationMode.None) { - PlaceInfo(placeContext, request.pendingInteractions, request.onPlace, placeConfig).startPending() + sendInteractPacket(hand, hitResult) } - val stackInHand = player.getStackInHand(hand) - val stackCountPre = stackInHand.count - - if (placeConfig.swing) { - swingHand(placeConfig.swingType, hand) - - if (!stackInHand.isEmpty && (stackInHand.count != stackCountPre || player.isInCreativeMode)) { - mc.gameRenderer.firstPersonRenderer.resetEquipProgress(hand) - } + if (interactConfig.placeConfirmationMode != InteractConfig.PlaceConfirmationMode.None) { + InteractInfo(interactContext, request.pendingInteractions, request.onPlace, interactConfig).startPending() } val itemStack = itemPlacementContext.stack itemStack.decrementUnlessCreative(1, player) - if (placeConfig.placeConfirmationMode == PlaceConfig.PlaceConfirmationMode.AwaitThenPlace) + if (interactConfig.placeConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) return ActionResult.SUCCESS // TODO: Implement restriction checks (e.g., world height) to prevent unnecessary server requests when the // "AwaitThenPlace" confirmation setting is enabled, as the block state setting methods that validate these // rules are not called. if (!item.place(itemPlacementContext, blockState)) { - logger.error("Could not place block client side at ${placeContext.blockPos} with placement state ${placeContext.expectedState}", placeContext, request) + logger.error("Could not place block client side at ${interactContext.blockPos} with placement state ${interactContext.expectedState}", interactContext, request) return ActionResult.FAIL } @@ -375,13 +365,13 @@ object PlaceManager : RequestHandler( state.block.onPlaced(world, blockPos, state, player, itemStack) } - if (placeConfig.sounds) placeSound(state, blockPos) + if (interactConfig.sounds) placeSound(state, blockPos) - if (placeConfig.placeConfirmationMode == PlaceConfig.PlaceConfirmationMode.None) { - request.onPlace?.invoke(this, placeContext.blockPos) + if (interactConfig.placeConfirmationMode == InteractConfig.PlaceConfirmationMode.None) { + request.onPlace?.invoke(this, interactContext.blockPos) } - logger.success("Placed ${placeContext.expectedState} at ${placeContext.blockPos}", placeContext, request) + logger.success("Placed ${interactContext.expectedState} at ${interactContext.blockPos}", interactContext, request) return ActionResult.SUCCESS } @@ -389,7 +379,7 @@ object PlaceManager : RequestHandler( /** * sends the block placement packet using the given [hand] and [hitResult]. */ - private fun SafeContext.sendPlacePacket(hand: Hand, hitResult: BlockHitResult) = + private fun SafeContext.sendInteractPacket(hand: Hand, hitResult: BlockHitResult) = interaction.sendSequencedPacket(world) { sequence: Int -> PlayerInteractBlockC2SPacket(hand, hitResult, sequence) } diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt index 299462c9e..67f08626f 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt @@ -17,40 +17,93 @@ package com.lambda.interaction.request.interacting -import com.lambda.Lambda.mc import com.lambda.context.Automated +import com.lambda.context.SafeContext import com.lambda.interaction.construction.context.BuildContext import com.lambda.interaction.construction.context.InteractContext +import com.lambda.interaction.construction.result.BuildResult +import com.lambda.interaction.construction.result.Dependent +import com.lambda.interaction.construction.result.results.InteractResult import com.lambda.interaction.request.LogContext import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder import com.lambda.interaction.request.Request +import com.lambda.threading.runSafe +import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.matches import net.minecraft.util.math.BlockPos -data class InteractRequest( - val contexts: Collection, - val pendingInteractionsList: MutableCollection, - private val automated: Automated, - override val nowOrNothing: Boolean = false, - val onInteract: ((BlockPos) -> Unit)? +data class InteractRequest private constructor( + val contexts: Collection, + val pendingInteractions: MutableCollection, + private val automated: Automated, + override val nowOrNothing: Boolean = false, ) : Request(), LogContext, Automated by automated { override val requestId = ++requestCount override val tickStageMask get() = interactConfig.tickStageMask + var onPlace: (SafeContext.(BlockPos) -> Unit)? = null + override val done: Boolean - get() = contexts.all { mc.world?.getBlockState(it.blockPos)?.matches(it.expectedState) == true } + get() = runSafe { + contexts.all { it.expectedState.matches(blockState(it.blockPos)) } + } == true override fun submit(queueIfMismatchedStage: Boolean) = - InteractionManager.request(this, queueIfMismatchedStage) + InteractManager.request(this, queueIfMismatchedStage) override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = { - group("Interact Request") { + group("PlaceRequest") { value("Request ID", requestId) value("Contexts", contexts.size) } } + @DslMarker + annotation class PlaceRequestDsl + + @PlaceRequestDsl + class PlaceRequestBuilder( + contexts: Collection, + pendingInteractions: MutableCollection, + nowOrNothing: Boolean, + automated: Automated + ) { + val request = InteractRequest(contexts, pendingInteractions, automated, nowOrNothing) + + @PlaceRequestDsl + fun onPlace(callback: SafeContext.(BlockPos) -> Unit) { + request.onPlace = callback + } + } + companion object { var requestCount = 0 + + @PlaceRequestDsl + @JvmName("interactRequest1") + context(automated: Automated) + fun Collection.interactRequest( + pendingInteractions: MutableCollection, + nowOrNothing: Boolean = false, + builder: (PlaceRequestBuilder.() -> Unit)? = null + ) = asSequence() + .map { if (it is Dependent) it.lastDependency else it } + .filterIsInstance() + .map { it.context } + .toSet() + .takeIf { it.isNotEmpty() } + ?.let { automated.interactRequest(it, pendingInteractions, nowOrNothing, builder) } + + @PlaceRequestDsl + @JvmName("interactRequest2") + fun Automated.interactRequest( + contexts: Collection, + pendingInteractions: MutableCollection, + nowOrNothing: Boolean = false, + builder: (PlaceRequestBuilder.() -> Unit)? = null + ) = PlaceRequestBuilder(contexts, pendingInteractions, nowOrNothing, this).apply { builder?.invoke(this) }.build() + + @PlaceRequestDsl + fun PlaceRequestBuilder.build() = request } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt index 6c5d7a253..a1128d416 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt @@ -17,30 +17,28 @@ package com.lambda.interaction.request.interacting -import com.lambda.Lambda.mc import com.lambda.config.AutomationConfig.Companion.DEFAULT import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.processing.ProcessorRegistry import com.lambda.interaction.request.PostActionHandler +import com.lambda.interaction.request.interacting.InteractManager.placeSound +import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.matches import com.lambda.util.Communication.info import com.lambda.util.Communication.warn import com.lambda.util.collections.LimitedDecayQueue -/** - * Designed to handle interactions pending a response from the server. - * - * @see InteractionManager - */ object InteractedBlockHandler : PostActionHandler() { override val pendingActions = LimitedDecayQueue( DEFAULT.buildConfig.maxPendingInteractions, DEFAULT.buildConfig.interactionTimeout * 50L ) { info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out") - if (it.interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.AwaitThenInteract) { - mc.world?.setBlockState(it.context.blockPos, it.context.cachedState) + if (it.interactConfig.placeConfirmationMode != InteractConfig.PlaceConfirmationMode.AwaitThenPlace) { + runSafe { + world.setBlockState(it.context.blockPos, it.context.cachedState) + } } it.pendingInteractionsList.remove(it.context) } @@ -62,18 +60,16 @@ object InteractedBlockHandler : PostActionHandler() { pending.stopPending() - this@InteractedBlockHandler.warn("Interacted block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}") + this@InteractedBlockHandler.warn("Placed block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}") return@listen } pending.stopPending() - //ToDo: reliable way to recreate the sounds played when interacting with any given block -// if (pending.interactConfirmationMode == InteractionConfig.InteractConfirmationMode.AwaitThenInteract) -// with (pending.context) { -// cachedState.onUse(world, player, Hand.MAIN_HAND, result) -// } + if (pending.interactConfig.placeConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) + with(pending.context) { placeSound(expectedState, blockPos) } + pending.onPlace?.invoke(this, pending.context.blockPos) } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractionManager.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractionManager.kt deleted file mode 100644 index 171aa14e7..000000000 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractionManager.kt +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.request.interacting - -import com.lambda.context.Automated -import com.lambda.context.AutomatedSafeContext -import com.lambda.event.EventFlow.post -import com.lambda.event.events.MovementEvent -import com.lambda.event.events.TickEvent -import com.lambda.event.events.UpdateManagerEvent -import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.request.Logger -import com.lambda.interaction.request.ManagerUtils.isPosBlocked -import com.lambda.interaction.request.ManagerUtils.newStage -import com.lambda.interaction.request.ManagerUtils.newTick -import com.lambda.interaction.request.PositionBlocking -import com.lambda.interaction.request.RequestHandler -import com.lambda.interaction.request.breaking.BreakManager -import com.lambda.interaction.request.interacting.InteractedBlockHandler.pendingActions -import com.lambda.interaction.request.interacting.InteractedBlockHandler.setPendingConfigs -import com.lambda.interaction.request.interacting.InteractedBlockHandler.startPending -import com.lambda.interaction.request.interacting.InteractionManager.activeRequest -import com.lambda.interaction.request.interacting.InteractionManager.maxInteractionsThisTick -import com.lambda.interaction.request.interacting.InteractionManager.populateFrom -import com.lambda.interaction.request.interacting.InteractionManager.potentialInteractions -import com.lambda.interaction.request.interacting.InteractionManager.processRequest -import com.lambda.interaction.request.placing.PlaceManager -import com.lambda.module.hud.ManagerDebugLoggers.interactionManagerLogger -import com.lambda.threading.runSafeAutomated -import com.lambda.util.player.MovementUtils.sneaking -import com.lambda.util.player.swingHand -import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket -import net.minecraft.util.Hand - -/** - * Manager responsible for handling block interactions other than placing. It can be accessed from anywhere - * through an [InteractRequest] - */ -object InteractionManager : RequestHandler( - 0, - onOpen = { - if (potentialInteractions.isNotEmpty()) - InteractionManager.logger.newStage(InteractionManager.tickStage) - activeRequest?.let { it.runSafeAutomated { processRequest(it) } } - } -), PositionBlocking, Logger { - private var activeRequest: InteractRequest? = null - private var potentialInteractions = mutableListOf() - - private var interactionsThisTick = 0 - private var maxInteractionsThisTick = 0 - - override val blockedPositions - get() = pendingActions.map { it.context.blockPos } - - override val logger = interactionManagerLogger - - override fun load(): String { - super.load() - - listen(priority = Int.MAX_VALUE) { - if (potentialInteractions.isNotEmpty()) - logger.newTick() - } - - listen(priority = Int.MIN_VALUE) { - activeRequest = null - interactionsThisTick = 0 - potentialInteractions.clear() - } - - listen(priority = Int.MIN_VALUE) { - if (potentialInteractions.isNotEmpty()) { - it.input.sneaking = false - } - } - - return "Loaded Interaction Manager" - } - - /** - * Attempts to accept and process the request, if there is not already an [activeRequest] and the request's [InteractRequest.contexts] - * collection is not empty. If nowOrNothing is true, the request is cleared after the first process. - * - * @see processRequest - */ - override fun AutomatedSafeContext.handleRequest(request: InteractRequest) { - if (activeRequest != null || request.contexts.isEmpty()) return - if (BreakManager.activeThisTick || PlaceManager.activeThisTick) return - - activeRequest = request - processRequest(request) - if (request.nowOrNothing) { - activeRequest = null - potentialInteractions = mutableListOf() - } - if (interactionsThisTick > 0) activeThisTick = true - } - - /** - * Handles populating the manager and performing interactions. - * - * @see populateFrom - */ - fun AutomatedSafeContext.processRequest(request: InteractRequest) { - logger.debug("Processing request", request) - - if (request.fresh) populateFrom(request) - - if (player.isSneaking) return - - val iterator = potentialInteractions.iterator() - while (iterator.hasNext()) { - if (interactionsThisTick + 1 > maxInteractionsThisTick) break - val ctx = iterator.next() - - if (!ctx.requestDependencies(request)) { - logger.warning("Dependencies failed for interaction", ctx, request) - return - } - if (tickStage !in interactConfig.tickStageMask) return - - if (interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.None) { - InteractInfo(ctx, request.pendingInteractionsList, request).startPending() - } - if (interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.AwaitThenInteract) { - interaction.interactBlock(player, Hand.MAIN_HAND, ctx.hitResult) - } else { - interaction.sendSequencedPacket(world) { sequence -> - PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, ctx.hitResult, sequence) - } - } - if (interactConfig.swingHand) { - swingHand(interactConfig.interactSwingType, Hand.MAIN_HAND) - } - request.onInteract?.invoke(ctx.blockPos) - interactionsThisTick++ - iterator.remove() - logger.success("interacted with ${ctx.cachedState} at ${ctx.blockPos}, changing to ${ctx.expectedState}", ctx, request) - } - } - - /** - * Populates the [potentialInteractions] collection, and sets the configurations - * - * @see setPendingConfigs - * @see maxInteractionsThisTick - */ - private fun Automated.populateFrom(request: InteractRequest) { - logger.debug("Populating from request", request) - setPendingConfigs() - potentialInteractions = request.contexts - .distinctBy { it.blockPos } - .filter { !isPosBlocked(it.blockPos) } - .take((buildConfig.maxPendingInteractions - pendingActions.size).coerceAtLeast(0)) - .toMutableList() - - logger.debug("${potentialInteractions.size} potential interactions") - - maxInteractionsThisTick = buildConfig.interactionsPerTick - } - - override fun preEvent() = UpdateManagerEvent.Interact.post() -} diff --git a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt b/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt index 2602e0705..01e198ae2 100644 --- a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt @@ -31,7 +31,7 @@ import com.lambda.interaction.request.inventory.InventoryManager.actions import com.lambda.interaction.request.inventory.InventoryManager.activeRequest import com.lambda.interaction.request.inventory.InventoryManager.alteredSlots import com.lambda.interaction.request.inventory.InventoryManager.processActiveRequest -import com.lambda.interaction.request.placing.PlaceManager +import com.lambda.interaction.request.interacting.InteractManager import com.lambda.module.hud.ManagerDebugLoggers.inventoryManagerLogger import com.lambda.threading.runSafe import com.lambda.util.collections.LimitedDecayQueue @@ -128,7 +128,7 @@ object InventoryManager : RequestHandler( } private fun populateFrom(request: InventoryRequest) { - PlaceManager.logger.debug("Populating from request", request) + InteractManager.logger.debug("Populating from request", request) activeRequest = request actions = request.actions.toMutableList() maxActionsThisSecond = request.inventoryConfig.actionsPerSecond @@ -142,7 +142,7 @@ object InventoryManager : RequestHandler( */ private fun SafeContext.processActiveRequest() { activeRequest?.let { active -> - PlaceManager.logger.debug("Processing request", active) + InteractManager.logger.debug("Processing request", active) if (tickStage !in active.inventoryConfig.tickStageMask && active.nowOrNothing) return val iterator = actions.iterator() while (iterator.hasNext()) { diff --git a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceConfig.kt b/src/main/kotlin/com/lambda/interaction/request/placing/PlaceConfig.kt deleted file mode 100644 index 07e91d185..000000000 --- a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceConfig.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.request.placing - -import com.lambda.config.ISettingGroup -import com.lambda.config.groups.ActionConfig -import com.lambda.config.groups.BuildConfig -import com.lambda.util.Describable -import com.lambda.util.NamedEnum - -interface PlaceConfig : ActionConfig, ISettingGroup { - val rotateForPlace: Boolean - val airPlace: AirPlaceMode - val axisRotateSetting: Boolean - val axisRotate get() = rotateForPlace && airPlace.isEnabled && axisRotateSetting - val placeConfirmationMode: PlaceConfirmationMode - val maxPendingPlacements: Int - val placementsPerTick: Int - val swing: Boolean - val swingType: BuildConfig.SwingType - val sounds: Boolean - - enum class AirPlaceMode( - override val displayName: String, - override val description: String - ) : NamedEnum, Describable { - None("None", "Do not attempt air placements; only place against valid supports."), - Standard("Standard", "Try common air-place techniques for convenience; moderate compatibility."), - Grim("Grim", "Use grim specific air placing.") - ; - - val isEnabled get() = this != None - } - - enum class PlaceConfirmationMode( - override val displayName: String, - override val description: String - ) : NamedEnum, Describable { - None("No confirmation", "Place immediately without waiting for the server; lowest latency, possible brief desync."), - PlaceThenAwait("Place now, confirm later", "Show placement right away, then wait for server confirmation to verify."), - AwaitThenPlace("Confirm first, then place", "Wait for server response before showing placement; most accurate, adds a short delay.") - } -} diff --git a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceInfo.kt b/src/main/kotlin/com/lambda/interaction/request/placing/PlaceInfo.kt deleted file mode 100644 index 718fe5909..000000000 --- a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceInfo.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.request.placing - -import com.lambda.context.SafeContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.context.PlaceContext -import com.lambda.interaction.request.ActionInfo -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import net.minecraft.util.math.BlockPos - -data class PlaceInfo( - override val context: PlaceContext, - override val pendingInteractionsList: MutableCollection, - val onPlace: (SafeContext.(BlockPos) -> Unit)?, - val placeConfig: PlaceConfig -) : ActionInfo, LogContext { - override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = { - group("Place Info") { - text(context.getLogContextBuilder()) - group("Callbacks") { - value("onPlace", onPlace != null) - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceRequest.kt b/src/main/kotlin/com/lambda/interaction/request/placing/PlaceRequest.kt deleted file mode 100644 index 8e3014428..000000000 --- a/src/main/kotlin/com/lambda/interaction/request/placing/PlaceRequest.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.request.placing - -import com.lambda.context.Automated -import com.lambda.context.SafeContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.context.PlaceContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.results.PlaceResult -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.Request -import com.lambda.threading.runSafe -import com.lambda.util.BlockUtils.blockState -import com.lambda.util.BlockUtils.matches -import net.minecraft.util.math.BlockPos - -data class PlaceRequest private constructor( - val contexts: Collection, - val pendingInteractions: MutableCollection, - private val automated: Automated, - override val nowOrNothing: Boolean = false, -) : Request(), LogContext, Automated by automated { - override val requestId = ++requestCount - override val tickStageMask get() = placeConfig.tickStageMask - - var onPlace: (SafeContext.(BlockPos) -> Unit)? = null - - override val done: Boolean - get() = runSafe { - contexts.all { it.expectedState.matches(blockState(it.blockPos)) } - } == true - - override fun submit(queueIfMismatchedStage: Boolean) = - PlaceManager.request(this, queueIfMismatchedStage) - - override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = { - group("PlaceRequest") { - value("Request ID", requestId) - value("Contexts", contexts.size) - } - } - - @DslMarker - annotation class PlaceRequestDsl - - @PlaceRequestDsl - class PlaceRequestBuilder( - contexts: Collection, - pendingInteractions: MutableCollection, - nowOrNothing: Boolean, - automated: Automated - ) { - val request = PlaceRequest(contexts, pendingInteractions, automated, nowOrNothing) - - @PlaceRequestDsl - fun onPlace(callback: SafeContext.(BlockPos) -> Unit) { - request.onPlace = callback - } - } - - companion object { - var requestCount = 0 - - @PlaceRequestDsl - @JvmName("placeRequest1") - context(automated: Automated) - fun Collection.placeRequest( - pendingInteractions: MutableCollection, - nowOrNothing: Boolean = false, - builder: (PlaceRequestBuilder.() -> Unit)? = null - ) = asSequence() - .map { if (it is Dependent) it.lastDependency else it } - .filterIsInstance() - .map { it.context } - .toSet() - .takeIf { it.isNotEmpty() } - ?.let { automated.placeRequest(it, pendingInteractions, nowOrNothing, builder) } - - @PlaceRequestDsl - @JvmName("placeRequest2") - fun Automated.placeRequest( - contexts: Collection, - pendingInteractions: MutableCollection, - nowOrNothing: Boolean = false, - builder: (PlaceRequestBuilder.() -> Unit)? = null - ) = PlaceRequestBuilder(contexts, pendingInteractions, nowOrNothing, this).apply { builder?.invoke(this) }.build() - - @PlaceRequestDsl - fun PlaceRequestBuilder.build() = request - } -} diff --git a/src/main/kotlin/com/lambda/interaction/request/placing/PlacedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/request/placing/PlacedBlockHandler.kt deleted file mode 100644 index 3b029f327..000000000 --- a/src/main/kotlin/com/lambda/interaction/request/placing/PlacedBlockHandler.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.request.placing - -import com.lambda.config.AutomationConfig.Companion.DEFAULT -import com.lambda.event.events.WorldEvent -import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.processing.ProcessorRegistry -import com.lambda.interaction.request.PostActionHandler -import com.lambda.interaction.request.placing.PlaceManager.placeSound -import com.lambda.threading.runSafe -import com.lambda.util.BlockUtils.matches -import com.lambda.util.Communication.info -import com.lambda.util.Communication.warn -import com.lambda.util.collections.LimitedDecayQueue - -object PlacedBlockHandler : PostActionHandler() { - override val pendingActions = LimitedDecayQueue( - DEFAULT.buildConfig.maxPendingInteractions, - DEFAULT.buildConfig.interactionTimeout * 50L - ) { - info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out") - if (it.placeConfig.placeConfirmationMode != PlaceConfig.PlaceConfirmationMode.AwaitThenPlace) { - runSafe { - world.setBlockState(it.context.blockPos, it.context.cachedState) - } - } - it.pendingInteractionsList.remove(it.context) - } - - init { - listen(priority = Int.MIN_VALUE) { event -> - pendingActions - .firstOrNull { it.context.blockPos == event.pos } - ?.let { pending -> - if (!pending.context.expectedState.matches(event.newState)) { - if (pending.context.cachedState.matches( - event.newState, - ProcessorRegistry.postProcessedProperties - ) - ) { - pending.context.cachedState = event.newState - return@listen - } - - pending.stopPending() - - this@PlacedBlockHandler.warn("Placed block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}") - return@listen - } - - pending.stopPending() - - if (pending.placeConfig.placeConfirmationMode == PlaceConfig.PlaceConfirmationMode.AwaitThenPlace) - with(pending.context) { placeSound(expectedState, blockPos) } - pending.onPlace?.invoke(this, pending.context.blockPos) - } - } - } -} diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt b/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt index 0ebbf2040..7f6665fc6 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt @@ -276,7 +276,7 @@ object VisibilityChecker { fun Box.getClosestPoints( pov: Vec3d, sides: Set, - preProcessing: PreProcessingData, + preProcessing: PreProcessingData?, allowInsideBox: Boolean, check: (Vec3d, Direction) -> Unit ) { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index 1b822cb30..dbe42cdb2 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -135,7 +135,7 @@ object KillAura : Module( // Attack interaction.attackEntity(player, target) - if (interactConfig.swingHand) player.swingHand(Hand.MAIN_HAND) + if (interactConfig.swing) player.swingHand(Hand.MAIN_HAND) lastAttackTime = System.currentTimeMillis() hitDelay = (hitDelay1..hitDelay2).random() * 50 diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index 3878e7947..b2abee144 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -59,7 +59,7 @@ object FastBreak : Module( ::suitableToolsOnly ) { defaultValue(false) } editTyped( - ::rotateForBreak, + ::rotate, ::doubleBreak ) { defaultValue(false); hide() } ::breaksPerTick.edit { defaultValue(1); hide() } diff --git a/src/main/kotlin/com/lambda/module/modules/player/Printer.kt b/src/main/kotlin/com/lambda/module/modules/player/Printer.kt index 6c16e3bc1..d3e670228 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Printer.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Printer.kt @@ -21,7 +21,7 @@ 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.request.placing.PlaceConfig +import com.lambda.interaction.request.interacting.InteractConfig import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask.run @@ -52,7 +52,7 @@ object Printer : Module( applyEdits { editTyped(buildConfig::pathing, buildConfig::stayInRange) { defaultValue(false) } editTyped(breakConfig::efficientOnly, breakConfig::suitableToolsOnly) { defaultValue(false) } - placeConfig::airPlace.edit { defaultValue(PlaceConfig.AirPlaceMode.Grim) } + interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) } } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt index 552faf9cd..a74ce7843 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt @@ -24,10 +24,9 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.result.results.PlaceResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.request.placing.PlaceRequest.Companion.placeRequest +import com.lambda.interaction.request.interacting.InteractRequest.Companion.interactRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafeAutomated @@ -35,7 +34,6 @@ import com.lambda.util.BlockUtils.blockPos import com.lambda.util.BlockUtils.blockState import com.lambda.util.InputUtils.isKeyPressed import com.lambda.util.KeyCode -import com.lambda.util.math.distSq import net.minecraft.util.math.BlockPos import java.util.concurrent.ConcurrentLinkedQueue @@ -49,7 +47,7 @@ object Scaffold : Module( private val descend by setting("Descend", KeyCode.Unbound, "Lower the place position by one to allow the player to lower y level") private val descendAmount by setting("Descend Amount", 1, 1..5, 1, "The amount to lower the place position by when descending", unit = " blocks") { descend != Bind.EMPTY } - private val pendingActions = ConcurrentLinkedQueue() + private val pendingInteractions = ConcurrentLinkedQueue() init { setDefaultAutomationConfig { @@ -60,7 +58,7 @@ object Scaffold : Module( hide() } } - hideAllGroupsExcept(placeConfig, rotationConfig, hotbarConfig) + hideAllGroupsExcept(interactConfig, rotationConfig, hotbarConfig) } } @@ -74,18 +72,15 @@ object Scaffold : Module( scaffoldPositions(beneath) .associateWith { TargetState.Solid(emptySet()) } .simulate() - .filterIsInstance() - .minByOrNull { it.pos distSq beneath } - ?.let { result -> - placeRequest(setOf(result.context), pendingActions).submit() - } + .interactRequest(pendingInteractions) + ?.submit() } } } private fun SafeContext.scaffoldPositions(beneath: BlockPos): List { if (!blockState(beneath).isReplaceable) return emptyList() - if (placeConfig.airPlace.isEnabled) return listOf(beneath) + if (interactConfig.airPlace.isEnabled) return listOf(beneath) return BlockPos.iterateOutwards(beneath, bridgeRange, bridgeRange, bridgeRange) .asSequence() diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index c067ed814..f3564ab49 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -41,16 +41,14 @@ import com.lambda.interaction.construction.result.Resolvable import com.lambda.interaction.construction.result.results.BreakResult import com.lambda.interaction.construction.result.results.GenericResult import com.lambda.interaction.construction.result.results.InteractResult -import com.lambda.interaction.construction.result.results.PlaceResult import com.lambda.interaction.construction.result.results.PreSimResult import com.lambda.interaction.construction.simulation.BuildGoal import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.Simulation.Companion.simulation import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.request.breaking.BreakRequest.Companion.breakRequest -import com.lambda.interaction.request.interacting.InteractRequest +import com.lambda.interaction.request.interacting.InteractRequest.Companion.interactRequest import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest -import com.lambda.interaction.request.placing.PlaceRequest.Companion.placeRequest import com.lambda.task.Task import com.lambda.task.tasks.EatTask.Companion.eat import com.lambda.threading.runSafeAutomated @@ -154,7 +152,7 @@ class BuildTask private constructor( } is GenericResult.NotVisible, - is PlaceResult.NoIntegrity -> { + is InteractResult.NoIntegrity -> { if (!buildConfig.pathing) return val sim = blueprint.simulation() val goal = BuildGoal(sim, player.blockPos) @@ -176,24 +174,10 @@ class BuildTask private constructor( } }?.submit() - is PlaceResult.Place -> - allResults.placeRequest(pendingInteractions, false) { + is InteractResult.Interact -> + allResults.interactRequest(pendingInteractions, false) { onPlace { placements++ } }?.submit() - - is InteractResult.Interact -> { - val interactResults = allResults - .map { if (it is Dependent) it.lastDependency else it } - .filterIsInstance() - .map { it.context } - - InteractRequest( - interactResults, - pendingInteractions, - this@BuildTask, - onInteract = null - ).submit(queueIfMismatchedStage = true) - } } } diff --git a/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt b/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt index 8b83e84e3..935c6c4df 100644 --- a/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt +++ b/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt @@ -22,7 +22,7 @@ import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.PlaceResult +import com.lambda.interaction.construction.result.results.InteractResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.request.ManagerUtils @@ -58,7 +58,7 @@ class PlaceContainer @Ta5kBuilder constructor( } } - val options = results.filterIsInstance().filter { + val options = results.filterIsInstance().filter { canBeOpened(startStack, it.pos, it.context.hitResult.side) } + results.filterIsInstance() From 96ad379a92317afef5d39fe05b892a546fd83b4c Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Sat, 6 Dec 2025 17:13:39 +0000 Subject: [PATCH 2/7] rename placement settings to interaction settings --- .../com/lambda/config/groups/InteractSettings.kt | 16 ++++++++-------- .../request/interacting/InteractConfig.kt | 6 +++--- .../request/interacting/InteractManager.kt | 10 +++++----- .../interacting/InteractedBlockHandler.kt | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index 0b273157f..5a4c20795 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -30,15 +30,15 @@ class InteractSettings( c: Configurable, baseGroup: NamedEnum ) : SettingGroup(c), InteractConfig { - override val rotate by c.setting("Rotate For Place", true, "Rotate towards block while placing").group(baseGroup).index() + override val rotate by c.setting("Rotate For Interact", true, "Rotate towards block while placing").group(baseGroup).index() override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index() override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled }.group(baseGroup).index() - override val sorter by c.setting("Place Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index() - override val tickStageMask by c.setting("Place Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which place actions are performed").group(baseGroup).index() - override val placeConfirmationMode by c.setting("Place Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index() - override val maxPendingPlacements by c.setting("Max Pending Placements", 5, 0..30, 1, "The maximum amount of pending placements").group(baseGroup).index() - override val placementsPerTick by c.setting("Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index() - override val swing by c.setting("Swing On Place", true, "Swings the players hand when placing").group(baseGroup).index() - override val swingType by c.setting("Place Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing }.group(baseGroup).index() + override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index() + override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which place actions are performed").group(baseGroup).index() + override val interactConfirmationMode by c.setting("Interact Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index() + override val maxPendingInteractions by c.setting("Max Pending Interactions", 5, 0..30, 1, "The maximum amount of pending placements").group(baseGroup).index() + override val interactionsPerTick by c.setting("Interactions Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index() + override val swing by c.setting("Swing On Interact", true, "Swings the players hand when placing").group(baseGroup).index() + override val swingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing }.group(baseGroup).index() override val sounds by c.setting("Place Sounds", true, "Plays the placing sounds").group(baseGroup).index() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt index 67e92740f..2dfc3133f 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt @@ -28,9 +28,9 @@ interface InteractConfig : ActionConfig, ISettingGroup { val airPlace: AirPlaceMode val axisRotateSetting: Boolean val axisRotate get() = rotate && airPlace.isEnabled && axisRotateSetting - val placeConfirmationMode: PlaceConfirmationMode - val maxPendingPlacements: Int - val placementsPerTick: Int + val interactConfirmationMode: PlaceConfirmationMode + val maxPendingInteractions: Int + val interactionsPerTick: Int val swing: Boolean val swingType: BuildConfig.SwingType val sounds: Boolean diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt index f091bbe43..96a9801eb 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt @@ -200,14 +200,14 @@ object InteractManager : RequestHandler( .filter { !isPosBlocked(it.blockPos) } .take( min( - interactConfig.maxPendingPlacements - pendingActions.size, + interactConfig.maxPendingInteractions - pendingActions.size, buildConfig.maxPendingInteractions - request.pendingInteractions.size ).coerceAtLeast(0) ) .toMutableList() logger.debug("${potentialPlacements.size} potential placements") - maxPlacementsThisTick = interactConfig.placementsPerTick + maxPlacementsThisTick = interactConfig.interactionsPerTick } /** @@ -339,14 +339,14 @@ object InteractManager : RequestHandler( sendInteractPacket(hand, hitResult) } - if (interactConfig.placeConfirmationMode != InteractConfig.PlaceConfirmationMode.None) { + if (interactConfig.interactConfirmationMode != InteractConfig.PlaceConfirmationMode.None) { InteractInfo(interactContext, request.pendingInteractions, request.onPlace, interactConfig).startPending() } val itemStack = itemPlacementContext.stack itemStack.decrementUnlessCreative(1, player) - if (interactConfig.placeConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) + if (interactConfig.interactConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) return ActionResult.SUCCESS // TODO: Implement restriction checks (e.g., world height) to prevent unnecessary server requests when the @@ -367,7 +367,7 @@ object InteractManager : RequestHandler( if (interactConfig.sounds) placeSound(state, blockPos) - if (interactConfig.placeConfirmationMode == InteractConfig.PlaceConfirmationMode.None) { + if (interactConfig.interactConfirmationMode == InteractConfig.PlaceConfirmationMode.None) { request.onPlace?.invoke(this, interactContext.blockPos) } diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt index a1128d416..3d11e59fa 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt @@ -35,7 +35,7 @@ object InteractedBlockHandler : PostActionHandler() { DEFAULT.buildConfig.interactionTimeout * 50L ) { info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out") - if (it.interactConfig.placeConfirmationMode != InteractConfig.PlaceConfirmationMode.AwaitThenPlace) { + if (it.interactConfig.interactConfirmationMode != InteractConfig.PlaceConfirmationMode.AwaitThenPlace) { runSafe { world.setBlockState(it.context.blockPos, it.context.cachedState) } @@ -66,7 +66,7 @@ object InteractedBlockHandler : PostActionHandler() { pending.stopPending() - if (pending.interactConfig.placeConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) + if (pending.interactConfig.interactConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) with(pending.context) { placeSound(expectedState, blockPos) } pending.onPlace?.invoke(this, pending.context.blockPos) } From 86f42286a8610509678dec9e74e6cb59f7322122 Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Sat, 6 Dec 2025 18:21:25 +0000 Subject: [PATCH 3/7] cleanup; 142 files changed lol --- .../baritone/MixinBaritonePlayerContext.java | 2 +- .../mixin/baritone/MixinLookBehavior.java | 2 +- .../mixin/entity/ClientPlayerEntityMixin.java | 8 +- .../com/lambda/mixin/entity/EntityMixin.java | 4 +- .../mixin/entity/HandledScreensMixin.java | 2 +- .../mixin/entity/LivingEntityMixin.java | 2 +- .../mixin/entity/PlayerEntityMixin.java | 2 +- .../mixin/entity/PlayerInventoryMixin.java | 2 +- .../ClientPlayNetworkHandlerMixin.java | 2 +- .../com/lambda/mixin/render/CameraMixin.java | 2 +- .../render/LivingEntityRendererMixin.java | 2 +- .../com/lambda/config/AutomationConfig.kt | 2 +- .../lambda/config/MutableAutomationConfig.kt | 10 +-- .../com/lambda/config/groups/BreakSettings.kt | 10 +-- .../com/lambda/config/groups/BuildConfig.kt | 8 +- .../com/lambda/config/groups/BuildSettings.kt | 8 +- .../lambda/config/groups/HotbarSettings.kt | 2 +- .../lambda/config/groups/InteractSettings.kt | 6 +- .../lambda/config/groups/InventorySettings.kt | 2 +- .../lambda/config/groups/RotationSettings.kt | 4 +- .../com/lambda/config/groups/Targeting.kt | 6 +- .../kotlin/com/lambda/context/Automated.kt | 10 +-- .../com/lambda/event/events/InventoryEvent.kt | 2 +- .../lambda/event/events/PlayerPacketEvent.kt | 2 +- .../com/lambda/event/events/RotationEvent.kt | 2 +- .../interaction/MovementConfiguration.kt | 29 ------ ...acketManager.kt => PlayerPacketHandler.kt} | 6 +- .../construction/simulation/BuildSimulator.kt | 5 +- .../construction/simulation/Results.kt | 4 +- .../construction/simulation/Sim.kt | 21 +++-- .../construction/simulation/SimInfo.kt | 8 +- .../construction/simulation/Simulation.kt | 4 +- .../simulation/checks/BasicChecker.kt | 4 +- .../simulation/checks/BreakSim.kt | 18 ++-- .../simulation/checks/InteractSim.kt | 24 ++--- .../{ => simulation}/context/BreakContext.kt | 10 +-- .../{ => simulation}/context/BuildContext.kt | 6 +- .../context/InteractContext.kt | 16 ++-- .../processing/PlacementProcessor.kt | 8 +- .../processing/PreProcessingInfo.kt | 8 +- .../processing/ProcessorRegistry.kt | 10 +-- .../post/StandardInteractPreProcessor.kt | 8 +- .../placement/pre/AttachmentPreProcessor.kt | 6 +- .../placement/pre/AxisPreProcessor.kt | 6 +- .../placement/pre/BlockFacePreProcessor.kt | 6 +- .../placement/pre/BlockHalfPreProcessor.kt | 6 +- .../placement/pre/DoorHingePreProcessor.kt | 6 +- .../placement/pre/HopperFacingPreProcessor.kt | 6 +- .../placement/pre/SlabPreProcessor.kt | 6 +- .../preprocessors/state/BambooPreProcessor.kt | 6 +- .../preprocessors/state/FirePreProcessor.kt | 6 +- .../state/FlowerPotPreProcessor.kt | 6 +- .../{ => simulation}/result/BuildResult.kt | 2 +- .../result/ComparableResult.kt | 2 +- .../{ => simulation}/result/Contextual.kt | 10 +-- .../{ => simulation}/result/Dependent.kt | 2 +- .../{ => simulation}/result/Drawable.kt | 2 +- .../{ => simulation}/result/Navigable.kt | 2 +- .../{ => simulation}/result/Rank.kt | 2 +- .../{ => simulation}/result/Resolvable.kt | 2 +- .../result/results/BreakResult.kt | 20 ++--- .../result/results/GenericResult.kt | 14 +-- .../result/results/InteractResult.kt | 18 ++-- .../result/results/PostSimResult.kt | 6 +- .../result/results/PreSimResult.kt | 12 +-- .../{request => managers}/ActionInfo.kt | 4 +- .../{request => managers}/DebugLogger.kt | 4 +- .../{request => managers}/LogContext.kt | 2 +- .../{request => managers}/Logger.kt | 2 +- .../RequestHandler.kt => managers/Manager.kt} | 6 +- .../{request => managers}/ManagerUtils.kt | 4 +- .../{request => managers}/PositionBlocking.kt | 2 +- .../PostActionHandler.kt | 6 +- .../{request => managers}/Request.kt | 2 +- .../breaking/BreakConfig.kt | 2 +- .../breaking/BreakInfo.kt | 20 ++--- .../breaking/BreakManager.kt | 88 +++++++++---------- .../breaking/BreakRequest.kt | 20 ++--- .../breaking/BrokenBlockHandler.kt | 16 ++-- .../breaking/RebreakHandler.kt | 10 +-- .../breaking/RebreakResult.kt | 2 +- .../breaking/SwapInfo.kt | 12 +-- .../hotbar/HotbarConfig.kt | 2 +- .../hotbar/HotbarManager.kt | 22 ++--- .../hotbar/HotbarRequest.kt | 8 +- .../interacting/InteractConfig.kt | 2 +- .../interacting/InteractInfo.kt | 12 +-- .../interacting/InteractManager.kt | 40 ++++----- .../interacting/InteractRequest.kt | 18 ++-- .../interacting/InteractedBlockHandler.kt | 12 +-- .../inventory/InventoryAction.kt | 2 +- .../inventory/InventoryConfig.kt | 2 +- .../inventory/InventoryManager.kt | 18 ++-- .../inventory/InventoryRequest.kt | 8 +- .../rotating/Rotation.kt | 2 +- .../rotating/RotationConfig.kt | 2 +- .../rotating/RotationManager.kt | 20 ++--- .../rotating/RotationMode.kt | 2 +- .../rotating/RotationRequest.kt | 10 +-- .../rotating/visibilty/PlaceDirection.kt | 4 +- .../rotating/visibilty/PointSelection.kt | 6 +- .../rotating/visibilty/RequestedHit.kt | 8 +- .../rotating/visibilty/RequestedHitDsl.kt | 2 +- .../rotating/visibilty/RotationTarget.kt | 10 +-- .../rotating/visibilty/RotationTargets.kt | 12 +-- .../rotating/visibilty/VisibilityChecker.kt | 10 +-- .../container/containers/CreativeContainer.kt | 2 +- .../container/containers/MainHandContainer.kt | 2 +- .../material/transfer/SlotTransfer.kt | 2 +- .../lambda/module/hud/ManagerDebugLoggers.kt | 2 +- .../lambda/module/modules/combat/Criticals.kt | 4 +- .../module/modules/combat/CrystalAura.kt | 8 +- .../lambda/module/modules/combat/KillAura.kt | 4 +- .../module/modules/debug/RotationTest.kt | 2 +- .../lambda/module/modules/debug/SilentSwap.kt | 4 +- .../module/modules/movement/BetterFirework.kt | 4 +- .../lambda/module/modules/movement/Speed.kt | 8 +- .../module/modules/movement/TargetStrafe.kt | 2 +- .../module/modules/network/Rubberband.kt | 8 +- .../lambda/module/modules/player/AntiAim.kt | 12 +-- .../lambda/module/modules/player/FastBreak.kt | 6 +- .../lambda/module/modules/player/Freecam.kt | 8 +- .../module/modules/player/InventoryMove.kt | 8 +- .../module/modules/player/PacketMine.kt | 10 +-- .../lambda/module/modules/player/Printer.kt | 2 +- .../lambda/module/modules/player/Replay.kt | 8 +- .../module/modules/player/RotationLock.kt | 6 +- .../lambda/module/modules/player/Scaffold.kt | 4 +- .../lambda/module/modules/render/FreeLook.kt | 2 +- .../lambda/module/modules/render/Particles.kt | 2 +- .../com/lambda/task/tasks/AcquireMaterial.kt | 1 - .../kotlin/com/lambda/task/tasks/BuildTask.kt | 30 +++---- .../com/lambda/task/tasks/OpenContainer.kt | 2 +- .../com/lambda/task/tasks/PlaceContainer.kt | 6 +- .../com/lambda/util/extension/Entity.kt | 2 +- .../kotlin/com/lambda/util/math/Linear.kt | 2 +- .../com/lambda/util/player/MovementUtils.kt | 2 +- .../player/prediction/PredictionEntity.kt | 2 +- .../util/player/prediction/PredictionTick.kt | 2 +- .../lambda/util/world/raycast/RayCastUtils.kt | 2 +- src/test/kotlin/PlaceDirectionTest.kt | 4 +- src/test/kotlin/RotationTest.kt | 12 +-- 142 files changed, 519 insertions(+), 551 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/interaction/MovementConfiguration.kt rename src/main/kotlin/com/lambda/interaction/{PlayerPacketManager.kt => PlayerPacketHandler.kt} (96%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/context/BreakContext.kt (89%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/context/BuildContext.kt (88%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/context/InteractContext.kt (84%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/PlacementProcessor.kt (72%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/PreProcessingInfo.kt (87%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/ProcessorRegistry.kt (92%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt (73%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt (84%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt (81%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt (84%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt (85%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt (88%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt (83%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt (88%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/state/BambooPreProcessor.kt (86%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/state/FirePreProcessor.kt (83%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/processing/preprocessors/state/FlowerPotPreProcessor.kt (85%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/BuildResult.kt (94%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/ComparableResult.kt (94%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/Contextual.kt (87%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/Dependent.kt (94%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/Drawable.kt (93%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/Navigable.kt (93%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/Rank.kt (95%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/Resolvable.kt (93%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/results/BreakResult.kt (89%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/results/GenericResult.kt (91%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/results/InteractResult.kt (91%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/results/PostSimResult.kt (83%) rename src/main/kotlin/com/lambda/interaction/construction/{ => simulation}/result/results/PreSimResult.kt (91%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/ActionInfo.kt (89%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/DebugLogger.kt (98%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/LogContext.kt (98%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/Logger.kt (94%) rename src/main/kotlin/com/lambda/interaction/{request/RequestHandler.kt => managers/Manager.kt} (96%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/ManagerUtils.kt (93%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/PositionBlocking.kt (96%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/PostActionHandler.kt (93%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/Request.kt (97%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/BreakConfig.kt (99%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/BreakInfo.kt (90%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/BreakManager.kt (91%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/BreakRequest.kt (90%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/BrokenBlockHandler.kt (92%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/RebreakHandler.kt (93%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/RebreakResult.kt (94%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/breaking/SwapInfo.kt (88%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/hotbar/HotbarConfig.kt (97%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/hotbar/HotbarManager.kt (90%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/hotbar/HotbarRequest.kt (89%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/interacting/InteractConfig.kt (97%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/interacting/InteractInfo.kt (76%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/interacting/InteractManager.kt (91%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/interacting/InteractRequest.kt (84%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/interacting/InteractedBlockHandler.kt (88%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/inventory/InventoryAction.kt (95%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/inventory/InventoryConfig.kt (98%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/inventory/InventoryManager.kt (94%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/inventory/InventoryRequest.kt (96%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/Rotation.kt (99%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/RotationConfig.kt (97%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/RotationManager.kt (95%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/RotationMode.kt (96%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/RotationRequest.kt (85%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/PlaceDirection.kt (96%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/PointSelection.kt (90%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/RequestedHit.kt (93%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/RequestedHitDsl.kt (95%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/RotationTarget.kt (84%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/RotationTargets.kt (91%) rename src/main/kotlin/com/lambda/interaction/{request => managers}/rotating/visibilty/VisibilityChecker.kt (97%) diff --git a/src/main/java/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java b/src/main/java/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java index b599bf794..f6c7f6451 100644 --- a/src/main/java/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java +++ b/src/main/java/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java @@ -21,7 +21,7 @@ import baritone.api.utils.Rotation; import baritone.utils.player.BaritonePlayerContext; import com.lambda.interaction.BaritoneManager; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationManager; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java b/src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java index d32aaf9ec..85a519d87 100644 --- a/src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java +++ b/src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java @@ -22,7 +22,7 @@ import baritone.api.utils.Rotation; import baritone.behavior.LookBehavior; import com.lambda.interaction.BaritoneManager; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java b/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java index c31ed4b87..0a37b5178 100644 --- a/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java +++ b/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java @@ -22,8 +22,8 @@ import com.lambda.event.events.MovementEvent; import com.lambda.event.events.PlayerEvent; import com.lambda.event.events.TickEvent; -import com.lambda.interaction.PlayerPacketManager; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.PlayerPacketHandler; +import com.lambda.interaction.managers.rotating.RotationManager; import com.lambda.module.modules.player.PortalGui; import com.lambda.module.modules.render.ViewModel; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; @@ -80,13 +80,13 @@ void processMovement(Input input) { @Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true) void sendLambdaMovement(CallbackInfo ci) { ci.cancel(); - PlayerPacketManager.sendPlayerPackets(); + PlayerPacketHandler.sendPlayerPackets(); autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue(); } @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V")) void sendSneakingPacket(ClientPlayerEntity entity) { - PlayerPacketManager.sendSneakPackets(); + PlayerPacketHandler.sendSneakPackets(); } @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z")) diff --git a/src/main/java/com/lambda/mixin/entity/EntityMixin.java b/src/main/java/com/lambda/mixin/entity/EntityMixin.java index 0e99fed9f..a6a57a69a 100644 --- a/src/main/java/com/lambda/mixin/entity/EntityMixin.java +++ b/src/main/java/com/lambda/mixin/entity/EntityMixin.java @@ -21,8 +21,8 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.EntityEvent; import com.lambda.event.events.PlayerEvent; -import com.lambda.interaction.request.rotating.RotationManager; -import com.lambda.interaction.request.rotating.RotationMode; +import com.lambda.interaction.managers.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationMode; import com.lambda.module.modules.player.RotationLock; import com.lambda.module.modules.render.NoRender; import com.lambda.util.math.Vec2d; diff --git a/src/main/java/com/lambda/mixin/entity/HandledScreensMixin.java b/src/main/java/com/lambda/mixin/entity/HandledScreensMixin.java index 000c4567f..30e1e64c8 100644 --- a/src/main/java/com/lambda/mixin/entity/HandledScreensMixin.java +++ b/src/main/java/com/lambda/mixin/entity/HandledScreensMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.entity; -import com.lambda.interaction.request.inventory.InventoryManager; +import com.lambda.interaction.managers.inventory.InventoryManager; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.HandledScreens; import net.minecraft.screen.ScreenHandler; diff --git a/src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java b/src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java index 329c76f04..97180eaca 100644 --- a/src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java +++ b/src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java @@ -20,7 +20,7 @@ import com.lambda.Lambda; import com.lambda.event.EventFlow; import com.lambda.event.events.MovementEvent; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationManager; import com.lambda.module.modules.movement.Velocity; import com.lambda.module.modules.render.ViewModel; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; diff --git a/src/main/java/com/lambda/mixin/entity/PlayerEntityMixin.java b/src/main/java/com/lambda/mixin/entity/PlayerEntityMixin.java index 457719846..06ceb00e4 100644 --- a/src/main/java/com/lambda/mixin/entity/PlayerEntityMixin.java +++ b/src/main/java/com/lambda/mixin/entity/PlayerEntityMixin.java @@ -20,7 +20,7 @@ import com.lambda.Lambda; import com.lambda.event.EventFlow; import com.lambda.event.events.MovementEvent; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationManager; import net.minecraft.entity.player.PlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/com/lambda/mixin/entity/PlayerInventoryMixin.java b/src/main/java/com/lambda/mixin/entity/PlayerInventoryMixin.java index 31c17d179..b15a8af21 100644 --- a/src/main/java/com/lambda/mixin/entity/PlayerInventoryMixin.java +++ b/src/main/java/com/lambda/mixin/entity/PlayerInventoryMixin.java @@ -18,7 +18,7 @@ package com.lambda.mixin.entity; import com.lambda.Lambda; -import com.lambda.interaction.request.hotbar.HotbarManager; +import com.lambda.interaction.managers.hotbar.HotbarManager; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.entity.player.PlayerInventory; import org.objectweb.asm.Opcodes; diff --git a/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java b/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java index 9762bed0a..09ddeba56 100644 --- a/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java @@ -20,7 +20,7 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.InventoryEvent; import com.lambda.event.events.WorldEvent; -import com.lambda.interaction.request.inventory.InventoryManager; +import com.lambda.interaction.managers.inventory.InventoryManager; import com.lambda.module.modules.movement.Velocity; import com.lambda.module.modules.render.NoRender; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; diff --git a/src/main/java/com/lambda/mixin/render/CameraMixin.java b/src/main/java/com/lambda/mixin/render/CameraMixin.java index ed91975c5..7b618d8be 100644 --- a/src/main/java/com/lambda/mixin/render/CameraMixin.java +++ b/src/main/java/com/lambda/mixin/render/CameraMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationManager; import com.lambda.module.modules.player.Freecam; import com.lambda.module.modules.render.CameraTweaks; import com.lambda.module.modules.render.FreeLook; diff --git a/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java b/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java index e9fff0577..5ce465d21 100644 --- a/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java @@ -18,7 +18,7 @@ package com.lambda.mixin.render; import com.lambda.Lambda; -import com.lambda.interaction.request.rotating.RotationManager; +import com.lambda.interaction.managers.rotating.RotationManager; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.client.render.entity.LivingEntityRenderer; diff --git a/src/main/kotlin/com/lambda/config/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/AutomationConfig.kt index 03b6640bc..e7585081f 100644 --- a/src/main/kotlin/com/lambda/config/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/AutomationConfig.kt @@ -27,7 +27,7 @@ import com.lambda.config.groups.InteractSettings import com.lambda.config.groups.RotationSettings import com.lambda.context.Automated import com.lambda.event.events.onStaticRender -import com.lambda.interaction.construction.result.Drawable +import com.lambda.interaction.construction.simulation.result.Drawable import com.lambda.module.Module import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt index c7142ae45..06f8d7e80 100644 --- a/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt @@ -20,11 +20,11 @@ package com.lambda.config import com.lambda.config.groups.BuildConfig import com.lambda.config.groups.EatConfig import com.lambda.context.Automated -import com.lambda.interaction.request.breaking.BreakConfig -import com.lambda.interaction.request.hotbar.HotbarConfig -import com.lambda.interaction.request.interacting.InteractConfig -import com.lambda.interaction.request.inventory.InventoryConfig -import com.lambda.interaction.request.rotating.RotationConfig +import com.lambda.interaction.managers.breaking.BreakConfig +import com.lambda.interaction.managers.hotbar.HotbarConfig +import com.lambda.interaction.managers.interacting.InteractConfig +import com.lambda.interaction.managers.inventory.InventoryConfig +import com.lambda.interaction.managers.rotating.RotationConfig interface MutableAutomationConfig : Automated { var defaultAutomationConfig: AutomationConfig diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt index a3117d806..86b16be62 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt @@ -21,11 +21,11 @@ import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.request.breaking.BreakConfig -import com.lambda.interaction.request.breaking.BreakConfig.AnimationMode -import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode -import com.lambda.interaction.request.breaking.BreakConfig.BreakMode -import com.lambda.interaction.request.breaking.BreakConfig.SwingMode +import com.lambda.interaction.managers.breaking.BreakConfig +import com.lambda.interaction.managers.breaking.BreakConfig.AnimationMode +import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode +import com.lambda.interaction.managers.breaking.BreakConfig.BreakMode +import com.lambda.interaction.managers.breaking.BreakConfig.SwingMode import com.lambda.util.BlockUtils.allSigns import com.lambda.util.NamedEnum import java.awt.Color diff --git a/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt b/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt index 31dab753c..d74023165 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt @@ -18,7 +18,7 @@ package com.lambda.config.groups import com.lambda.config.ISettingGroup -import com.lambda.interaction.request.rotating.visibilty.PointSelection +import com.lambda.interaction.managers.rotating.visibilty.PointSelection import com.lambda.util.Describable import com.lambda.util.NamedEnum @@ -28,9 +28,9 @@ interface BuildConfig : ISettingGroup { val stayInRange: Boolean val collectDrops: Boolean val spleefEntities: Boolean - val interactionsPerTick: Int - val maxPendingInteractions: Int - val interactionTimeout: Int + val actionsPerTick: Int + val maxPendingActions: Int + val actionTimeout: Int val maxBuildDependencies: Int val useDefaultReach: Boolean diff --git a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt index 11d3c9d4f..580b23555 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt @@ -19,7 +19,7 @@ package com.lambda.config.groups import com.lambda.config.Configurable import com.lambda.config.SettingGroup -import com.lambda.interaction.request.rotating.visibilty.PointSelection +import com.lambda.interaction.managers.rotating.visibilty.PointSelection import com.lambda.util.NamedEnum import kotlin.math.max @@ -38,9 +38,9 @@ class BuildSettings( override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks").group(baseGroup, Group.General).index() override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks").group(baseGroup, Group.General).index() override val spleefEntities by c.setting("Spleef Entities", false, "Breaks blocks beneath entities blocking placements to get them out of the way").group(baseGroup, Group.General).index() - override val interactionsPerTick by c.setting("Interactions Per Tick", 5, 1..30, 1, "The amount of interactions that can happen per tick").group(baseGroup, Group.General).index() - override val maxPendingInteractions by c.setting("Max Pending Interactions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions").group(baseGroup, Group.General).index() - override val interactionTimeout by c.setting("Interaction Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks").group(baseGroup, Group.General).index() + override val actionsPerTick by c.setting("Actions Per Tick", 5, 1..30, 1, "The amount of interactions that can happen per tick").group(baseGroup, Group.General).index() + override val maxPendingActions by c.setting("Max Pending Actions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions").group(baseGroup, Group.General).index() + override val actionTimeout by c.setting("Action Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks").group(baseGroup, Group.General).index() override val maxBuildDependencies by c.setting("Max Sim Dependencies", 3, 0..10, 1, "Maximum dependency build results").group(baseGroup, Group.General).index() override val useDefaultReach by c.setting("Default Reach", true, "Whether to use vanilla interaction ranges").group(baseGroup, Group.Reach).index() diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt index 35e6e7948..fa64ade1d 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt @@ -21,7 +21,7 @@ import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.request.hotbar.HotbarConfig +import com.lambda.interaction.managers.hotbar.HotbarConfig import com.lambda.util.NamedEnum class HotbarSettings( diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index 5a4c20795..375a68660 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -21,9 +21,9 @@ import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.request.interacting.InteractConfig -import com.lambda.interaction.request.interacting.InteractConfig.AirPlaceMode -import com.lambda.interaction.request.interacting.InteractConfig.PlaceConfirmationMode +import com.lambda.interaction.managers.interacting.InteractConfig +import com.lambda.interaction.managers.interacting.InteractConfig.AirPlaceMode +import com.lambda.interaction.managers.interacting.InteractConfig.PlaceConfirmationMode import com.lambda.util.NamedEnum class InteractSettings( diff --git a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt index 3157fad74..294d4c080 100644 --- a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt @@ -20,7 +20,7 @@ package com.lambda.config.groups import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.request.inventory.InventoryConfig +import com.lambda.interaction.managers.inventory.InventoryConfig import com.lambda.util.NamedEnum import com.lambda.util.item.ItemUtils diff --git a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt b/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt index 7ede84a57..49bd347ef 100644 --- a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt @@ -21,8 +21,8 @@ import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.request.rotating.RotationConfig -import com.lambda.interaction.request.rotating.RotationMode +import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.util.NamedEnum import kotlin.math.PI import kotlin.math.abs diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/Targeting.kt index ca7c8860c..28f9d31c9 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/Targeting.kt @@ -21,9 +21,9 @@ import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.context.SafeContext import com.lambda.friend.FriendManager.isFriend -import com.lambda.interaction.request.rotating.Rotation.Companion.dist -import com.lambda.interaction.request.rotating.Rotation.Companion.rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.threading.runSafe import com.lambda.util.NamedEnum import com.lambda.util.extension.fullHealth diff --git a/src/main/kotlin/com/lambda/context/Automated.kt b/src/main/kotlin/com/lambda/context/Automated.kt index efada2284..8cabc8128 100644 --- a/src/main/kotlin/com/lambda/context/Automated.kt +++ b/src/main/kotlin/com/lambda/context/Automated.kt @@ -19,11 +19,11 @@ package com.lambda.context import com.lambda.config.groups.BuildConfig import com.lambda.config.groups.EatConfig -import com.lambda.interaction.request.breaking.BreakConfig -import com.lambda.interaction.request.hotbar.HotbarConfig -import com.lambda.interaction.request.inventory.InventoryConfig -import com.lambda.interaction.request.interacting.InteractConfig -import com.lambda.interaction.request.rotating.RotationConfig +import com.lambda.interaction.managers.breaking.BreakConfig +import com.lambda.interaction.managers.hotbar.HotbarConfig +import com.lambda.interaction.managers.interacting.InteractConfig +import com.lambda.interaction.managers.inventory.InventoryConfig +import com.lambda.interaction.managers.rotating.RotationConfig interface Automated { val buildConfig: BuildConfig diff --git a/src/main/kotlin/com/lambda/event/events/InventoryEvent.kt b/src/main/kotlin/com/lambda/event/events/InventoryEvent.kt index 788449f79..d8b277457 100644 --- a/src/main/kotlin/com/lambda/event/events/InventoryEvent.kt +++ b/src/main/kotlin/com/lambda/event/events/InventoryEvent.kt @@ -20,7 +20,7 @@ package com.lambda.event.events import com.lambda.event.Event import com.lambda.event.callback.Cancellable import com.lambda.event.callback.ICancellable -import com.lambda.interaction.request.hotbar.HotbarRequest +import com.lambda.interaction.managers.hotbar.HotbarRequest import net.minecraft.item.ItemStack import net.minecraft.screen.ScreenHandler diff --git a/src/main/kotlin/com/lambda/event/events/PlayerPacketEvent.kt b/src/main/kotlin/com/lambda/event/events/PlayerPacketEvent.kt index fea59387d..fc3d5a8a2 100644 --- a/src/main/kotlin/com/lambda/event/events/PlayerPacketEvent.kt +++ b/src/main/kotlin/com/lambda/event/events/PlayerPacketEvent.kt @@ -20,7 +20,7 @@ package com.lambda.event.events import com.lambda.event.Event import com.lambda.event.callback.Cancellable import com.lambda.event.callback.ICancellable -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/lambda/event/events/RotationEvent.kt b/src/main/kotlin/com/lambda/event/events/RotationEvent.kt index 148b37fed..c34d2f600 100644 --- a/src/main/kotlin/com/lambda/event/events/RotationEvent.kt +++ b/src/main/kotlin/com/lambda/event/events/RotationEvent.kt @@ -18,7 +18,7 @@ package com.lambda.event.events import com.lambda.event.Event -import com.lambda.interaction.request.rotating.RotationRequest +import com.lambda.interaction.managers.rotating.RotationRequest import net.minecraft.client.input.Input sealed class RotationEvent { diff --git a/src/main/kotlin/com/lambda/interaction/MovementConfiguration.kt b/src/main/kotlin/com/lambda/interaction/MovementConfiguration.kt deleted file mode 100644 index 3d7442ec1..000000000 --- a/src/main/kotlin/com/lambda/interaction/MovementConfiguration.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction - -import com.lambda.interaction.request.rotating.Rotation -import net.minecraft.util.math.Vec3d - -data class MovementConfiguration( - var position: Vec3d, - var rotation: Rotation, - var onGround: Boolean, - var sprinting: Boolean, - var sneaking: Boolean, -) diff --git a/src/main/kotlin/com/lambda/interaction/PlayerPacketManager.kt b/src/main/kotlin/com/lambda/interaction/PlayerPacketHandler.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/PlayerPacketManager.kt rename to src/main/kotlin/com/lambda/interaction/PlayerPacketHandler.kt index 4c5c9931e..5cda2e509 100644 --- a/src/main/kotlin/com/lambda/interaction/PlayerPacketManager.kt +++ b/src/main/kotlin/com/lambda/interaction/PlayerPacketHandler.kt @@ -21,8 +21,8 @@ import com.lambda.context.SafeContext import com.lambda.event.EventFlow.post import com.lambda.event.EventFlow.postChecked import com.lambda.event.events.PlayerPacketEvent -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationManager +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.threading.runSafe import com.lambda.util.collections.LimitedOrderedSet import com.lambda.util.math.approximate @@ -33,7 +33,7 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.OnGroundOnly import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.PositionAndOnGround import net.minecraft.util.math.Vec3d -object PlayerPacketManager { +object PlayerPacketHandler { val configurations = LimitedOrderedSet(100) var lastPosition: Vec3d = Vec3d.ZERO diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt index f3aabfb47..e37fe716f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt @@ -18,8 +18,8 @@ package com.lambda.interaction.construction.simulation import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.results.PostSimResult +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.results.PostSimResult import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak import com.lambda.interaction.construction.simulation.checks.InteractSim.Companion.simInteraction @@ -39,7 +39,6 @@ object BuildSimulator : Sim() { * will likely not be returned in the same order they were simulated due to the parallel nature of the simulations. * * @see SimInfo.sim - * @see simPostProcessing * @see simInteraction * @see simBreak */ diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt index ccab8eed0..8871e497a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Results.kt @@ -17,8 +17,8 @@ package com.lambda.interaction.construction.simulation -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.results.GenericResult +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.results.GenericResult @SimDsl interface Results { diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt index 5832cecf6..ce74e8d20 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt @@ -17,14 +17,13 @@ package com.lambda.interaction.construction.simulation -import com.lambda.interaction.construction.processing.PreProcessingData -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.CheckedHit -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.getClosestPoints -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.getVisibleSurfaces -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.scanSurfaces +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.results.GenericResult +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.CheckedHit +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.getClosestPoints +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.getVisibleSurfaces +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.scanSurfaces import com.lambda.util.math.distSq import com.lambda.util.math.vec3d import com.lambda.util.world.raycast.RayCastUtils.blockResult @@ -58,7 +57,7 @@ annotation class SimDsl * * @param T The type of [BuildResult] this sim produces. * - * @see com.lambda.interaction.construction.result.Dependent + * @see com.lambda.interaction.construction.simulation.result.Dependent * @see dependentUpon * @see withDependent */ @@ -67,7 +66,7 @@ abstract class Sim : Results { /** * Can be overridden to return a typed Dependent result with the initial [buildResult] nested inside. * - * @see com.lambda.interaction.construction.result.Dependent + * @see com.lambda.interaction.construction.simulation.result.Dependent */ @SimDsl open fun dependentUpon(buildResult: BuildResult): BuildResult = buildResult @@ -91,7 +90,7 @@ abstract class Sim : Results { voxelShape: VoxelShape, pos: BlockPos, sides: Set, - preProcessing: PreProcessingData? + preProcessing: com.lambda.interaction.construction.simulation.processing.PreProcessingData? ): Set? { val boxes = voxelShape.boundingBoxes.map { it.offset(pos) } diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt index 92867db59..c609e84b4 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt @@ -19,9 +19,9 @@ package com.lambda.interaction.construction.simulation import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.processing.PreProcessingData -import com.lambda.interaction.construction.processing.ProcessorRegistry.getProcessingInfo -import com.lambda.interaction.construction.result.BuildResult +import com.lambda.interaction.construction.simulation.processing.PreProcessingData +import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry.getProcessingInfo +import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.checks.BasicChecker.hasBasicRequirements import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak import com.lambda.interaction.construction.simulation.checks.InteractSim.Companion.simInteraction @@ -139,7 +139,7 @@ interface SimInfo : Automated { } interface InteractSimInfo : SimInfo { - val preProcessing: PreProcessingData + val preProcessing: com.lambda.interaction.construction.simulation.processing.PreProcessingData val expectedState: BlockState val item: Item? val placing: Boolean diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt index 4765980b2..98e5f6c4c 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt @@ -21,8 +21,8 @@ import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.graphics.renderer.esp.ShapeBuilder import com.lambda.interaction.construction.blueprint.Blueprint -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Drawable +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Drawable import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt index a714afebe..dc29f88e0 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt @@ -18,11 +18,11 @@ package com.lambda.interaction.construction.simulation.checks import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.PreSimResult import com.lambda.interaction.construction.simulation.Results import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo +import com.lambda.interaction.construction.simulation.result.results.GenericResult +import com.lambda.interaction.construction.simulation.result.results.PreSimResult import com.lambda.util.player.gamemode import com.lambda.util.world.WorldUtils.isLoaded import net.minecraft.block.OperatorBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt index bd983adc3..9008ad720 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt @@ -18,15 +18,15 @@ package com.lambda.interaction.construction.simulation.checks import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.results.BreakResult -import com.lambda.interaction.construction.result.results.GenericResult +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.results.BreakResult +import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.construction.simulation.BreakSimInfo import com.lambda.interaction.construction.simulation.Sim import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim +import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection @@ -34,11 +34,11 @@ import com.lambda.interaction.material.StackSelection.Companion.EVERYTHING import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerManager.containerWithMaterial import com.lambda.interaction.material.container.MaterialContainer -import com.lambda.interaction.request.hotbar.HotbarManager -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.RotationRequest -import com.lambda.interaction.request.rotating.visibilty.lookAt -import com.lambda.interaction.request.rotating.visibilty.lookAtBlock +import com.lambda.interaction.managers.hotbar.HotbarManager +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.RotationRequest +import com.lambda.interaction.managers.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.visibilty.lookAtBlock import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta import com.lambda.util.BlockUtils.instantBreakable diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt index 6b66d5456..968bdb5ef 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt @@ -18,28 +18,28 @@ package com.lambda.interaction.construction.simulation.checks import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.InteractResult import com.lambda.interaction.construction.simulation.InteractSimInfo import com.lambda.interaction.construction.simulation.Sim import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim +import com.lambda.interaction.construction.simulation.context.InteractContext +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.results.GenericResult +import com.lambda.interaction.construction.simulation.result.results.InteractResult import com.lambda.interaction.construction.verify.TargetState +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.RotationRequest +import com.lambda.interaction.managers.rotating.visibilty.PlaceDirection +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.CheckedHit +import com.lambda.interaction.managers.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.visibilty.lookInDirection import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.interaction.material.container.ContainerManager.containerWithMaterial import com.lambda.interaction.material.container.MaterialContainer -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.rotation -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.RotationRequest -import com.lambda.interaction.request.rotating.visibilty.PlaceDirection -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.CheckedHit -import com.lambda.interaction.request.rotating.visibilty.lookAt -import com.lambda.interaction.request.rotating.visibilty.lookInDirection import com.lambda.util.BlockUtils import com.lambda.util.BlockUtils.blockState import com.lambda.util.EntityUtils.getPositionsWithinHitboxXZ diff --git a/src/main/kotlin/com/lambda/interaction/construction/context/BreakContext.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BreakContext.kt similarity index 89% rename from src/main/kotlin/com/lambda/interaction/construction/context/BreakContext.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/context/BreakContext.kt index e681f9c39..e4a40a9f7 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/context/BreakContext.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BreakContext.kt @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.context +package com.lambda.interaction.construction.simulation.context import com.lambda.context.Automated import com.lambda.graphics.renderer.esp.ShapeBuilder import com.lambda.interaction.material.StackSelection -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.LogContext.Companion.getLogContextBuilder -import com.lambda.interaction.request.rotating.RotationRequest +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.LogContext.Companion.getLogContextBuilder +import com.lambda.interaction.managers.rotating.RotationRequest import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.emptyState import net.minecraft.block.BlockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/context/BuildContext.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt similarity index 88% rename from src/main/kotlin/com/lambda/interaction/construction/context/BuildContext.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt index 3941507f3..6cdfeee62 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/context/BuildContext.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.context +package com.lambda.interaction.construction.simulation.context import com.lambda.config.groups.ActionConfig import com.lambda.context.Automated -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.request.rotating.RotationRequest +import com.lambda.interaction.construction.simulation.result.Drawable +import com.lambda.interaction.managers.rotating.RotationRequest import com.lambda.threading.runSafe import net.minecraft.block.BlockState import net.minecraft.util.hit.BlockHitResult diff --git a/src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/InteractContext.kt similarity index 84% rename from src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/context/InteractContext.kt index 5b3aabc0b..0ccc754e6 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/InteractContext.kt @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.context +package com.lambda.interaction.construction.simulation.context import com.lambda.context.Automated import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.LogContext.Companion.getLogContextBuilder -import com.lambda.interaction.request.Request.Companion.submit -import com.lambda.interaction.request.hotbar.HotbarRequest -import com.lambda.interaction.request.interacting.InteractRequest -import com.lambda.interaction.request.rotating.RotationRequest +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.LogContext.Companion.getLogContextBuilder +import com.lambda.interaction.managers.Request.Companion.submit +import com.lambda.interaction.managers.hotbar.HotbarRequest +import com.lambda.interaction.managers.interacting.InteractRequest +import com.lambda.interaction.managers.rotating.RotationRequest import net.minecraft.block.BlockState import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/PlacementProcessor.kt similarity index 72% rename from src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/PlacementProcessor.kt index b4b23e453..b07587e3a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/PlacementProcessor.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing +package com.lambda.interaction.construction.simulation.processing import com.lambda.context.SafeContext import net.minecraft.block.BlockState @@ -30,15 +30,15 @@ import net.minecraft.util.math.BlockPos interface StateProcessor { fun acceptsState(state: BlockState, targetState: BlockState): Boolean context(safeContext: SafeContext) - fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) + fun com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos) } interface PropertyPreProcessor { fun acceptsState(targetState: BlockState): Boolean - fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) + fun com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) } interface PropertyPostProcessor { fun acceptsState(state: BlockState, targetState: BlockState): Boolean - fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) + fun com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/PreProcessingInfo.kt similarity index 87% rename from src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/PreProcessingInfo.kt index 37fc2f062..4a49894db 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/PreProcessingInfo.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing +package com.lambda.interaction.construction.simulation.processing import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.construction.verify.SurfaceScan @@ -53,12 +53,12 @@ class PreProcessingInfoAccumulator( override var expectedState: BlockState, override var item: Item?, override var surfaceScan: SurfaceScan = SurfaceScan.DEFAULT, - override val ignore: MutableSet> = ProcessorRegistry.postProcessedProperties.toMutableSet(), + override val ignore: MutableSet> = _root_ide_package_.com.lambda.interaction.construction.simulation.processing.ProcessorRegistry.postProcessedProperties.toMutableSet(), override val sides: MutableSet = Direction.entries.toMutableSet(), override var placing: Boolean = true, override var noCaching: Boolean = false, var omitPlacement: Boolean = false -) : PreProcessingInfo { +) : com.lambda.interaction.construction.simulation.processing.PreProcessingInfo { @InfoAccumulator fun offerSurfaceScan(scan: SurfaceScan) { if (scan.mode.priority > surfaceScan.mode.priority) { @@ -110,7 +110,7 @@ class PreProcessingInfoAccumulator( } @InfoAccumulator - fun complete(): PreProcessingInfo = this + fun complete(): com.lambda.interaction.construction.simulation.processing.PreProcessingInfo = this companion object { @DslMarker diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt similarity index 92% rename from src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt index 2b856f3fa..d5397a917 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/ProcessorRegistry.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing +package com.lambda.interaction.construction.simulation.processing import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.core.Loadable -import com.lambda.interaction.construction.processing.PreProcessingInfo.Companion.default +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfo.Companion.default import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.verify.TargetState import com.lambda.util.reflections.getInstances @@ -31,9 +31,9 @@ import net.minecraft.util.math.BlockPos import java.util.* object ProcessorRegistry : Loadable{ - private val stateProcessors = getInstances() - private val propertyPreProcessors = getInstances() - private val propertyPostProcessors = getInstances() + private val stateProcessors = getInstances() + private val propertyPreProcessors = getInstances() + private val propertyPostProcessors = getInstances() private val processorCache = Collections.synchronizedMap, PreProcessingInfo?>(mutableMapOf()) /** diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt similarity index 73% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt index 6510755bf..9c134f9a3 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPreProcessor.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.post +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.post -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.ProcessorRegistry.standardInteractProperties -import com.lambda.interaction.construction.processing.PropertyPostProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry.standardInteractProperties +import com.lambda.interaction.construction.simulation.processing.PropertyPostProcessor import net.minecraft.block.BlockState object StandardInteractPreProcessor : PropertyPostProcessor { diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt similarity index 84% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt index 64d0b0e63..6a399c562 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.block.enums.Attachment import net.minecraft.state.property.Properties diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt similarity index 81% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt index 8564b46e4..11aff0c2a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.state.property.Properties diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt similarity index 84% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt index 59117c858..aecbd5820 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.block.enums.BlockFace import net.minecraft.state.property.Properties diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt similarity index 85% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt index 2bac9c78a..41153b10d 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan import net.minecraft.block.BlockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt similarity index 88% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt index 6f41d2e39..eaa037bb8 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan import net.minecraft.block.BlockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt similarity index 83% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt index eb091d8ba..87b43486f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import net.minecraft.block.BlockState import net.minecraft.state.property.Properties import net.minecraft.util.math.Direction diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt similarity index 88% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt index d826afb2f..08300790d 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.property.placement.pre +package com.lambda.interaction.construction.simulation.processing.preprocessors.property.placement.pre -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.PropertyPreProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.PropertyPreProcessor import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan import net.minecraft.block.BlockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooPreProcessor.kt similarity index 86% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooPreProcessor.kt index 602181080..a15db85e3 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/BambooPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooPreProcessor.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.state +package com.lambda.interaction.construction.simulation.processing.preprocessors.state import com.lambda.context.SafeContext -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.StateProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.StateProcessor import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.item import net.minecraft.block.BlockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FirePreProcessor.kt similarity index 83% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FirePreProcessor.kt index ea16ecfa6..738f8c969 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FirePreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FirePreProcessor.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.state +package com.lambda.interaction.construction.simulation.processing.preprocessors.state import com.lambda.context.SafeContext -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.StateProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.StateProcessor import net.minecraft.block.BlockState import net.minecraft.block.Blocks import net.minecraft.item.Items diff --git a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotPreProcessor.kt similarity index 85% rename from src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotPreProcessor.kt index 31775feca..425453ea7 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/processing/preprocessors/state/FlowerPotPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotPreProcessor.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.processing.preprocessors.state +package com.lambda.interaction.construction.simulation.processing.preprocessors.state import com.lambda.context.SafeContext -import com.lambda.interaction.construction.processing.PreProcessingInfoAccumulator -import com.lambda.interaction.construction.processing.StateProcessor +import com.lambda.interaction.construction.simulation.processing.PreProcessingInfoAccumulator +import com.lambda.interaction.construction.simulation.processing.StateProcessor import net.minecraft.block.BlockState import net.minecraft.block.Blocks import net.minecraft.block.FlowerPotBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/BuildResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/BuildResult.kt similarity index 94% rename from src/main/kotlin/com/lambda/interaction/construction/result/BuildResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/BuildResult.kt index 7f1158d68..d80db6bcd 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/BuildResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/BuildResult.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result import com.lambda.util.Nameable import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/ComparableResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/ComparableResult.kt similarity index 94% rename from src/main/kotlin/com/lambda/interaction/construction/result/ComparableResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/ComparableResult.kt index efd8c1c49..a9d06b97f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/ComparableResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/ComparableResult.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result interface ComparableResult> : Comparable> { val rank: T diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt similarity index 87% rename from src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt index a4dcc1152..4f2eb78a3 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Contextual.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result import com.lambda.config.groups.ActionConfig -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.request.hotbar.HotbarManager +import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.construction.simulation.context.InteractContext +import com.lambda.interaction.managers.hotbar.HotbarManager import com.lambda.threading.runSafe import com.lambda.util.BlockUtils diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Dependent.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Dependent.kt similarity index 94% rename from src/main/kotlin/com/lambda/interaction/construction/result/Dependent.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/Dependent.kt index 3d61ac5b2..9c7aede93 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Dependent.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Dependent.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result /** * Represents a [BuildResult] that depends on another [BuildResult]. diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Drawable.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/construction/result/Drawable.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt index ba9e05615..cd51bd728 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Drawable.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result import com.lambda.graphics.renderer.esp.ShapeBuilder diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Navigable.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/construction/result/Navigable.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt index fc5483c2c..99c05b7ce 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Navigable.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result import baritone.api.pathing.goals.Goal diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Rank.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Rank.kt similarity index 95% rename from src/main/kotlin/com/lambda/interaction/construction/result/Rank.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/Rank.kt index c199cf41b..6ff670fb5 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Rank.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Rank.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result enum class Rank { // solvable diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/Resolvable.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Resolvable.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/construction/result/Resolvable.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/Resolvable.kt index bbf96023c..364762d48 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/Resolvable.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Resolvable.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result +package com.lambda.interaction.construction.simulation.result import com.lambda.context.Automated import com.lambda.task.Task diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/BreakResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt similarity index 89% rename from src/main/kotlin/com/lambda/interaction/construction/result/results/BreakResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt index 155da3c7a..3c624816c 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/BreakResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt @@ -15,22 +15,22 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result.results +package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalBlock import baritone.api.pathing.goals.GoalInverted import com.lambda.context.Automated import com.lambda.graphics.renderer.esp.DirectionMask.mask import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.ComparableResult -import com.lambda.interaction.construction.result.Contextual -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.construction.result.Navigable -import com.lambda.interaction.construction.result.Rank -import com.lambda.interaction.construction.result.Resolvable +import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.ComparableResult +import com.lambda.interaction.construction.simulation.result.Contextual +import com.lambda.interaction.construction.simulation.result.Dependent +import com.lambda.interaction.construction.simulation.result.Drawable +import com.lambda.interaction.construction.simulation.result.Navigable +import com.lambda.interaction.construction.simulation.result.Rank +import com.lambda.interaction.construction.simulation.result.Resolvable import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerManager.transfer import com.lambda.interaction.material.container.MaterialContainer diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/GenericResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt similarity index 91% rename from src/main/kotlin/com/lambda/interaction/construction/result/results/GenericResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt index f9f36b66a..31935ad4a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/GenericResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result.results +package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalNear import com.lambda.context.Automated import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.ComparableResult -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.construction.result.Navigable -import com.lambda.interaction.construction.result.Rank -import com.lambda.interaction.construction.result.Resolvable +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.ComparableResult +import com.lambda.interaction.construction.simulation.result.Drawable +import com.lambda.interaction.construction.simulation.result.Navigable +import com.lambda.interaction.construction.simulation.result.Rank +import com.lambda.interaction.construction.simulation.result.Resolvable import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.container.ContainerManager.transfer import com.lambda.interaction.material.container.MaterialContainer diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt similarity index 91% rename from src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt index cff5a7254..653fa75ff 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/InteractResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt @@ -15,18 +15,18 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result.results +package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalBlock import baritone.api.pathing.goals.GoalInverted import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Contextual -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.construction.result.Navigable -import com.lambda.interaction.construction.result.Rank +import com.lambda.interaction.construction.simulation.context.InteractContext +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Contextual +import com.lambda.interaction.construction.simulation.result.Dependent +import com.lambda.interaction.construction.simulation.result.Drawable +import com.lambda.interaction.construction.simulation.result.Navigable +import com.lambda.interaction.construction.simulation.result.Rank import net.minecraft.block.BlockState import net.minecraft.entity.Entity import net.minecraft.item.ItemPlacementContext @@ -42,7 +42,7 @@ import java.awt.Color * Holds data about the placement and the result of the simulation. * Every [GenericResult] can [resolve] its own problem. * Every [GenericResult] can be compared to another [GenericResult]. - * First based on the context, then based on the [com.lambda.interaction.construction.result.Rank]. + * First based on the context, then based on the [Rank]. */ sealed class InteractResult : BuildResult() { override val name: String get() = "${this::class.simpleName} at ${pos.toShortString()}" diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/PostSimResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PostSimResult.kt similarity index 83% rename from src/main/kotlin/com/lambda/interaction/construction/result/results/PostSimResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PostSimResult.kt index c607af354..36f6ca781 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/PostSimResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PostSimResult.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result.results +package com.lambda.interaction.construction.simulation.result.results -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Rank +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Rank import net.minecraft.util.math.BlockPos sealed class PostSimResult : BuildResult() { diff --git a/src/main/kotlin/com/lambda/interaction/construction/result/results/PreSimResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt similarity index 91% rename from src/main/kotlin/com/lambda/interaction/construction/result/results/PreSimResult.kt rename to src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt index 29d72968e..c92bda7b1 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/result/results/PreSimResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -package com.lambda.interaction.construction.result.results +package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalBlock import com.lambda.graphics.renderer.esp.ShapeBuilder -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.ComparableResult -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.construction.result.Navigable -import com.lambda.interaction.construction.result.Rank +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.ComparableResult +import com.lambda.interaction.construction.simulation.result.Drawable +import com.lambda.interaction.construction.simulation.result.Navigable +import com.lambda.interaction.construction.simulation.result.Rank import net.minecraft.block.BlockState import net.minecraft.util.math.BlockPos import java.awt.Color diff --git a/src/main/kotlin/com/lambda/interaction/request/ActionInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/ActionInfo.kt similarity index 89% rename from src/main/kotlin/com/lambda/interaction/request/ActionInfo.kt rename to src/main/kotlin/com/lambda/interaction/managers/ActionInfo.kt index 4eb5b43ac..2d54656ad 100644 --- a/src/main/kotlin/com/lambda/interaction/request/ActionInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/ActionInfo.kt @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers -import com.lambda.interaction.construction.context.BuildContext +import com.lambda.interaction.construction.simulation.context.BuildContext /** * A simple interface to provide a basic object to hold key information that managers might need if information diff --git a/src/main/kotlin/com/lambda/interaction/request/DebugLogger.kt b/src/main/kotlin/com/lambda/interaction/managers/DebugLogger.kt similarity index 98% rename from src/main/kotlin/com/lambda/interaction/request/DebugLogger.kt rename to src/main/kotlin/com/lambda/interaction/managers/DebugLogger.kt index 77b15015d..0e6f85b67 100644 --- a/src/main/kotlin/com/lambda/interaction/request/DebugLogger.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/DebugLogger.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import com.lambda.gui.components.ClickGuiLayout import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.interaction.request.LogContext.Companion.buildLogContext +import com.lambda.interaction.managers.LogContext.Companion.buildLogContext import com.lambda.module.hud.ManagerDebugLoggers.autoScroll import com.lambda.module.hud.ManagerDebugLoggers.maxLogEntries import com.lambda.module.hud.ManagerDebugLoggers.showDebug diff --git a/src/main/kotlin/com/lambda/interaction/request/LogContext.kt b/src/main/kotlin/com/lambda/interaction/managers/LogContext.kt similarity index 98% rename from src/main/kotlin/com/lambda/interaction/request/LogContext.kt rename to src/main/kotlin/com/lambda/interaction/managers/LogContext.kt index 45106aa6b..a2df2d272 100644 --- a/src/main/kotlin/com/lambda/interaction/request/LogContext.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/LogContext.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/interaction/request/Logger.kt b/src/main/kotlin/com/lambda/interaction/managers/Logger.kt similarity index 94% rename from src/main/kotlin/com/lambda/interaction/request/Logger.kt rename to src/main/kotlin/com/lambda/interaction/managers/Logger.kt index 768595363..4f46c29f2 100644 --- a/src/main/kotlin/com/lambda/interaction/request/Logger.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/Logger.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers interface Logger { val logger: DebugLogger diff --git a/src/main/kotlin/com/lambda/interaction/request/RequestHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/Manager.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/request/RequestHandler.kt rename to src/main/kotlin/com/lambda/interaction/managers/Manager.kt index ff188b8cc..bdc46364b 100644 --- a/src/main/kotlin/com/lambda/interaction/request/RequestHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/Manager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext @@ -25,7 +25,7 @@ import com.lambda.event.Event import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.ManagerUtils.accumulatedManagerPriority +import com.lambda.interaction.managers.ManagerUtils.accumulatedManagerPriority import com.lambda.threading.runSafeAutomated import kotlin.reflect.KClass @@ -33,7 +33,7 @@ import kotlin.reflect.KClass * This class handles requests, offering specific opening times, and an option to queue a request for the * next opening if closed */ -abstract class RequestHandler( +abstract class Manager( val stagePriority: Int, vararg val blacklistedStages: TickEvent, private val onOpen: (SafeContext.() -> Unit)? = null, diff --git a/src/main/kotlin/com/lambda/interaction/request/ManagerUtils.kt b/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/request/ManagerUtils.kt rename to src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt index a6c4d3fea..ef21c2a4b 100644 --- a/src/main/kotlin/com/lambda/interaction/request/ManagerUtils.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import com.lambda.event.Event import com.lambda.util.reflections.getInstances import net.minecraft.util.math.BlockPos object ManagerUtils { - val managers = getInstances>() + val managers = getInstances>() val accumulatedManagerPriority = managers.map { it.stagePriority }.reduce { acc, priority -> acc + priority } val positionBlockingManagers = getInstances() diff --git a/src/main/kotlin/com/lambda/interaction/request/PositionBlocking.kt b/src/main/kotlin/com/lambda/interaction/managers/PositionBlocking.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/request/PositionBlocking.kt rename to src/main/kotlin/com/lambda/interaction/managers/PositionBlocking.kt index 5086495a1..3f56d978e 100644 --- a/src/main/kotlin/com/lambda/interaction/request/PositionBlocking.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/PositionBlocking.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/interaction/request/PostActionHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/PostActionHandler.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/request/PostActionHandler.kt rename to src/main/kotlin/com/lambda/interaction/managers/PostActionHandler.kt index 5c4a8ee75..db2eac0af 100644 --- a/src/main/kotlin/com/lambda/interaction/request/PostActionHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/PostActionHandler.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import com.lambda.context.Automated import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe -import com.lambda.interaction.request.breaking.BrokenBlockHandler +import com.lambda.interaction.managers.breaking.BrokenBlockHandler import com.lambda.util.collections.LimitedDecayQueue /** @@ -53,6 +53,6 @@ abstract class PostActionHandler { fun Automated.setPendingConfigs() { BrokenBlockHandler.pendingActions.setSizeLimit(breakConfig.maxPendingBreaks) - BrokenBlockHandler.pendingActions.setDecayTime(buildConfig.interactionTimeout * 50L) + BrokenBlockHandler.pendingActions.setDecayTime(buildConfig.actionTimeout * 50L) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/request/Request.kt b/src/main/kotlin/com/lambda/interaction/managers/Request.kt similarity index 97% rename from src/main/kotlin/com/lambda/interaction/request/Request.kt rename to src/main/kotlin/com/lambda/interaction/managers/Request.kt index a010af841..731ba6ac0 100644 --- a/src/main/kotlin/com/lambda/interaction/request/Request.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/Request.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request +package com.lambda.interaction.managers import com.lambda.context.Automated import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt similarity index 99% rename from src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt index 4ad56a376..be181f70f 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.config.ISettingGroup import com.lambda.config.groups.ActionConfig diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt similarity index 90% rename from src/main/kotlin/com/lambda/interaction/request/breaking/BreakInfo.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt index 95d93c4e6..0c216040b 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt @@ -15,18 +15,18 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.context.SafeContext -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.request.ActionInfo -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.RedundantSecondary -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Secondary -import com.lambda.interaction.request.breaking.BreakManager.calcBreakDelta +import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.managers.ActionInfo +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Rebreak +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.RedundantSecondary +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Secondary +import com.lambda.interaction.managers.breaking.BreakManager.calcBreakDelta import com.lambda.threading.runSafeAutomated import com.lambda.util.Describable import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt similarity index 91% rename from src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index 4c128e397..e5cf7e20e 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext @@ -31,51 +31,51 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.renderer.esp.DynamicAABB import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.construction.result.results.BreakResult +import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate +import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.select -import com.lambda.interaction.request.Logger -import com.lambda.interaction.request.ManagerUtils.isPosBlocked -import com.lambda.interaction.request.ManagerUtils.newStage -import com.lambda.interaction.request.ManagerUtils.newTick -import com.lambda.interaction.request.PositionBlocking -import com.lambda.interaction.request.RequestHandler -import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode -import com.lambda.interaction.request.breaking.BreakConfig.BreakMode -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Rebreak -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.RedundantSecondary -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Secondary -import com.lambda.interaction.request.breaking.BreakManager.abandonedBreak -import com.lambda.interaction.request.breaking.BreakManager.activeInfos -import com.lambda.interaction.request.breaking.BreakManager.activeRequest -import com.lambda.interaction.request.breaking.BreakManager.breakInfos -import com.lambda.interaction.request.breaking.BreakManager.breaks -import com.lambda.interaction.request.breaking.BreakManager.canAccept -import com.lambda.interaction.request.breaking.BreakManager.checkForCancels -import com.lambda.interaction.request.breaking.BreakManager.handlePreProcessing -import com.lambda.interaction.request.breaking.BreakManager.hotbarRequest -import com.lambda.interaction.request.breaking.BreakManager.initNewBreak -import com.lambda.interaction.request.breaking.BreakManager.maxBreaksThisTick -import com.lambda.interaction.request.breaking.BreakManager.nullify -import com.lambda.interaction.request.breaking.BreakManager.populateFrom -import com.lambda.interaction.request.breaking.BreakManager.processNewBreak -import com.lambda.interaction.request.breaking.BreakManager.processRequest -import com.lambda.interaction.request.breaking.BreakManager.rotationRequest -import com.lambda.interaction.request.breaking.BreakManager.simulateAbandoned -import com.lambda.interaction.request.breaking.BreakManager.updateBreakProgress -import com.lambda.interaction.request.breaking.BreakManager.updatePreProcessing -import com.lambda.interaction.request.breaking.BrokenBlockHandler.destroyBlock -import com.lambda.interaction.request.breaking.BrokenBlockHandler.pendingActions -import com.lambda.interaction.request.breaking.BrokenBlockHandler.setPendingConfigs -import com.lambda.interaction.request.breaking.BrokenBlockHandler.startPending -import com.lambda.interaction.request.breaking.RebreakHandler.getRebreakPotential -import com.lambda.interaction.request.breaking.SwapInfo.Companion.getSwapInfo -import com.lambda.interaction.request.hotbar.HotbarRequest -import com.lambda.interaction.request.rotating.RotationRequest +import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.ManagerUtils.isPosBlocked +import com.lambda.interaction.managers.ManagerUtils.newStage +import com.lambda.interaction.managers.ManagerUtils.newTick +import com.lambda.interaction.managers.PositionBlocking +import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode +import com.lambda.interaction.managers.breaking.BreakConfig.BreakMode +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Rebreak +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.RedundantSecondary +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Secondary +import com.lambda.interaction.managers.breaking.BreakManager.abandonedBreak +import com.lambda.interaction.managers.breaking.BreakManager.activeInfos +import com.lambda.interaction.managers.breaking.BreakManager.activeRequest +import com.lambda.interaction.managers.breaking.BreakManager.breakInfos +import com.lambda.interaction.managers.breaking.BreakManager.breaks +import com.lambda.interaction.managers.breaking.BreakManager.canAccept +import com.lambda.interaction.managers.breaking.BreakManager.checkForCancels +import com.lambda.interaction.managers.breaking.BreakManager.handlePreProcessing +import com.lambda.interaction.managers.breaking.BreakManager.hotbarRequest +import com.lambda.interaction.managers.breaking.BreakManager.initNewBreak +import com.lambda.interaction.managers.breaking.BreakManager.maxBreaksThisTick +import com.lambda.interaction.managers.breaking.BreakManager.nullify +import com.lambda.interaction.managers.breaking.BreakManager.populateFrom +import com.lambda.interaction.managers.breaking.BreakManager.processNewBreak +import com.lambda.interaction.managers.breaking.BreakManager.processRequest +import com.lambda.interaction.managers.breaking.BreakManager.rotationRequest +import com.lambda.interaction.managers.breaking.BreakManager.simulateAbandoned +import com.lambda.interaction.managers.breaking.BreakManager.updateBreakProgress +import com.lambda.interaction.managers.breaking.BreakManager.updatePreProcessing +import com.lambda.interaction.managers.breaking.BrokenBlockHandler.destroyBlock +import com.lambda.interaction.managers.breaking.BrokenBlockHandler.pendingActions +import com.lambda.interaction.managers.breaking.BrokenBlockHandler.setPendingConfigs +import com.lambda.interaction.managers.breaking.BrokenBlockHandler.startPending +import com.lambda.interaction.managers.breaking.RebreakHandler.getRebreakPotential +import com.lambda.interaction.managers.breaking.SwapInfo.Companion.getSwapInfo +import com.lambda.interaction.managers.hotbar.HotbarRequest +import com.lambda.interaction.managers.rotating.RotationRequest import com.lambda.module.hud.ManagerDebugLoggers.breakManagerLogger import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState @@ -108,7 +108,7 @@ import kotlin.math.min * different requests. Each break will be handled using its own config, and just like the other managers, priority is a first-come, first-served * style system. */ -object BreakManager : RequestHandler( +object BreakManager : Manager( 0, onOpen = { if (activeInfos.isNotEmpty() || breaks.isNotEmpty()) @@ -413,7 +413,7 @@ object BreakManager : RequestHandler( .take( min( breakConfig.maxPendingBreaks - pendingBreakCount, - buildConfig.maxPendingInteractions - request.pendingInteractions.size + buildConfig.maxPendingActions - request.pendingInteractions.size ).coerceAtLeast(0) ) .toMutableList() diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt similarity index 90% rename from src/main/kotlin/com/lambda/interaction/request/breaking/BreakRequest.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt index 2290813fe..a65f18671 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BreakRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt @@ -15,22 +15,22 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.results.BreakResult +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Dependent +import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate +import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.Request -import com.lambda.interaction.request.breaking.BreakRequest.Companion.breakRequest +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.Request +import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/BrokenBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt similarity index 92% rename from src/main/kotlin/com/lambda/interaction/request/breaking/BrokenBlockHandler.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt index da3716135..8cabe0594 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/BrokenBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt @@ -15,19 +15,19 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.config.AutomationConfig.Companion.DEFAULT import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.processing.ProcessorRegistry -import com.lambda.interaction.request.PostActionHandler -import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode -import com.lambda.interaction.request.breaking.BreakManager.lastPosStarted -import com.lambda.interaction.request.breaking.BreakManager.matchesBlockItem -import com.lambda.interaction.request.breaking.RebreakHandler.rebreak +import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry +import com.lambda.interaction.managers.PostActionHandler +import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode +import com.lambda.interaction.managers.breaking.BreakManager.lastPosStarted +import com.lambda.interaction.managers.breaking.BreakManager.matchesBlockItem +import com.lambda.interaction.managers.breaking.RebreakHandler.rebreak import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.emptyState import com.lambda.util.BlockUtils.fluidState @@ -49,7 +49,7 @@ import net.minecraft.util.math.ChunkSectionPos */ object BrokenBlockHandler : PostActionHandler() { override val pendingActions = LimitedDecayQueue( - DEFAULT.buildConfig.maxPendingInteractions, DEFAULT.buildConfig.interactionTimeout * 50L + DEFAULT.buildConfig.maxPendingActions, DEFAULT.buildConfig.actionTimeout * 50L ) { info -> runSafe { val pos = info.context.blockPos diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/RebreakHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/request/breaking/RebreakHandler.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt index ccec4316e..17bd3366d 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/RebreakHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.request.breaking.BreakManager.calcBreakDelta -import com.lambda.interaction.request.breaking.BrokenBlockHandler.destroyBlock -import com.lambda.interaction.request.breaking.RebreakHandler.rebreak +import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.managers.breaking.BreakManager.calcBreakDelta +import com.lambda.interaction.managers.breaking.BrokenBlockHandler.destroyBlock +import com.lambda.interaction.managers.breaking.RebreakHandler.rebreak import com.lambda.threading.runSafeAutomated import com.lambda.util.player.swingHand import net.minecraft.util.Hand diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/RebreakResult.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakResult.kt similarity index 94% rename from src/main/kotlin/com/lambda/interaction/request/breaking/RebreakResult.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakResult.kt index 7e1a00522..2b4c1c05b 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/RebreakResult.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakResult.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking sealed class RebreakResult { data object Ignored : RebreakResult() diff --git a/src/main/kotlin/com/lambda/interaction/request/breaking/SwapInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt similarity index 88% rename from src/main/kotlin/com/lambda/interaction/request/breaking/SwapInfo.kt rename to src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt index 5e76c303e..89bb61e16 100644 --- a/src/main/kotlin/com/lambda/interaction/request/breaking/SwapInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt @@ -15,16 +15,16 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.breaking +package com.lambda.interaction.managers.breaking import com.lambda.context.Automated import com.lambda.config.AutomationConfig.Companion.DEFAULT import com.lambda.context.SafeContext -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Primary -import com.lambda.interaction.request.breaking.BreakInfo.BreakType.Secondary -import com.lambda.interaction.request.breaking.BreakManager.calcBreakDelta +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary +import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Secondary +import com.lambda.interaction.managers.breaking.BreakManager.calcBreakDelta import com.lambda.threading.runSafeAutomated /** diff --git a/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarConfig.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarConfig.kt rename to src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarConfig.kt index 3043d6017..b54e0e3bd 100644 --- a/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.hotbar +package com.lambda.interaction.managers.hotbar import com.lambda.config.ISettingGroup import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt similarity index 90% rename from src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarManager.kt rename to src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index e93d59fee..6edec2ab9 100644 --- a/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.hotbar +package com.lambda.interaction.managers.hotbar import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext @@ -24,15 +24,15 @@ import com.lambda.event.EventFlow.post import com.lambda.event.events.TickEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.Logger -import com.lambda.interaction.request.ManagerUtils.newStage -import com.lambda.interaction.request.ManagerUtils.newTick -import com.lambda.interaction.request.RequestHandler -import com.lambda.interaction.request.hotbar.HotbarManager.activeRequest -import com.lambda.interaction.request.hotbar.HotbarManager.activeSlot -import com.lambda.interaction.request.hotbar.HotbarManager.checkResetSwap -import com.lambda.interaction.request.hotbar.HotbarManager.setActiveRequest -import com.lambda.interaction.request.hotbar.HotbarManager.setActiveSlot +import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.ManagerUtils.newStage +import com.lambda.interaction.managers.ManagerUtils.newTick +import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.hotbar.HotbarManager.activeRequest +import com.lambda.interaction.managers.hotbar.HotbarManager.activeSlot +import com.lambda.interaction.managers.hotbar.HotbarManager.checkResetSwap +import com.lambda.interaction.managers.hotbar.HotbarManager.setActiveRequest +import com.lambda.interaction.managers.hotbar.HotbarManager.setActiveSlot import com.lambda.module.hud.ManagerDebugLoggers.hotbarManagerLogger import com.lambda.threading.runSafe import net.minecraft.item.ItemStack @@ -45,7 +45,7 @@ import net.minecraft.item.ItemStack * set to 0, assuming the request is accepted, the manager will only swap for the duration of the current [tickStage]. * After which, the manager will end the request and swap back to the player's selected slot. */ -object HotbarManager : RequestHandler( +object HotbarManager : Manager( 1, onOpen = { if (activeRequest != null) { diff --git a/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarRequest.kt similarity index 89% rename from src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarRequest.kt rename to src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarRequest.kt index 9d2df9eca..2c23715bb 100644 --- a/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarRequest.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.hotbar +package com.lambda.interaction.managers.hotbar import com.lambda.context.Automated -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.Request +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.Request class HotbarRequest( val slot: Int, diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt rename to src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt index 2dfc3133f..63999d6ec 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.interacting +package com.lambda.interaction.managers.interacting import com.lambda.config.ISettingGroup import com.lambda.config.groups.ActionConfig diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt similarity index 76% rename from src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt rename to src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt index 7ddbede43..e9826d895 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.interacting +package com.lambda.interaction.managers.interacting import com.lambda.context.SafeContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.request.ActionInfo -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.construction.simulation.context.InteractContext +import com.lambda.interaction.managers.ActionInfo +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder import net.minecraft.util.math.BlockPos data class InteractInfo( diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt similarity index 91% rename from src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt rename to src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt index 96a9801eb..8a1dab083 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.interacting +package com.lambda.interaction.managers.interacting import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext @@ -26,23 +26,23 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.events.TickEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.request.Logger -import com.lambda.interaction.request.ManagerUtils.isPosBlocked -import com.lambda.interaction.request.ManagerUtils.newStage -import com.lambda.interaction.request.ManagerUtils.newTick -import com.lambda.interaction.request.PositionBlocking -import com.lambda.interaction.request.RequestHandler -import com.lambda.interaction.request.breaking.BreakManager -import com.lambda.interaction.request.interacting.InteractManager.activeRequest -import com.lambda.interaction.request.interacting.InteractManager.maxPlacementsThisTick -import com.lambda.interaction.request.interacting.InteractManager.populateFrom -import com.lambda.interaction.request.interacting.InteractManager.potentialPlacements -import com.lambda.interaction.request.interacting.InteractManager.processRequest -import com.lambda.interaction.request.interacting.InteractedBlockHandler.pendingActions -import com.lambda.interaction.request.interacting.InteractedBlockHandler.setPendingConfigs -import com.lambda.interaction.request.interacting.InteractedBlockHandler.startPending -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest +import com.lambda.interaction.construction.simulation.context.InteractContext +import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.ManagerUtils.isPosBlocked +import com.lambda.interaction.managers.ManagerUtils.newStage +import com.lambda.interaction.managers.ManagerUtils.newTick +import com.lambda.interaction.managers.PositionBlocking +import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.breaking.BreakManager +import com.lambda.interaction.managers.interacting.InteractManager.activeRequest +import com.lambda.interaction.managers.interacting.InteractManager.maxPlacementsThisTick +import com.lambda.interaction.managers.interacting.InteractManager.populateFrom +import com.lambda.interaction.managers.interacting.InteractManager.potentialPlacements +import com.lambda.interaction.managers.interacting.InteractManager.processRequest +import com.lambda.interaction.managers.interacting.InteractedBlockHandler.pendingActions +import com.lambda.interaction.managers.interacting.InteractedBlockHandler.setPendingConfigs +import com.lambda.interaction.managers.interacting.InteractedBlockHandler.startPending +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.module.hud.ManagerDebugLoggers.placeManagerLogger import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState @@ -68,7 +68,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.world.GameMode import kotlin.math.min -object InteractManager : RequestHandler( +object InteractManager : Manager( 0, onOpen = { if (potentialPlacements.isNotEmpty()) @@ -201,7 +201,7 @@ object InteractManager : RequestHandler( .take( min( interactConfig.maxPendingInteractions - pendingActions.size, - buildConfig.maxPendingInteractions - request.pendingInteractions.size + buildConfig.maxPendingActions - request.pendingInteractions.size ).coerceAtLeast(0) ) .toMutableList() diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt similarity index 84% rename from src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt rename to src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt index 67f08626f..292e9584c 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt @@ -15,18 +15,18 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.interacting +package com.lambda.interaction.managers.interacting import com.lambda.context.Automated import com.lambda.context.SafeContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.context.InteractContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.results.InteractResult -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.Request +import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.construction.simulation.context.InteractContext +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Dependent +import com.lambda.interaction.construction.simulation.result.results.InteractResult +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.Request import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.matches diff --git a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt similarity index 88% rename from src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt rename to src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt index 3d11e59fa..14bc59022 100644 --- a/src/main/kotlin/com/lambda/interaction/request/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.interacting +package com.lambda.interaction.managers.interacting import com.lambda.config.AutomationConfig.Companion.DEFAULT import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.processing.ProcessorRegistry -import com.lambda.interaction.request.PostActionHandler -import com.lambda.interaction.request.interacting.InteractManager.placeSound +import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry +import com.lambda.interaction.managers.PostActionHandler +import com.lambda.interaction.managers.interacting.InteractManager.placeSound import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.matches import com.lambda.util.Communication.info @@ -31,8 +31,8 @@ import com.lambda.util.collections.LimitedDecayQueue object InteractedBlockHandler : PostActionHandler() { override val pendingActions = LimitedDecayQueue( - DEFAULT.buildConfig.maxPendingInteractions, - DEFAULT.buildConfig.interactionTimeout * 50L + DEFAULT.buildConfig.maxPendingActions, + DEFAULT.buildConfig.actionTimeout * 50L ) { info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out") if (it.interactConfig.interactConfirmationMode != InteractConfig.PlaceConfirmationMode.AwaitThenPlace) { diff --git a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryAction.kt b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryAction.kt similarity index 95% rename from src/main/kotlin/com/lambda/interaction/request/inventory/InventoryAction.kt rename to src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryAction.kt index db527337e..302f5cb83 100644 --- a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryAction.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryAction.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.inventory +package com.lambda.interaction.managers.inventory import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryConfig.kt b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryConfig.kt similarity index 98% rename from src/main/kotlin/com/lambda/interaction/request/inventory/InventoryConfig.kt rename to src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryConfig.kt index 2647b15ad..f177b5f3e 100644 --- a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.inventory +package com.lambda.interaction.managers.inventory import com.lambda.config.ISettingGroup import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt similarity index 94% rename from src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt rename to src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt index 01e198ae2..614f75796 100644 --- a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.inventory +package com.lambda.interaction.managers.inventory import com.lambda.config.AutomationConfig.Companion.DEFAULT import com.lambda.context.AutomatedSafeContext @@ -25,13 +25,13 @@ import com.lambda.event.events.PacketEvent import com.lambda.event.events.TickEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.Logger -import com.lambda.interaction.request.RequestHandler -import com.lambda.interaction.request.inventory.InventoryManager.actions -import com.lambda.interaction.request.inventory.InventoryManager.activeRequest -import com.lambda.interaction.request.inventory.InventoryManager.alteredSlots -import com.lambda.interaction.request.inventory.InventoryManager.processActiveRequest -import com.lambda.interaction.request.interacting.InteractManager +import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.inventory.InventoryManager.actions +import com.lambda.interaction.managers.inventory.InventoryManager.activeRequest +import com.lambda.interaction.managers.inventory.InventoryManager.alteredSlots +import com.lambda.interaction.managers.inventory.InventoryManager.processActiveRequest +import com.lambda.interaction.managers.interacting.InteractManager import com.lambda.module.hud.ManagerDebugLoggers.inventoryManagerLogger import com.lambda.threading.runSafe import com.lambda.util.collections.LimitedDecayQueue @@ -50,7 +50,7 @@ import net.minecraft.screen.slot.Slot * Manager designed to handle inventory actions. One of the key features being the inventory change detection to * avoid accepting old information from the server in cases where ping is high. This helps to prevent desync. */ -object InventoryManager : RequestHandler( +object InventoryManager : Manager( 1, onOpen = { processActiveRequest() } ), Logger { diff --git a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/request/inventory/InventoryRequest.kt rename to src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt index 24e2ffd2e..74862cecb 100644 --- a/src/main/kotlin/com/lambda/interaction/request/inventory/InventoryRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.inventory +package com.lambda.interaction.managers.inventory import com.lambda.context.Automated import com.lambda.context.SafeContext -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.Request +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.Request import com.lambda.util.player.SlotUtils.clickSlot import net.minecraft.item.ItemStack import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/Rotation.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt similarity index 99% rename from src/main/kotlin/com/lambda/interaction/request/rotating/Rotation.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt index d10326ba7..96c9ff7ca 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/Rotation.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating +package com.lambda.interaction.managers.rotating import com.lambda.threading.runSafe import com.lambda.util.math.MathUtils.toDegree diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationConfig.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/interaction/request/rotating/RotationConfig.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/RotationConfig.kt index 9e48d60ad..d974a74ff 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating +package com.lambda.interaction.managers.rotating import com.lambda.config.ISettingGroup import com.lambda.config.Setting diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationManager.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt similarity index 95% rename from src/main/kotlin/com/lambda/interaction/request/rotating/RotationManager.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt index 276edf865..d186602ba 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating +package com.lambda.interaction.managers.rotating import com.lambda.Lambda.mc import com.lambda.context.AutomatedSafeContext @@ -31,14 +31,14 @@ import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.interaction.BaritoneManager -import com.lambda.interaction.request.Logger -import com.lambda.interaction.request.RequestHandler -import com.lambda.interaction.request.rotating.Rotation.Companion.slerp -import com.lambda.interaction.request.rotating.RotationManager.activeRequest -import com.lambda.interaction.request.rotating.RotationManager.activeRotation -import com.lambda.interaction.request.rotating.RotationManager.serverRotation -import com.lambda.interaction.request.rotating.RotationManager.updateActiveRotation -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.rotating.Rotation.Companion.slerp +import com.lambda.interaction.managers.rotating.RotationManager.activeRequest +import com.lambda.interaction.managers.rotating.RotationManager.activeRotation +import com.lambda.interaction.managers.rotating.RotationManager.serverRotation +import com.lambda.interaction.managers.rotating.RotationManager.updateActiveRotation +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.hud.ManagerDebugLoggers.rotationManagerLogger import com.lambda.threading.runGameScheduled import com.lambda.threading.runSafe @@ -60,7 +60,7 @@ import kotlin.math.sin /** * Manager designed to rotate the player and adjust movement input to match the camera's direction. */ -object RotationManager : RequestHandler( +object RotationManager : Manager( 1, *(ALL_STAGES.subList(ALL_STAGES.indexOf(TickEvent.Player.Post), ALL_STAGES.size - 1).toTypedArray()), ), Logger { diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationMode.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationMode.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/request/rotating/RotationMode.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/RotationMode.kt index 59313d50d..814bce1bd 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationMode.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationMode.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating +package com.lambda.interaction.managers.rotating import com.lambda.util.Describable import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationRequest.kt similarity index 85% rename from src/main/kotlin/com/lambda/interaction/request/rotating/RotationRequest.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/RotationRequest.kt index 84269676a..1815afc79 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/RotationRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationRequest.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating +package com.lambda.interaction.managers.rotating import com.lambda.context.Automated -import com.lambda.interaction.request.LogContext -import com.lambda.interaction.request.LogContext.Companion.LogContextBuilder -import com.lambda.interaction.request.Request -import com.lambda.interaction.request.rotating.visibilty.RotationTarget +import com.lambda.interaction.managers.LogContext +import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder +import com.lambda.interaction.managers.Request +import com.lambda.interaction.managers.rotating.visibilty.RotationTarget import com.lambda.threading.runSafe data class RotationRequest( diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PlaceDirection.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PlaceDirection.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt index dd17ffa97..eb858d4d0 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PlaceDirection.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import net.minecraft.entity.Entity import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PointSelection.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt similarity index 90% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PointSelection.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt index dbb7f9fb3..ee3c1d742 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PointSelection.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty -import com.lambda.interaction.request.rotating.Rotation.Companion.dist -import com.lambda.interaction.request.rotating.RotationManager +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.util.Describable import com.lambda.util.NamedEnum import com.lambda.util.math.distSq diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RequestedHit.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RequestedHit.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RequestedHit.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RequestedHit.kt index 0a8b5910e..e2f303591 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RequestedHit.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RequestedHit.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.ALL_SIDES +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.ALL_SIDES import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState import com.lambda.util.world.raycast.RayCastUtils.blockResult diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RequestedHitDsl.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RequestedHitDsl.kt similarity index 95% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RequestedHitDsl.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RequestedHitDsl.kt index 0c6230b81..476389ebb 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RequestedHitDsl.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RequestedHitDsl.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty import net.minecraft.entity.LivingEntity import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RotationTarget.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTarget.kt similarity index 84% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RotationTarget.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTarget.kt index 71359b35b..cfc55f162 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RotationTarget.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTarget.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty import com.lambda.context.Automated import com.lambda.context.SafeContext -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.dist -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.RotationRequest +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.RotationRequest import com.lambda.threading.runSafe import com.lambda.util.collections.updatableLazy diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RotationTargets.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt similarity index 91% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RotationTargets.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt index 5849266a9..d0ae3a11f 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/RotationTargets.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty import com.lambda.context.Automated import com.lambda.context.SafeContext -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.dist -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.ALL_SIDES -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.findRotation +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.ALL_SIDES +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.findRotation import com.lambda.threading.runSafeAutomated import com.lambda.util.extension.rotation import com.lambda.util.world.raycast.InteractionMask diff --git a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt similarity index 97% rename from src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt rename to src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt index 7f6665fc6..081d72a8e 100644 --- a/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/VisibilityChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt @@ -15,16 +15,16 @@ * along with this program. If not, see . */ -package com.lambda.interaction.request.rotating.visibilty +package com.lambda.interaction.managers.rotating.visibilty import com.lambda.config.AutomationConfig.Companion.DEFAULT import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.processing.PreProcessingData +import com.lambda.interaction.construction.simulation.processing.PreProcessingData import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo -import com.lambda.interaction.request.rotating.RotationManager +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.util.extension.component6 import com.lambda.util.math.distSq import com.lambda.util.world.raycast.InteractionMask diff --git a/src/main/kotlin/com/lambda/interaction/material/container/containers/CreativeContainer.kt b/src/main/kotlin/com/lambda/interaction/material/container/containers/CreativeContainer.kt index 6dad142a0..888be64d4 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/containers/CreativeContainer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/containers/CreativeContainer.kt @@ -23,7 +23,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.container.MaterialContainer -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.task.Task import com.lambda.util.item.ItemStackUtils.equal import com.lambda.util.player.gamemode diff --git a/src/main/kotlin/com/lambda/interaction/material/container/containers/MainHandContainer.kt b/src/main/kotlin/com/lambda/interaction/material/container/containers/MainHandContainer.kt index b6df4d1af..f7ae84839 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/containers/MainHandContainer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/containers/MainHandContainer.kt @@ -24,7 +24,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.material.ContainerTask import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.container.MaterialContainer -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.util.item.ItemStackUtils.equal import com.lambda.util.text.buildText import com.lambda.util.text.literal diff --git a/src/main/kotlin/com/lambda/interaction/material/transfer/SlotTransfer.kt b/src/main/kotlin/com/lambda/interaction/material/transfer/SlotTransfer.kt index ea4c886cb..70788f938 100644 --- a/src/main/kotlin/com/lambda/interaction/material/transfer/SlotTransfer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/transfer/SlotTransfer.kt @@ -22,7 +22,7 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.material.StackSelection -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.task.Task import com.lambda.util.extension.containerSlots import com.lambda.util.extension.inventorySlots diff --git a/src/main/kotlin/com/lambda/module/hud/ManagerDebugLoggers.kt b/src/main/kotlin/com/lambda/module/hud/ManagerDebugLoggers.kt index 45bb6bc1d..b0385a1f7 100644 --- a/src/main/kotlin/com/lambda/module/hud/ManagerDebugLoggers.kt +++ b/src/main/kotlin/com/lambda/module/hud/ManagerDebugLoggers.kt @@ -18,7 +18,7 @@ package com.lambda.module.hud import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.interaction.request.DebugLogger +import com.lambda.interaction.managers.DebugLogger import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt index 7df4e35e1..df114a978 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt @@ -20,8 +20,8 @@ package com.lambda.module.modules.combat import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.extension.rotation diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index f5160199b..78d330827 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -34,10 +34,10 @@ import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerManager.transfer import com.lambda.interaction.material.container.containers.MainHandContainer import com.lambda.interaction.material.container.containers.OffHandContainer -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.visibilty.VisibilityChecker.getVisibleSurfaces -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.getVisibleSurfaces +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask.run diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index dbe42cdb2..7586e4707 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -27,8 +27,8 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerManager.transfer import com.lambda.interaction.material.container.containers.MainHandContainer -import com.lambda.interaction.request.rotating.RotationManager -import com.lambda.interaction.request.rotating.visibilty.lookAtEntity +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.visibilty.lookAtEntity import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask.run diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt index bac9cd061..695d62158 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt @@ -21,7 +21,7 @@ import com.lambda.config.AutomationConfig import com.lambda.config.groups.RotationSettings import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.visibilty.lookAtHit +import com.lambda.interaction.managers.rotating.visibilty.lookAtHit import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import net.minecraft.util.hit.HitResult diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index 4a610fe00..cd53754e4 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -20,8 +20,8 @@ package com.lambda.module.modules.debug import com.lambda.config.groups.HotbarSettings import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.Request.Companion.submit -import com.lambda.interaction.request.hotbar.HotbarRequest +import com.lambda.interaction.managers.Request.Companion.submit +import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.Communication.info diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index 820541f40..414325cba 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -26,8 +26,8 @@ import com.lambda.event.events.MouseEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.material.StackSelection.Companion.selectStack -import com.lambda.interaction.request.hotbar.HotbarRequest -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest +import com.lambda.interaction.managers.hotbar.HotbarRequest +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index 75ffb3400..def77c587 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -22,10 +22,10 @@ import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationConfig -import com.lambda.interaction.request.rotating.RotationMode -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.interaction.managers.rotating.RotationMode +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt b/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt index 4b09cd805..753c2b78e 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.movement import com.lambda.event.events.RotationEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.module.Module import com.lambda.module.modules.combat.KillAura import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt index 90c8b2ffc..b988e2e18 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.network import com.lambda.event.events.PacketEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.PlayerPacketManager +import com.lambda.interaction.PlayerPacketHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.Communication.warn @@ -48,20 +48,20 @@ object Rubberband : Module( if (!showRubberbandInfo) return@listen if (event.packet !is PlayerPositionLookS2CPacket) return@listen - if (PlayerPacketManager.configurations.isEmpty()) { + if (PlayerPacketHandler.configurations.isEmpty()) { this@Rubberband.warn("Position was reverted") return@listen } val newPos = event.packet.change.position - val last = PlayerPacketManager.configurations.minBy { + val last = PlayerPacketHandler.configurations.minBy { it.position distSq newPos } this@Rubberband.warn(buildText { literal("Reverted position by ") color(Color.YELLOW) { - literal("${PlayerPacketManager.configurations.toList().asReversed().indexOf(last) + 1}") + literal("${PlayerPacketHandler.configurations.toList().asReversed().indexOf(last) + 1}") } literal(" ticks (deviation: ") color(Color.YELLOW) { diff --git a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt index 0c408d4ea..26e8051a4 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt @@ -22,12 +22,12 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.Request.Companion.submit -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.rotationTo -import com.lambda.interaction.request.rotating.Rotation.Companion.wrap -import com.lambda.interaction.request.rotating.RotationRequest -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.Request.Companion.submit +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo +import com.lambda.interaction.managers.rotating.Rotation.Companion.wrap +import com.lambda.interaction.managers.rotating.RotationRequest +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index b2abee144..206af85fa 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -22,8 +22,8 @@ import com.lambda.config.applyEdits import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.request.breaking.BreakRequest.Companion.breakRequest +import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafeAutomated @@ -48,7 +48,7 @@ object FastBreak : Module( ::checkSideVisibility, ::strictRayCast ) { defaultValue(false) } - ::interactionsPerTick.edit { defaultValue(1) } + ::actionsPerTick.edit { defaultValue(1) } ::interactReach.edit { defaultValue(Double.MAX_VALUE) } } breakConfig.apply { diff --git a/src/main/kotlin/com/lambda/module/modules/player/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/player/Freecam.kt index a0a73c212..aec73dc33 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Freecam.kt @@ -23,10 +23,10 @@ import com.lambda.event.events.PlayerEvent import com.lambda.event.events.RenderEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationConfig -import com.lambda.interaction.request.rotating.RotationMode -import com.lambda.interaction.request.rotating.visibilty.lookAtHit +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.interaction.managers.rotating.RotationMode +import com.lambda.interaction.managers.rotating.visibilty.lookAtHit import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.extension.rotation diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt index c64f64928..daf59e1ca 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt @@ -21,10 +21,10 @@ import com.lambda.Lambda.mc import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.LambdaScreen -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationConfig -import com.lambda.interaction.request.rotating.RotationMode -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.interaction.managers.rotating.RotationMode +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.InputUtils.isKeyPressed diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index b63f5871f..6cf8c9644 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -24,13 +24,13 @@ import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent import com.lambda.event.events.onStaticRender import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.context.BreakContext -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.result.results.BreakResult +import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.request.breaking.BreakConfig -import com.lambda.interaction.request.breaking.BreakRequest.Companion.breakRequest +import com.lambda.interaction.managers.breaking.BreakConfig +import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafeAutomated diff --git a/src/main/kotlin/com/lambda/module/modules/player/Printer.kt b/src/main/kotlin/com/lambda/module/modules/player/Printer.kt index d3e670228..1bcce472e 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Printer.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Printer.kt @@ -21,7 +21,7 @@ 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.request.interacting.InteractConfig +import com.lambda.interaction.managers.interacting.InteractConfig import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask.run diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index c65e0f069..a52949056 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -34,10 +34,10 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.components.ClickGuiLayout -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationConfig -import com.lambda.interaction.request.rotating.RotationMode -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.interaction.managers.rotating.RotationMode +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.modules.player.Replay.InputAction.Companion.toAction import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index 3a9a85a19..038f293bf 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -20,9 +20,9 @@ package com.lambda.module.modules.player import com.lambda.config.groups.RotationSettings import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.RotationRequest -import com.lambda.interaction.request.rotating.visibilty.lookAt +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.RotationRequest +import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt index a74ce7843..6c09fc81b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt @@ -23,10 +23,10 @@ import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.construction.context.BuildContext +import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.request.interacting.InteractRequest.Companion.interactRequest +import com.lambda.interaction.managers.interacting.InteractRequest.Companion.interactRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafeAutomated diff --git a/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt b/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt index 3a22d59d7..36cd3d07c 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.extension.rotation diff --git a/src/main/kotlin/com/lambda/module/modules/render/Particles.kt b/src/main/kotlin/com/lambda/module/modules/render/Particles.kt index 1b13a1ed2..8a9924fdf 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Particles.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Particles.kt @@ -35,7 +35,7 @@ import com.lambda.graphics.pipeline.VertexBuilder import com.lambda.graphics.pipeline.VertexPipeline import com.lambda.graphics.shader.Shader.Companion.shader import com.lambda.gui.components.ClickGuiLayout -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.extension.partialTicks diff --git a/src/main/kotlin/com/lambda/task/tasks/AcquireMaterial.kt b/src/main/kotlin/com/lambda/task/tasks/AcquireMaterial.kt index 399ea9ece..60d70f2b4 100644 --- a/src/main/kotlin/com/lambda/task/tasks/AcquireMaterial.kt +++ b/src/main/kotlin/com/lambda/task/tasks/AcquireMaterial.kt @@ -22,7 +22,6 @@ import com.lambda.context.SafeContext import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.container.ContainerManager import com.lambda.interaction.material.container.ContainerManager.findContainerWithMaterial -import com.lambda.interaction.request.inventory.InventoryConfig import com.lambda.task.Task class AcquireMaterial @Ta5kBuilder constructor( diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index f3564ab49..09bb1dc4d 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -31,24 +31,24 @@ import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStruc import com.lambda.interaction.construction.blueprint.PropagatingBlueprint import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint import com.lambda.interaction.construction.blueprint.TickingBlueprint -import com.lambda.interaction.construction.context.BuildContext -import com.lambda.interaction.construction.result.BuildResult -import com.lambda.interaction.construction.result.Contextual -import com.lambda.interaction.construction.result.Dependent -import com.lambda.interaction.construction.result.Drawable -import com.lambda.interaction.construction.result.Navigable -import com.lambda.interaction.construction.result.Resolvable -import com.lambda.interaction.construction.result.results.BreakResult -import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.InteractResult -import com.lambda.interaction.construction.result.results.PreSimResult +import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Contextual +import com.lambda.interaction.construction.simulation.result.Dependent +import com.lambda.interaction.construction.simulation.result.Drawable +import com.lambda.interaction.construction.simulation.result.Navigable +import com.lambda.interaction.construction.simulation.result.Resolvable +import com.lambda.interaction.construction.simulation.result.results.BreakResult +import com.lambda.interaction.construction.simulation.result.results.GenericResult +import com.lambda.interaction.construction.simulation.result.results.InteractResult +import com.lambda.interaction.construction.simulation.result.results.PreSimResult import com.lambda.interaction.construction.simulation.BuildGoal import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.Simulation.Companion.simulation import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.request.breaking.BreakRequest.Companion.breakRequest -import com.lambda.interaction.request.interacting.InteractRequest.Companion.interactRequest -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest +import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest +import com.lambda.interaction.managers.interacting.InteractRequest.Companion.interactRequest +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.task.Task import com.lambda.task.tasks.EatTask.Companion.eat import com.lambda.threading.runSafeAutomated @@ -72,7 +72,7 @@ class BuildTask private constructor( private val pendingInteractions = ConcurrentLinkedQueue() private val atMaxPendingInteractions - get() = pendingInteractions.size >= buildConfig.maxPendingInteractions + get() = pendingInteractions.size >= buildConfig.maxPendingActions private var placements = 0 private var breaks = 0 diff --git a/src/main/kotlin/com/lambda/task/tasks/OpenContainer.kt b/src/main/kotlin/com/lambda/task/tasks/OpenContainer.kt index 105f6089b..560a72662 100644 --- a/src/main/kotlin/com/lambda/task/tasks/OpenContainer.kt +++ b/src/main/kotlin/com/lambda/task/tasks/OpenContainer.kt @@ -21,7 +21,7 @@ import com.lambda.context.Automated import com.lambda.event.events.InventoryEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.request.rotating.visibilty.lookAtBlock +import com.lambda.interaction.managers.rotating.visibilty.lookAtBlock import com.lambda.task.Task import com.lambda.util.world.raycast.RayCastUtils.blockResult import net.minecraft.screen.ScreenHandler diff --git a/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt b/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt index 935c6c4df..5e2816a21 100644 --- a/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt +++ b/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt @@ -21,11 +21,11 @@ import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint -import com.lambda.interaction.construction.result.results.GenericResult -import com.lambda.interaction.construction.result.results.InteractResult +import com.lambda.interaction.construction.simulation.result.results.GenericResult +import com.lambda.interaction.construction.simulation.result.results.InteractResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.request.ManagerUtils +import com.lambda.interaction.managers.ManagerUtils import com.lambda.task.Task import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.threading.runSafeAutomated diff --git a/src/main/kotlin/com/lambda/util/extension/Entity.kt b/src/main/kotlin/com/lambda/util/extension/Entity.kt index 56eb488b4..c7bc6e583 100644 --- a/src/main/kotlin/com/lambda/util/extension/Entity.kt +++ b/src/main/kotlin/com/lambda/util/extension/Entity.kt @@ -17,7 +17,7 @@ package com.lambda.util.extension -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import net.minecraft.entity.Entity import net.minecraft.entity.LivingEntity import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/lambda/util/math/Linear.kt b/src/main/kotlin/com/lambda/util/math/Linear.kt index f9a30fdf6..969e6d36a 100644 --- a/src/main/kotlin/com/lambda/util/math/Linear.kt +++ b/src/main/kotlin/com/lambda/util/math/Linear.kt @@ -17,7 +17,7 @@ package com.lambda.util.math -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import net.minecraft.util.math.Box import net.minecraft.util.math.Vec3d import java.awt.Color diff --git a/src/main/kotlin/com/lambda/util/player/MovementUtils.kt b/src/main/kotlin/com/lambda/util/player/MovementUtils.kt index 1f9c0215c..17943e8ae 100644 --- a/src/main/kotlin/com/lambda/util/player/MovementUtils.kt +++ b/src/main/kotlin/com/lambda/util/player/MovementUtils.kt @@ -18,7 +18,7 @@ package com.lambda.util.player import com.lambda.context.SafeContext -import com.lambda.interaction.request.rotating.RotationManager +import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.util.math.MathUtils.toDegree import com.lambda.util.math.MathUtils.toDouble import com.lambda.util.math.MathUtils.toRadian diff --git a/src/main/kotlin/com/lambda/util/player/prediction/PredictionEntity.kt b/src/main/kotlin/com/lambda/util/player/prediction/PredictionEntity.kt index ed5780a89..cd7202e42 100644 --- a/src/main/kotlin/com/lambda/util/player/prediction/PredictionEntity.kt +++ b/src/main/kotlin/com/lambda/util/player/prediction/PredictionEntity.kt @@ -19,7 +19,7 @@ package com.lambda.util.player.prediction import com.lambda.Lambda.mc import com.lambda.context.SafeContext -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import com.lambda.module.modules.movement.SafeWalk.isNearLedge import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState diff --git a/src/main/kotlin/com/lambda/util/player/prediction/PredictionTick.kt b/src/main/kotlin/com/lambda/util/player/prediction/PredictionTick.kt index 3f84a9d9f..d2fa065dc 100644 --- a/src/main/kotlin/com/lambda/util/player/prediction/PredictionTick.kt +++ b/src/main/kotlin/com/lambda/util/player/prediction/PredictionTick.kt @@ -17,7 +17,7 @@ package com.lambda.util.player.prediction -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import net.minecraft.util.math.Box import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt b/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt index d53588414..af159a65b 100644 --- a/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt +++ b/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt @@ -19,7 +19,7 @@ package com.lambda.util.world.raycast import com.lambda.Lambda.mc import com.lambda.context.SafeContext -import com.lambda.interaction.request.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation import com.lambda.util.math.distSq import net.minecraft.client.network.ClientPlayerEntity import net.minecraft.entity.Entity diff --git a/src/test/kotlin/PlaceDirectionTest.kt b/src/test/kotlin/PlaceDirectionTest.kt index 9f76d1b9a..cbde3cf1a 100644 --- a/src/test/kotlin/PlaceDirectionTest.kt +++ b/src/test/kotlin/PlaceDirectionTest.kt @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.visibilty.PlaceDirection +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.visibilty.PlaceDirection import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse diff --git a/src/test/kotlin/RotationTest.kt b/src/test/kotlin/RotationTest.kt index d103eb346..e61dda91f 100644 --- a/src/test/kotlin/RotationTest.kt +++ b/src/test/kotlin/RotationTest.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -import com.lambda.interaction.request.rotating.Rotation -import com.lambda.interaction.request.rotating.Rotation.Companion.angleDifference -import com.lambda.interaction.request.rotating.Rotation.Companion.dist -import com.lambda.interaction.request.rotating.Rotation.Companion.lerp -import com.lambda.interaction.request.rotating.Rotation.Companion.slerp -import com.lambda.interaction.request.rotating.Rotation.Companion.wrap +import com.lambda.interaction.managers.rotating.Rotation +import com.lambda.interaction.managers.rotating.Rotation.Companion.angleDifference +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.Rotation.Companion.lerp +import com.lambda.interaction.managers.rotating.Rotation.Companion.slerp +import com.lambda.interaction.managers.rotating.Rotation.Companion.wrap import kotlin.math.abs import kotlin.math.hypot import kotlin.test.Test From 386329b9f2cb66b800a105c57b39628f939ec873 Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Sat, 6 Dec 2025 23:36:13 +0000 Subject: [PATCH 4/7] fix compile error --- src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index e398e0e9b..9966dbc81 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -22,8 +22,8 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.friend.FriendManager +import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.interaction.material.StackSelection.Companion.select -import com.lambda.interaction.request.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum From 914c226744cbd0b0aa98f4dea03d26e30f679aa6 Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Sun, 7 Dec 2025 02:00:38 +0000 Subject: [PATCH 5/7] nits --- .../ClientPlayInteractionManagerMixin.java | 14 +++++++++++++- .../com/lambda/config/AutomationConfig.kt | 5 ++--- .../managers/breaking/BreakRequest.kt | 9 +++++---- .../managers/interacting/InteractRequest.kt | 3 ++- .../managers/inventory/InventoryManager.kt | 18 +++++++++++++----- .../com/lambda/module/modules/player/Nuker.kt | 7 +------ .../lambda/module/modules/player/PacketMine.kt | 7 ++----- 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java b/src/main/java/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java index 9748f7e5f..d3287d3c6 100644 --- a/src/main/java/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java +++ b/src/main/java/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java @@ -20,12 +20,18 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.InventoryEvent; import com.lambda.event.events.PlayerEvent; +import com.lambda.interaction.managers.inventory.InventoryManager; +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerInteractionManager; +import net.minecraft.client.recipebook.ClientRecipeBook; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.slot.SlotActionType; +import net.minecraft.stat.StatHandler; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -42,7 +48,6 @@ @Mixin(ClientPlayerInteractionManager.class) public class ClientPlayInteractionManagerMixin { - @Shadow public float currentBreakingProgress; @@ -115,4 +120,11 @@ private void updateBlockBreakingProgressPre(BlockPos pos, Direction side, Callba private void cancelBlockBreakingPre(CallbackInfo ci) { if (EventFlow.post(new PlayerEvent.Breaking.Cancel(currentBreakingProgress)).isCanceled()) ci.cancel(); } + + @WrapMethod(method = "createPlayer(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/stat/StatHandler;Lnet/minecraft/client/recipebook/ClientRecipeBook;ZZ)Lnet/minecraft/client/network/ClientPlayerEntity;") + private ClientPlayerEntity injectCreatePlayer(ClientWorld world, StatHandler statHandler, ClientRecipeBook recipeBook, boolean lastSneaking, boolean lastSprinting, Operation original) { + var player = original.call(world, statHandler, recipeBook, lastSneaking, lastSprinting); + InventoryManager.INSTANCE.setScreenHandler(player.playerScreenHandler); + return player; + } } diff --git a/src/main/kotlin/com/lambda/config/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/AutomationConfig.kt index e7585081f..b872eae37 100644 --- a/src/main/kotlin/com/lambda/config/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/AutomationConfig.kt @@ -22,8 +22,8 @@ import com.lambda.config.groups.BreakSettings import com.lambda.config.groups.BuildSettings import com.lambda.config.groups.EatSettings import com.lambda.config.groups.HotbarSettings -import com.lambda.config.groups.InventorySettings import com.lambda.config.groups.InteractSettings +import com.lambda.config.groups.InventorySettings import com.lambda.config.groups.RotationSettings import com.lambda.context.Automated import com.lambda.event.events.onStaticRender @@ -39,7 +39,6 @@ open class AutomationConfig( enum class Group(override val displayName: String) : NamedEnum { Build("Build"), Break("Break"), - Place("Place"), Interact("Interact"), Rotation("Rotation"), Inventory("Inventory"), @@ -51,7 +50,7 @@ open class AutomationConfig( override val buildConfig = BuildSettings(this, Group.Build) override val breakConfig = BreakSettings(this, Group.Break) - override val interactConfig = InteractSettings(this, Group.Place) + override val interactConfig = InteractSettings(this, Group.Interact) override val rotationConfig = RotationSettings(this, Group.Rotation) override val inventoryConfig = InventorySettings(this, Group.Inventory) override val hotbarConfig = HotbarSettings(this, Group.Hotbar) diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt index a65f18671..ed4597286 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt @@ -20,12 +20,12 @@ package com.lambda.interaction.managers.breaking import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext -import com.lambda.interaction.construction.simulation.result.BuildResult -import com.lambda.interaction.construction.simulation.result.Dependent -import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.context.BuildContext +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.Dependent +import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.LogContext import com.lambda.interaction.managers.LogContext.Companion.LogContextBuilder @@ -162,7 +162,8 @@ data class BreakRequest private constructor( ) = asSequence() .map { if (it is Dependent) it.lastDependency else it } .filterIsInstance() - .map { it.context } + .sorted() + .map { it.context } .toSet() .takeIf { it.isNotEmpty() } ?.let { automated.breakRequest(it, pendingInteractions, nowOrNothing, builder) } diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt index 292e9584c..ea219c7bc 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt @@ -89,7 +89,8 @@ data class InteractRequest private constructor( ) = asSequence() .map { if (it is Dependent) it.lastDependency else it } .filterIsInstance() - .map { it.context } + .sorted() + .map { it.context } .toSet() .takeIf { it.isNotEmpty() } ?.let { automated.interactRequest(it, pendingInteractions, nowOrNothing, builder) } diff --git a/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt index 30912725f..eea3d6cd3 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryManager.kt @@ -27,11 +27,11 @@ import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.Logger import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.interacting.InteractManager import com.lambda.interaction.managers.inventory.InventoryManager.actions import com.lambda.interaction.managers.inventory.InventoryManager.activeRequest import com.lambda.interaction.managers.inventory.InventoryManager.alteredSlots import com.lambda.interaction.managers.inventory.InventoryManager.processActiveRequest -import com.lambda.interaction.managers.interacting.InteractManager import com.lambda.module.hud.ManagerDebugLoggers.inventoryManagerLogger import com.lambda.threading.runSafe import com.lambda.util.collections.LimitedDecayQueue @@ -61,9 +61,9 @@ object InventoryManager : Manager( private var alteredSlots = LimitedDecayQueue(Int.MAX_VALUE, DEFAULT.desyncTimeout * 50L) private var alteredPlayerSlots = LimitedDecayQueue(Int.MAX_VALUE, DEFAULT.desyncTimeout * 50L) - private var screenHandler: ScreenHandler? = null + var screenHandler: ScreenHandler? = null set(value) { - if (value != null && field?.syncId != value.syncId) { + if (value != null) { alteredSlots.clear() slots = getStacks(value.slots) } @@ -248,9 +248,17 @@ object InventoryManager : Manager( } } - if (!matches) player.playerScreenHandler.setStackInSlot(packet.slot, packet.revision, itemStack) + player.playerScreenHandler.setStackInSlot( + packet.slot, + packet.revision, + if (!matches) itemStack else player.playerScreenHandler.getSlot(packet.slot).stack + ) } else if (packet.syncId == player.currentScreenHandler.syncId && (packet.syncId != 0 || !bl)) - if (!matches) player.currentScreenHandler.setStackInSlot(packet.slot, packet.revision, itemStack) + player.currentScreenHandler.setStackInSlot( + packet.slot, + packet.revision, + if (!matches) itemStack else player.playerScreenHandler.getSlot(packet.slot).stack + ) if (mc.currentScreen is CreativeInventoryScreen) { player.playerScreenHandler.setReceivedStack(packet.slot, itemStack) diff --git a/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt index f594c6116..ef9c912f6 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt @@ -18,7 +18,6 @@ package com.lambda.module.modules.player import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.applyEdits import com.lambda.interaction.BaritoneManager import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState @@ -47,11 +46,7 @@ object Nuker : Module( private var task: Task<*>? = null init { - setDefaultAutomationConfig { - applyEdits { - hideGroup(interactConfig) - } - } + setDefaultAutomationConfig() onEnable { task = tickingBlueprint { diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index 6cf8c9644..024f3f7bd 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -24,10 +24,10 @@ import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent import com.lambda.event.events.onStaticRender import com.lambda.event.listener.SafeListener.Companion.listen +import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.result.results.BreakResult -import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.breaking.BreakConfig import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest @@ -119,10 +119,7 @@ object PacketMine : Module( attackedThisTick = false } - listen { - it.cancel() - } - + listen { it.cancel() } listen { event -> event.cancel() val pos = event.pos From 47aede5cf84926d2495fca2cafa77fbe1009c9bb Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Sun, 7 Dec 2025 04:51:51 +0000 Subject: [PATCH 6/7] more nits and fixes --- .../com/lambda/config/groups/BreakSettings.kt | 2 +- .../lambda/config/groups/InteractSettings.kt | 4 +-- .../managers/breaking/BreakManager.kt | 12 +++++---- .../managers/interacting/InteractConfig.kt | 10 ++++---- .../managers/interacting/InteractManager.kt | 25 +++++++++---------- .../interacting/InteractedBlockHandler.kt | 4 +-- .../com/lambda/module/modules/player/Nuker.kt | 4 +-- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 19 +++++++------- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt index 86b16be62..2c0033bf5 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt @@ -54,7 +54,7 @@ open class BreakSettings( override val serverSwapTicks by c.setting("Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)").group(baseGroup, Group.General).index() // override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { vis() && page == Page.General } - override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)").group(baseGroup, Group.General).index() + override val breakDelay by c.setting("Break Delay", 0, 0..5, 1, "The delay between breaking blocks", " tick(s)").group(baseGroup, Group.General).index() // Timing override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which break actions can be performed").group(baseGroup, Group.General).index() diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index 375a68660..c9b142e29 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -23,7 +23,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.interaction.managers.interacting.InteractConfig import com.lambda.interaction.managers.interacting.InteractConfig.AirPlaceMode -import com.lambda.interaction.managers.interacting.InteractConfig.PlaceConfirmationMode +import com.lambda.interaction.managers.interacting.InteractConfig.InteractConfirmationMode import com.lambda.util.NamedEnum class InteractSettings( @@ -35,7 +35,7 @@ class InteractSettings( override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled }.group(baseGroup).index() override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index() override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which place actions are performed").group(baseGroup).index() - override val interactConfirmationMode by c.setting("Interact Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index() + override val interactConfirmationMode by c.setting("Interact Confirmation", InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index() override val maxPendingInteractions by c.setting("Max Pending Interactions", 5, 0..30, 1, "The maximum amount of pending placements").group(baseGroup).index() override val interactionsPerTick by c.setting("Interactions Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index() override val swing by c.setting("Swing On Interact", true, "Swings the players hand when placing").group(baseGroup).index() diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index e5cf7e20e..94ed7cc0f 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -31,18 +31,16 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.renderer.esp.DynamicAABB import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure -import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.context.BreakContext +import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.material.StackSelection -import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.Manager import com.lambda.interaction.managers.ManagerUtils.isPosBlocked import com.lambda.interaction.managers.ManagerUtils.newStage import com.lambda.interaction.managers.ManagerUtils.newTick import com.lambda.interaction.managers.PositionBlocking -import com.lambda.interaction.managers.Manager import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode import com.lambda.interaction.managers.breaking.BreakConfig.BreakMode import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary @@ -75,7 +73,10 @@ import com.lambda.interaction.managers.breaking.BrokenBlockHandler.startPending import com.lambda.interaction.managers.breaking.RebreakHandler.getRebreakPotential import com.lambda.interaction.managers.breaking.SwapInfo.Companion.getSwapInfo import com.lambda.interaction.managers.hotbar.HotbarRequest +import com.lambda.interaction.managers.interacting.InteractManager import com.lambda.interaction.managers.rotating.RotationRequest +import com.lambda.interaction.material.StackSelection +import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.module.hud.ManagerDebugLoggers.breakManagerLogger import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState @@ -307,6 +308,7 @@ object BreakManager : Manager( */ override fun AutomatedSafeContext.handleRequest(request: BreakRequest) { if (activeRequest != null || request.contexts.isEmpty()) return + if (InteractManager.activeThisTick) return activeRequest = request processRequest(request) @@ -841,7 +843,7 @@ object BreakManager : Manager( logger.success("Instant breaking", info) info.vanillaInstantBreakable = progress >= 1 onBlockBreak(info) - if (!info.vanillaInstantBreakable) breakCooldown = breakConfig.breakDelay + if (!info.vanillaInstantBreakable) breakCooldown = breakConfig.breakDelay + 1 } else { logger.debug("Starting break", info) info.apply { diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt index 63999d6ec..996be04c7 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt @@ -28,7 +28,7 @@ interface InteractConfig : ActionConfig, ISettingGroup { val airPlace: AirPlaceMode val axisRotateSetting: Boolean val axisRotate get() = rotate && airPlace.isEnabled && axisRotateSetting - val interactConfirmationMode: PlaceConfirmationMode + val interactConfirmationMode: InteractConfirmationMode val maxPendingInteractions: Int val interactionsPerTick: Int val swing: Boolean @@ -47,12 +47,12 @@ interface InteractConfig : ActionConfig, ISettingGroup { val isEnabled get() = this != None } - enum class PlaceConfirmationMode( + enum class InteractConfirmationMode( override val displayName: String, override val description: String ) : NamedEnum, Describable { - None("No confirmation", "Place immediately without waiting for the server; lowest latency, possible brief desync."), - PlaceThenAwait("Place now, confirm later", "Show placement right away, then wait for server confirmation to verify."), - AwaitThenPlace("Confirm first, then place", "Wait for server response before showing placement; most accurate, adds a short delay.") + None("No confirmation", "Interact immediately without waiting for the server; possible desync."), + PlaceThenAwait("Interact now, confirm later", "Interact immediately, then wait for server confirmation to verify."), + AwaitThenPlace("Confirm first, then Interact", "Wait for server response before interacting; safest, adds a short delay.") } } diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt index 8a1dab083..e6b70a3e5 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt @@ -28,11 +28,11 @@ import com.lambda.event.events.UpdateManagerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.simulation.context.InteractContext import com.lambda.interaction.managers.Logger +import com.lambda.interaction.managers.Manager import com.lambda.interaction.managers.ManagerUtils.isPosBlocked import com.lambda.interaction.managers.ManagerUtils.newStage import com.lambda.interaction.managers.ManagerUtils.newTick import com.lambda.interaction.managers.PositionBlocking -import com.lambda.interaction.managers.Manager import com.lambda.interaction.managers.breaking.BreakManager import com.lambda.interaction.managers.interacting.InteractManager.activeRequest import com.lambda.interaction.managers.interacting.InteractManager.maxPlacementsThisTick @@ -123,6 +123,7 @@ object InteractManager : Manager( */ override fun AutomatedSafeContext.handleRequest(request: InteractRequest) { if (activeRequest != null || request.contexts.isEmpty()) return + if (BreakManager.activeThisTick) return activeRequest = request processRequest(request) @@ -164,15 +165,13 @@ object InteractManager : Manager( else interaction.interactBlock(player, Hand.MAIN_HAND, ctx.hitResult) if (!actionResult.isAccepted) { logger.warning("Placement interaction failed with $actionResult", ctx, request) - } else { - if (interactConfig.swing) { - swingHand(interactConfig.swingType, Hand.MAIN_HAND) - - val stackInHand = player.getStackInHand(Hand.MAIN_HAND) - val stackCountPre = stackInHand.count - if (!stackInHand.isEmpty && (stackInHand.count != stackCountPre || player.isInCreativeMode)) { - mc.gameRenderer.firstPersonRenderer.resetEquipProgress(Hand.MAIN_HAND) - } + } else if (interactConfig.swing) { + swingHand(interactConfig.swingType, Hand.MAIN_HAND) + + val stackInHand = player.getStackInHand(Hand.MAIN_HAND) + val stackCountPre = stackInHand.count + if (!stackInHand.isEmpty && (stackInHand.count != stackCountPre || player.isInCreativeMode)) { + mc.gameRenderer.firstPersonRenderer.resetEquipProgress(Hand.MAIN_HAND) } } placementsThisTick++ @@ -339,14 +338,14 @@ object InteractManager : Manager( sendInteractPacket(hand, hitResult) } - if (interactConfig.interactConfirmationMode != InteractConfig.PlaceConfirmationMode.None) { + if (interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.None) { InteractInfo(interactContext, request.pendingInteractions, request.onPlace, interactConfig).startPending() } val itemStack = itemPlacementContext.stack itemStack.decrementUnlessCreative(1, player) - if (interactConfig.interactConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) + if (interactConfig.interactConfirmationMode == InteractConfig.InteractConfirmationMode.AwaitThenPlace) return ActionResult.SUCCESS // TODO: Implement restriction checks (e.g., world height) to prevent unnecessary server requests when the @@ -367,7 +366,7 @@ object InteractManager : Manager( if (interactConfig.sounds) placeSound(state, blockPos) - if (interactConfig.interactConfirmationMode == InteractConfig.PlaceConfirmationMode.None) { + if (interactConfig.interactConfirmationMode == InteractConfig.InteractConfirmationMode.None) { request.onPlace?.invoke(this, interactContext.blockPos) } diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt index 14bc59022..c28dbe213 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt @@ -35,7 +35,7 @@ object InteractedBlockHandler : PostActionHandler() { DEFAULT.buildConfig.actionTimeout * 50L ) { info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out") - if (it.interactConfig.interactConfirmationMode != InteractConfig.PlaceConfirmationMode.AwaitThenPlace) { + if (it.interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.AwaitThenPlace) { runSafe { world.setBlockState(it.context.blockPos, it.context.cachedState) } @@ -66,7 +66,7 @@ object InteractedBlockHandler : PostActionHandler() { pending.stopPending() - if (pending.interactConfig.interactConfirmationMode == InteractConfig.PlaceConfirmationMode.AwaitThenPlace) + if (pending.interactConfig.interactConfirmationMode == InteractConfig.InteractConfirmationMode.AwaitThenPlace) with(pending.context) { placeSound(expectedState, blockPos) } pending.onPlace?.invoke(this, pending.context.blockPos) } diff --git a/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt index ef9c912f6..49e5849de 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Nuker.kt @@ -78,9 +78,7 @@ object Nuker : Module( selection }.build(finishOnDone = false) - // ToDo: Add build setting delegates - - task?.run() + .run() } onDisable { diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index 09bb1dc4d..9fe4dde30 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -31,6 +31,9 @@ import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStruc import com.lambda.interaction.construction.blueprint.PropagatingBlueprint import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint import com.lambda.interaction.construction.blueprint.TickingBlueprint +import com.lambda.interaction.construction.simulation.BuildGoal +import com.lambda.interaction.construction.simulation.BuildSimulator.simulate +import com.lambda.interaction.construction.simulation.Simulation.Companion.simulation import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.Contextual @@ -42,9 +45,6 @@ import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.construction.simulation.result.results.InteractResult import com.lambda.interaction.construction.simulation.result.results.PreSimResult -import com.lambda.interaction.construction.simulation.BuildGoal -import com.lambda.interaction.construction.simulation.BuildSimulator.simulate -import com.lambda.interaction.construction.simulation.Simulation.Companion.simulation import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest import com.lambda.interaction.managers.interacting.InteractRequest.Companion.interactRequest @@ -134,7 +134,7 @@ class BuildTask private constructor( } private fun SafeContext.handleResult(result: BuildResult, allResults: List) { - if (result !is Contextual && pendingInteractions.isNotEmpty()) + if (result !is Dependent && result !is Contextual && pendingInteractions.isNotEmpty()) return when (result) { @@ -174,17 +174,18 @@ class BuildTask private constructor( } }?.submit() - is InteractResult.Interact -> - allResults.interactRequest(pendingInteractions, false) { - onPlace { placements++ } - }?.submit() + is InteractResult.Interact -> { + allResults.interactRequest(pendingInteractions, false) { + onPlace { placements++ } + }?.submit() + } } } is Dependent -> handleResult(result.lastDependency, allResults) is Resolvable -> { - LOG.info("Resolving: ${result.name}") + LOG.info("Resolving: ${result.name}") result.resolve().execute(this@BuildTask) } } From 8e5d24814cf048f2dcb8680a0092d652a0944e77 Mon Sep 17 00:00:00 2001 From: beanbag44 Date: Mon, 8 Dec 2025 16:52:06 +0000 Subject: [PATCH 7/7] import cleanup --- .../com/lambda/interaction/construction/simulation/Sim.kt | 3 ++- .../com/lambda/interaction/construction/simulation/SimInfo.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt index ce74e8d20..751b1a2e9 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.construction.simulation +import com.lambda.interaction.construction.simulation.processing.PreProcessingData import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo @@ -90,7 +91,7 @@ abstract class Sim : Results { voxelShape: VoxelShape, pos: BlockPos, sides: Set, - preProcessing: com.lambda.interaction.construction.simulation.processing.PreProcessingData? + preProcessing: PreProcessingData? ): Set? { val boxes = voxelShape.boundingBoxes.map { it.offset(pos) } diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt index c609e84b4..202799110 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/SimInfo.kt @@ -139,7 +139,7 @@ interface SimInfo : Automated { } interface InteractSimInfo : SimInfo { - val preProcessing: com.lambda.interaction.construction.simulation.processing.PreProcessingData + val preProcessing: PreProcessingData val expectedState: BlockState val item: Item? val placing: Boolean