Skip to content

Commit ae4e40f

Browse files
committed
async crystal aura
1 parent 3fd3626 commit ae4e40f

File tree

9 files changed

+195
-318
lines changed

9 files changed

+195
-318
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/blueprint/Blueprint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.lambda.interaction.construction.verify.TargetState
2121
import com.lambda.util.BlockUtils.blockPos
2222
import com.lambda.util.collections.ResettableLazy
2323
import com.lambda.util.extension.Structure
24-
import com.lambda.util.math.VecUtils.blockPos
24+
import com.lambda.util.math.VecUtils.roundedBlockPos
2525
import net.minecraft.structure.StructureTemplate
2626
import net.minecraft.util.math.*
2727

@@ -47,7 +47,7 @@ abstract class Blueprint {
4747
return Vec3d(d, e, f)
4848
}
4949

50-
fun isOutOfBounds(vec3d: Vec3d): Boolean = bounds.value?.contains(vec3d.blockPos) == false
50+
fun isOutOfBounds(vec3d: Vec3d): Boolean = bounds.value?.contains(vec3d.roundedBlockPos) == false
5151

5252
val center get() = bounds.value?.center?.blockPos
5353

common/src/main/kotlin/com/lambda/interaction/material/container/containers/StashContainer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package com.lambda.interaction.material.container.containers
1919

2020
import com.lambda.interaction.material.StackSelection
2121
import com.lambda.interaction.material.container.MaterialContainer
22-
import com.lambda.util.math.VecUtils.blockPos
22+
import com.lambda.util.math.VecUtils.roundedBlockPos
2323
import com.lambda.util.text.buildText
2424
import com.lambda.util.text.highlighted
2525
import com.lambda.util.text.literal
@@ -36,7 +36,7 @@ data class StashContainer(
3636

3737
override val description = buildText {
3838
literal("Stash at ")
39-
highlighted(pos.center.blockPos.toShortString())
39+
highlighted(pos.center.roundedBlockPos.toShortString())
4040
}
4141

4242
override fun materialAvailable(selection: StackSelection): Int =

common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.lambda.context.SafeContext
2323
import com.lambda.interaction.RotationManager
2424
import com.lambda.interaction.construction.verify.ScanMode
2525
import com.lambda.interaction.construction.verify.SurfaceScan
26+
import com.lambda.interaction.rotation.Rotation.Companion.dist
2627
import com.lambda.interaction.rotation.Rotation.Companion.rotationTo
2728
import com.lambda.interaction.rotation.RotationRequest
2829
import com.lambda.module.modules.client.TaskFlowModule
@@ -133,16 +134,16 @@ object VisibilityChecker {
133134
}
134135

135136
// Way stable
136-
/*validHits.minByOrNull { eye.rotationTo(it.key) dist currentRotation }?.let { closest ->
137-
return RotationContext(eye.rotationTo(closest.key), rotationConfig, closest.value, verify)
138-
}*/
137+
validHits.minByOrNull { eye.rotationTo(it.key) dist currentRotation }?.let { closest ->
138+
return RotationRequest(eye.rotationTo(closest.key), rotationConfig, closest.value, verify)
139+
}
139140

140-
validHits.keys.optimum?.let { optimum ->
141+
/*validHits.keys.optimum?.let { optimum ->
141142
validHits.minByOrNull { optimum distSq it.key }?.let { closest ->
142143
val optimumRotation = eye.rotationTo(closest.key)
143144
return RotationRequest(optimumRotation, rotationConfig, closest.value, verify)
144145
}
145-
}
146+
}*/
146147

147148
return null
148149
}

common/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt

Lines changed: 173 additions & 302 deletions
Large diffs are not rendered by default.

common/src/main/kotlin/com/lambda/threading/Threading.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ inline fun runGameScheduled(crossinline block: () -> Unit) {
126126
*
127127
* @param block The task to be executed on the game's main thread within a safe context.
128128
*/
129-
inline fun runSafeGameConcurrent(crossinline block: SafeContext.() -> Unit) {
129+
inline fun runSafeGameScheduled(crossinline block: SafeContext.() -> Unit) {
130130
runGameScheduled { runSafe { block() } }
131131
}
132132

common/src/main/kotlin/com/lambda/util/Communication.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import com.lambda.module.Module
2828
import com.lambda.module.ModuleRegistry
2929
import com.lambda.module.modules.client.GuiSettings
3030
import com.lambda.threading.runSafe
31-
import com.lambda.threading.runSafeGameConcurrent
31+
import com.lambda.threading.runSafeGameScheduled
3232
import com.lambda.util.StringUtils.capitalize
3333
import com.lambda.util.text.*
3434
import net.minecraft.client.toast.SystemToast
@@ -74,7 +74,7 @@ object Communication {
7474
buildText {
7575
text(this@toast.source(logLevel, color = Color.YELLOW))
7676
}.let { title ->
77-
runSafeGameConcurrent {
77+
runSafeGameScheduled {
7878
mc.toastManager.add(logLevel.toast(title, message))
7979
}
8080
}
@@ -99,7 +99,7 @@ object Communication {
9999
text(this@log.source(logLevel, source, textSource))
100100
text(message)
101101
}.let { log ->
102-
runSafeGameConcurrent {
102+
runSafeGameScheduled {
103103
player.sendMessage(log)
104104
}
105105
}

common/src/main/kotlin/com/lambda/util/math/VecUtils.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ import kotlin.math.roundToInt
2525
import kotlin.math.sqrt
2626

2727
object VecUtils {
28-
val Vec3d.blockPos: BlockPos
28+
val Vec3d.roundedBlockPos: BlockPos
2929
get() = BlockPos(x.roundToInt(), y.roundToInt(), z.roundToInt())
3030

31+
val Vec3d.flooredBlockPos: BlockPos
32+
get() = BlockPos.ofFloored(this)
33+
3134
val Vec3i.vec3d get() = Vec3d.of(this)
3235

3336
fun BlockPos.getHitVec(side: Direction) =

common/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ object RayCastUtils {
4040

4141
fun SafeContext.rayCast(
4242
start: Vec3d,
43-
rotation: Vec3d,
43+
direction: Vec3d,
4444
reach: Double,
4545
mask: RayCastMask,
4646
fluids: Boolean = false,
4747
): HitResult? {
48-
val vec = rotation.multiply(reach)
48+
val vec = direction.multiply(reach)
4949
val point = start.add(vec)
5050

5151
val block = run {

common/src/main/resources/lambda.accesswidener

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ accessible field net/minecraft/network/ClientConnection packetsSentCounter I
6363
accessible field net/minecraft/network/ClientConnection packetsReceivedCounter I
6464
accessible field net/minecraft/network/packet/c2s/login/LoginKeyC2SPacket encryptedSecretKey [B
6565
accessible field net/minecraft/network/packet/c2s/login/LoginKeyC2SPacket nonce [B
66+
accessible method net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket <init> (IZLnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler;)V
67+
accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket ATTACK Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler;
6668

6769
# Other
6870
accessible field net/minecraft/world/explosion/Explosion behavior Lnet/minecraft/world/explosion/ExplosionBehavior;

0 commit comments

Comments
 (0)