Skip to content

Commit 596695b

Browse files
committed
working but needs major improvements
1 parent 1512770 commit 596695b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1137
-1693
lines changed

src/main/kotlin/com/lambda/config/AutomationConfig.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ import com.lambda.config.groups.BreakSettings
2222
import com.lambda.config.groups.BuildSettings
2323
import com.lambda.config.groups.EatSettings
2424
import com.lambda.config.groups.HotbarSettings
25-
import com.lambda.config.groups.InteractSettings
2625
import com.lambda.config.groups.InventorySettings
27-
import com.lambda.config.groups.PlaceSettings
26+
import com.lambda.config.groups.InteractSettings
2827
import com.lambda.config.groups.RotationSettings
2928
import com.lambda.context.Automated
3029
import com.lambda.event.events.onStaticRender
@@ -52,8 +51,7 @@ open class AutomationConfig(
5251

5352
override val buildConfig = BuildSettings(this, Group.Build)
5453
override val breakConfig = BreakSettings(this, Group.Break)
55-
override val placeConfig = PlaceSettings(this, Group.Place)
56-
override val interactConfig = InteractSettings(this, Group.Interact)
54+
override val interactConfig = InteractSettings(this, Group.Place)
5755
override val rotationConfig = RotationSettings(this, Group.Rotation)
5856
override val inventoryConfig = InventorySettings(this, Group.Inventory)
5957
override val hotbarConfig = HotbarSettings(this, Group.Hotbar)

src/main/kotlin/com/lambda/config/MutableAutomationConfig.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import com.lambda.interaction.request.breaking.BreakConfig
2424
import com.lambda.interaction.request.hotbar.HotbarConfig
2525
import com.lambda.interaction.request.interacting.InteractConfig
2626
import com.lambda.interaction.request.inventory.InventoryConfig
27-
import com.lambda.interaction.request.placing.PlaceConfig
2827
import com.lambda.interaction.request.rotating.RotationConfig
2928

3029
interface MutableAutomationConfig : Automated {
@@ -34,7 +33,6 @@ interface MutableAutomationConfig : Automated {
3433

3534
override val buildConfig: BuildConfig get() = automationConfig.buildConfig
3635
override val breakConfig: BreakConfig get() = automationConfig.breakConfig
37-
override val placeConfig: PlaceConfig get() = automationConfig.placeConfig
3836
override val interactConfig: InteractConfig get() = automationConfig.interactConfig
3937
override val rotationConfig: RotationConfig get() = automationConfig.rotationConfig
4038
override val inventoryConfig: InventoryConfig get() = automationConfig.inventoryConfig

src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ open class BreakSettings(
6767
override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None }.group(baseGroup, Group.General).index()
6868

6969
// Rotate
70-
override val rotateForBreak by c.setting("Rotate For Break", false, "Rotate towards block while breaking").group(baseGroup, Group.General).index()
70+
override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking").group(baseGroup, Group.General).index()
7171

7272
// Pending / Post
7373
override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking").group(baseGroup, Group.General).index()

src/main/kotlin/com/lambda/config/groups/InteractSettings.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@ import com.lambda.config.SettingGroup
2222
import com.lambda.event.events.TickEvent
2323
import com.lambda.event.events.TickEvent.Companion.ALL_STAGES
2424
import com.lambda.interaction.request.interacting.InteractConfig
25+
import com.lambda.interaction.request.interacting.InteractConfig.AirPlaceMode
26+
import com.lambda.interaction.request.interacting.InteractConfig.PlaceConfirmationMode
2527
import com.lambda.util.NamedEnum
2628

2729
class InteractSettings(
2830
c: Configurable,
2931
baseGroup: NamedEnum
3032
) : SettingGroup(c), InteractConfig {
31-
override val rotate by c.setting("Rotate For Interact", true, "Rotates the player to look at the block when interacting").group(baseGroup).index()
32-
override val sorter by c.setting("Interact Sorter", ActionConfig.SortMode.Tool, "The order in which interactions are performed").group(baseGroup).index()
33-
override val swingHand by c.setting("Swing On Interact", true, "Swings the players hand after interacting").group(baseGroup).index()
34-
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()
35-
override val interactSwingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swingHand }.group(baseGroup).index()
36-
override val interactConfirmationMode by c.setting("Interact Confirmation Mode", InteractConfig.InteractConfirmationMode.InteractThenAwait, "The style of confirmation for interactions").group(baseGroup).index()
33+
override val rotate by c.setting("Rotate For Place", true, "Rotate towards block while placing").group(baseGroup).index()
34+
override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index()
35+
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()
36+
override val sorter by c.setting("Place Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index()
37+
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()
38+
override val placeConfirmationMode by c.setting("Place Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index()
39+
override val maxPendingPlacements by c.setting("Max Pending Placements", 5, 0..30, 1, "The maximum amount of pending placements").group(baseGroup).index()
40+
override val placementsPerTick by c.setting("Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index()
41+
override val swing by c.setting("Swing On Place", true, "Swings the players hand when placing").group(baseGroup).index()
42+
override val swingType by c.setting("Place Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing }.group(baseGroup).index()
43+
override val sounds by c.setting("Place Sounds", true, "Plays the placing sounds").group(baseGroup).index()
3744
}

src/main/kotlin/com/lambda/config/groups/PlaceSettings.kt

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/main/kotlin/com/lambda/context/Automated.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ import com.lambda.config.groups.BuildConfig
2121
import com.lambda.config.groups.EatConfig
2222
import com.lambda.interaction.request.breaking.BreakConfig
2323
import com.lambda.interaction.request.hotbar.HotbarConfig
24-
import com.lambda.interaction.request.interacting.InteractConfig
2524
import com.lambda.interaction.request.inventory.InventoryConfig
26-
import com.lambda.interaction.request.placing.PlaceConfig
25+
import com.lambda.interaction.request.interacting.InteractConfig
2726
import com.lambda.interaction.request.rotating.RotationConfig
2827

2928
interface Automated {
3029
val buildConfig: BuildConfig
3130
val breakConfig: BreakConfig
32-
val placeConfig: PlaceConfig
3331
val interactConfig: InteractConfig
3432
val rotationConfig: RotationConfig
3533
val inventoryConfig: InventoryConfig

src/main/kotlin/com/lambda/interaction/construction/context/InteractContext.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,20 @@ import net.minecraft.util.math.BlockPos
3232
import net.minecraft.util.math.Box
3333
import java.awt.Color
3434

35-
class InteractContext(
35+
data class InteractContext(
3636
override val hitResult: BlockHitResult,
3737
override val rotationRequest: RotationRequest,
3838
override var hotbarIndex: Int,
39+
override val blockPos: BlockPos,
3940
override var cachedState: BlockState,
4041
override val expectedState: BlockState,
41-
val automated: Automated
42+
val placing: Boolean,
43+
val sneak: Boolean,
44+
val currentDirIsValid: Boolean = false,
45+
private val automated: Automated
4246
) : BuildContext(), LogContext, Automated by automated {
43-
private val baseColor = Color(35, 254, 79, 25)
44-
private val sideColor = Color(35, 254, 79, 100)
45-
46-
override val blockPos: BlockPos = hitResult.blockPos
47+
private val baseColor = Color(35, 188, 254, 50)
48+
private val sideColor = Color(35, 188, 254, 100)
4749

4850
override val sorter get() = interactConfig.sorter
4951

@@ -58,19 +60,23 @@ class InteractContext(
5860
}
5961

6062
fun requestDependencies(request: InteractRequest): Boolean {
61-
val hotbarRequest = submit(HotbarRequest(hotbarIndex, request), false)
62-
val validRotation = if (request.interactConfig.rotate) submit(rotationRequest, false).done else true
63+
val hotbarRequest = submit(HotbarRequest(hotbarIndex, this), false)
64+
val validRotation = if (request.interactConfig.rotate) {
65+
submit(rotationRequest, false).done && currentDirIsValid
66+
} else true
6367
return hotbarRequest.done && validRotation
6468
}
6569

6670
override fun getLogContextBuilder(): LogContextBuilder.() -> Unit = {
67-
group("Interaction Context") {
71+
group("Place Context") {
6872
text(blockPos.getLogContextBuilder())
6973
text(hitResult.getLogContextBuilder())
7074
text(rotationRequest.getLogContextBuilder())
7175
value("Hotbar Index", hotbarIndex)
7276
value("Cached State", cachedState)
7377
value("Expected State", expectedState)
78+
value("Sneak", sneak)
79+
value("Current Dir Is Valid", currentDirIsValid)
7480
}
7581
}
7682
}

src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/main/kotlin/com/lambda/interaction/construction/processing/PlacementProcessor.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.interaction.construction.processing
1919

20+
import com.lambda.context.SafeContext
2021
import net.minecraft.block.BlockState
2122
import net.minecraft.util.math.BlockPos
2223

@@ -25,7 +26,19 @@ import net.minecraft.util.math.BlockPos
2526
* optimize how blocks are simulated. Some blocks might only be placeable on certain sides, so it is
2627
* unnecessary to scan all of them, for example.
2728
*/
28-
abstract class PlacementProcessor {
29-
abstract fun acceptsState(state: BlockState): Boolean
30-
abstract fun preProcess(state: BlockState, pos: BlockPos, accumulator: PreProcessingInfoAccumulator)
29+
30+
interface StateProcessor {
31+
fun acceptsState(state: BlockState, targetState: BlockState): Boolean
32+
context(safeContext: SafeContext)
33+
fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState, pos: BlockPos)
34+
}
35+
36+
interface PropertyPreProcessor {
37+
fun acceptsState(targetState: BlockState): Boolean
38+
fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState)
39+
}
40+
41+
interface PropertyPostProcessor {
42+
fun acceptsState(state: BlockState, targetState: BlockState): Boolean
43+
fun PreProcessingInfoAccumulator.preProcess(state: BlockState, targetState: BlockState)
3144
}

0 commit comments

Comments
 (0)