Skip to content

Commit 4bef752

Browse files
committed
add rotation stage mask, and open requests for all stages in break, place, and hotbar managers
1 parent b94e115 commit 4bef752

File tree

7 files changed

+24
-10
lines changed

7 files changed

+24
-10
lines changed

common/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import com.lambda.config.Configurable
2121
import com.lambda.interaction.request.Priority
2222
import com.lambda.interaction.request.rotation.RotationConfig
2323
import com.lambda.interaction.request.rotation.RotationMode
24-
import kotlin.math.*
24+
import kotlin.math.PI
25+
import kotlin.math.abs
26+
import kotlin.math.cos
27+
import kotlin.math.ln
28+
import kotlin.math.sqrt
2529
import kotlin.random.Random
2630

2731
class RotationSettings(
@@ -37,6 +41,11 @@ class RotationSettings(
3741
/** How many ticks to wait before resetting the rotation */
3842
override val decayTicks by c.setting("Reset Rotation", 3, 1..10, 1, "Ticks before rotation is reset", " ticks") { rotate && vis() }
3943

44+
/**
45+
* At what sub-tick stages rotations can be performed
46+
*/
47+
override val rotationStageMask by c.setting("Rotation Stage Mask", setOf(*TickStage.entries.toTypedArray()), "The sub-tick stages at which rotations can be performed", vis)
48+
4049
/** Whether the rotation is instant */
4150
var instant by c.setting("Instant Rotation", true, "Instantly rotate") { rotate && vis() }
4251

common/src/main/kotlin/com/lambda/interaction/request/RequestHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ abstract class RequestHandler<R : Request>(
6060
openStages.forEach { stage ->
6161
when(stage) {
6262
TickStage.TickStart -> openRequestsFor<TickEvent.Pre>(TickStage.TickStart)
63-
TickStage.PostHotbar -> TODO()
64-
TickStage.PostInteract -> TODO()
63+
TickStage.PostHotbar -> { /*ToDo*/ }
64+
TickStage.PostInteract -> { /*ToDo*/ }
6565
TickStage.PreMovement -> openRequestsFor<MovementEvent.Player.Pre>(TickStage.PreMovement)
6666
TickStage.PostMovement -> openRequestsFor<MovementEvent.Player.Post>(TickStage.PostMovement)
6767
}

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ import net.minecraft.util.math.BlockPos
6868
import net.minecraft.util.math.ChunkSectionPos
6969

7070
object BreakManager : RequestHandler<BreakRequest>(
71-
TickStage.TickStart,
72-
TickStage.PostMovement,
71+
*TickStage.entries.toTypedArray(),
7372
preOpen = { activeRequest?.let { processRequest(it) } },
7473
onOpen = { preEvent() }
7574
), PositionBlocking {

common/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ import com.lambda.threading.runSafe
4040
* @see InGameHudMixin.onTick
4141
*/
4242
object HotbarManager : RequestHandler<HotbarRequest>(
43-
TickStage.TickStart,
44-
TickStage.PostMovement,
43+
*TickStage.entries.toTypedArray(),
4544
postClose = { checkResetSwap() },
4645
onOpen = { preEvent() }
4746
), Loadable {

common/src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ import net.minecraft.util.math.Direction
6868
import net.minecraft.world.GameMode
6969

7070
object PlaceManager : RequestHandler<PlaceRequest>(
71-
TickStage.TickStart,
72-
TickStage.PostMovement,
71+
*TickStage.entries.toTypedArray(),
7372
preOpen = { activeRequest?.let { processRequest(it) } },
7473
onOpen = { preEvent() }
7574
), PositionBlocking {

common/src/main/kotlin/com/lambda/interaction/request/rotation/RotationConfig.kt

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

1818
package com.lambda.interaction.request.rotation
1919

20+
import com.lambda.config.groups.TickStage
2021
import com.lambda.interaction.request.Priority
2122
import com.lambda.interaction.request.RequestConfig
2223

@@ -49,6 +50,11 @@ abstract class RotationConfig(priority: Priority) : RequestConfig<RotationReques
4950
*/
5051
abstract val decayTicks: Int
5152

53+
/**
54+
* The sub-tick stages at which rotations can take place
55+
*/
56+
abstract val rotationStageMask: Set<TickStage>
57+
5258
val rotate: Boolean get() = rotationMode != RotationMode.None
5359

5460
override fun requestInternal(request: RotationRequest) {
@@ -59,6 +65,7 @@ abstract class RotationConfig(priority: Priority) : RequestConfig<RotationReques
5965
override val turnSpeed get() = 360.0
6066
override val keepTicks get() = 1
6167
override val decayTicks get() = 1
68+
override val rotationStageMask = setOf(*TickStage.entries.toTypedArray())
6269
override val rotationMode = mode
6370
}
6471
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/RotationRequest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ data class RotationRequest(
2626
val target: RotationTarget,
2727
val prio: Priority,
2828
val mode: RotationMode,
29+
val rotationConfig: RotationConfig,
2930
var keepTicks: Int = 3,
3031
var decayTicks: Int = 0,
3132
val turnSpeed: () -> Double = { 180.0 },
@@ -37,7 +38,7 @@ data class RotationRequest(
3738
target: RotationTarget,
3839
config: RotationConfig,
3940
speedMultiplier: Double = 1.0
40-
) : this(target, config.priority, config.rotationMode, config.keepTicks, config.decayTicks, config::turnSpeed, speedMultiplier)
41+
) : this(target, config.priority, config.rotationMode, config, config.keepTicks, config.decayTicks, config::turnSpeed, speedMultiplier)
4142

4243
override val done: Boolean get() =
4344
mode == RotationMode.None || runSafe {

0 commit comments

Comments
 (0)