Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
500139c
first test for crystal aura
emyfops Nov 10, 2024
ca69b2c
Merge branch 'master' into feature/combat
emyfops Jan 5, 2025
ca63e6d
crystal aura
emyfops Jan 5, 2025
f4cee65
better checks and visualization
emyfops Jan 6, 2025
0b6eff3
Update CrystalAura.kt
emyfops Jan 8, 2025
50fec70
Merge branch 'master' into feature/combat
emyfops Jan 9, 2025
2781a5e
Merge branch 'master' into feature/combat
emyfops Jan 9, 2025
743911b
Merge branch 'master' into feature/combat
Avanatiker Jan 9, 2025
63f358f
removed caura delay check
emyfops Jan 9, 2025
e93d412
inlined killaura target
emyfops Jan 9, 2025
f7f8794
feat: tps clock
emyfops Jan 9, 2025
ac67df8
Merge branch 'feature/combat' of https://github.com/Avanatiker/NeoLam…
emyfops Jan 9, 2025
7631fa4
Rework ServerTPS
Avanatiker Jan 9, 2025
9329c6f
Fix esp builder bounding box not shifted by position
Avanatiker Jan 9, 2025
b03a3d9
Add RotationMode.NONE
Avanatiker Jan 9, 2025
4341b84
ESP builder rename
Avanatiker Jan 9, 2025
d262d00
Dynamic targeting range
Avanatiker Jan 9, 2025
2ed4623
Use disconnect to clean up server tps
Avanatiker Jan 9, 2025
89ac694
Crystal Aura rewrite
Avanatiker Jan 9, 2025
5310b56
Troll PvPers
Avanatiker Jan 9, 2025
bcb6546
Get state a bit later
Avanatiker Jan 9, 2025
b13b9ea
Merge branch 'master' into feature/combat
Avanatiker Jan 9, 2025
6791554
Merge branch 'master' into feature/combat
Avanatiker Jan 10, 2025
8be6c5f
Fix rotation validity checks and crystal placement
Avanatiker Jan 10, 2025
31c2ff8
Explosion targeting
Avanatiker Jan 10, 2025
e9d244c
Merge branch 'master' into feature/combat
Avanatiker Jan 10, 2025
178f35a
Fix missing merge stuff
Avanatiker Jan 10, 2025
9dd364a
coordinate hud module
emyfops Jan 10, 2025
4e391c0
ref: fakeplayer nil id
emyfops Jan 10, 2025
45ca49f
ref: coordinate hud
emyfops Jan 11, 2025
da168c0
Fix LimitedDecayQueue MutableIterator
Avanatiker Jan 12, 2025
1bba52a
CrystalAura exploding
Avanatiker Jan 12, 2025
5d7a706
fix: fake player targeting
emyfops Jan 12, 2025
ac6054b
ref: use mc's reach
emyfops Jan 12, 2025
4d7df22
ref: raycast arguments
emyfops Jan 12, 2025
bd40575
disable fake player on shutdown
emyfops Jan 12, 2025
f218933
clear caura on disable
emyfops Jan 12, 2025
3af2f41
fix: kill aura reach
emyfops Jan 12, 2025
156d16c
Disable FakePlayer on disconnect
Avanatiker Jan 13, 2025
64218f1
Timer (for delays and periodic actions)
blade1234567 Jan 15, 2025
3fd3626
FakePlayer crash fix
blade1234567 Jan 16, 2025
ae4e40f
async crystal aura
blade1234567 Jan 17, 2025
f38db93
Merge branch 'master' into feature/combat
emyfops Jan 17, 2025
d5c51e4
idk what happened
emyfops Jan 17, 2025
a9ab201
Lightfast CrystalAura
blade1234567 Jan 19, 2025
fd89186
OP Predictions
blade1234567 Jan 19, 2025
d72809c
Rotation & refactor
blade1234567 Jan 19, 2025
cb85548
Timer refactor
blade1234567 Jan 20, 2025
1c710ae
Fixed & improved predictions
blade1234567 Jan 20, 2025
bc19659
Cleaned up & improved predictions
blade1234567 Jan 20, 2025
0fbd682
Accurate Timer with duration type
Avanatiker Jan 21, 2025
478dd20
Request system, Rotation request rework, HotbarManager
blade1234567 Feb 2, 2025
6c9993a
Remove deprecated rotation fix and fix wrong hit check
Avanatiker Feb 4, 2025
e38cdb3
Use proper update event
Avanatiker Feb 4, 2025
b7c9113
Make requests data classes so we can debug them better
Avanatiker Feb 4, 2025
82396e2
Merge branch 'master' into feature/combat
Avanatiker Feb 5, 2025
ebe0bd4
Configuration delegation
Avanatiker Feb 6, 2025
d22b73d
Fix default values and visibility
Avanatiker Feb 6, 2025
3876523
UpdatableLazy Kdocs
Avanatiker Feb 6, 2025
e60615f
Some fixes
Avanatiker Feb 6, 2025
fca9ae2
Decision making on tick post
Avanatiker Feb 6, 2025
f70179f
Add build config to simulator
Avanatiker Feb 6, 2025
42c1c0e
Task duration
Avanatiker Feb 6, 2025
d95eda5
Fix player collision check for simulation
Avanatiker Feb 6, 2025
30cc651
Surface scan margin
Avanatiker Feb 6, 2025
4d63c79
Move breaking into build task. Item pickup strategy still missing
Avanatiker Feb 7, 2025
1614f38
Distinct block update event for server updates
Avanatiker Feb 7, 2025
50654c6
Fix stuff
Avanatiker Feb 7, 2025
51db458
Revert to old surface scan function as new one was flawed and it hurts
Avanatiker Feb 7, 2025
48f1144
Propagating Blueprint
Avanatiker Feb 7, 2025
4adfb18
Nullable withdrawal or deposit tasks
Avanatiker Feb 7, 2025
505ba1d
Sort build results by rotation distance
Avanatiker Feb 7, 2025
db4a568
Cleanup
Avanatiker Feb 7, 2025
6bd7d89
Indicate non raycasting rotation. Not yet possible bc of internal cas…
Avanatiker Feb 7, 2025
f181bd4
Baritone movement fix, surface scan for rotation dsl
blade1234567 Feb 7, 2025
a7b7d63
Fix BuildTask context build timing, block inaccurate pathing positions
Avanatiker Feb 7, 2025
75965ba
FakePlayer refactor, ca speed debug
blade1234567 Feb 8, 2025
48fc1d7
Merge remote-tracking branch 'origin/feature/combat' into feature/combat
blade1234567 Feb 8, 2025
1e73519
resettableLazy() -> updatableLazy()
Avanatiker Feb 7, 2025
7ca5a36
Bring back placement blocking by entities result
Avanatiker Feb 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accurate Timer with duration type
  • Loading branch information
Avanatiker committed Jan 21, 2025
commit 0fbd682426cb687a0ce3289a7ede8a8fd64cd5c6
228 changes: 116 additions & 112 deletions common/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.lambda.module.tag.ModuleTag
import com.lambda.threading.runSafe
import com.lambda.threading.runSafeGameScheduled
import com.lambda.util.BlockUtils.blockState
import com.lambda.util.SimpleTimer
import com.lambda.util.Timer
import com.lambda.util.combat.CombatUtils.crystalDamage
import com.lambda.util.math.*
import com.lambda.util.math.MathUtils.ceilToInt
Expand All @@ -55,6 +55,8 @@ import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.*
import kotlin.concurrent.fixedRateTimer
import kotlin.math.max
import kotlin.time.DurationUnit
import kotlin.time.toDuration

object CrystalAura : Module(
name = "CrystalAura",
Expand All @@ -69,7 +71,7 @@ object CrystalAura : Module(
private val placeDelay by setting("Place Delay", 50L, 0L..1000L, 5L, "Delay between placement attempts", " ms") { page == Page.General }
private val explodeDelay by setting("Explode Delay", 10L, 0L..1000L, 5L, "Delay between explosion attempts", " ms") { page == Page.General }
private val updateMode by setting("Update Mode", UpdateMode.Async) { page == Page.General }
private val updateDelaySetting by setting("Update Delay", 25L, 5L..200L, 5L) { page == Page.General && updateMode == UpdateMode.Async }
private val updateDelaySetting by setting("Update Delay", 25L, 5L..200L, 5L, unit = " ms") { page == Page.General && updateMode == UpdateMode.Async }
private val maxUpdatesPerFrame by setting("Max Updates Per Frame", 5, 1..20, 1) { page == Page.General && updateMode == UpdateMode.Async }
private val updateDelay get() = if (updateMode == UpdateMode.Async) updateDelaySetting else 0L
private val debug by setting("Debug", false) { page == Page.General }
Expand Down Expand Up @@ -102,13 +104,13 @@ object CrystalAura : Module(
private val actionMap = mutableMapOf<ActionType, MutableList<Opportunity>>()
private var actionType = ActionType.Normal

private val updateTimer = SimpleTimer()
private val updateTimer = Timer()
private var updatesThisFrame = 0

private val placeTimer = SimpleTimer()
private val explodeTimer = SimpleTimer()
private val placeTimer = Timer()
private val explodeTimer = Timer()

private val predictionTimer = SimpleTimer()
private val predictionTimer = Timer()
private var lastEntityId = 0

private val collidingOffsets = mutableListOf<BlockPos>().apply {
Expand Down Expand Up @@ -284,119 +286,120 @@ object CrystalAura : Module(
player.swingHand(Hand.MAIN_HAND)
}

private fun SafeContext.updateBlueprint(target: LivingEntity) = updateTimer.runIfPassed(updateDelay) {
resetBlueprint()

// Build damage info
fun info(
pos: BlockPos, target: LivingEntity,
blocked: Boolean,
crystal: EndCrystalEntity? = null
): Opportunity? {
val crystalPos = pos.crystalPosition

// Calculate the damage to the target from the explosion of the crystal
val targetDamage = crystalDamage(crystalPos, target)
if (targetDamage < minTargetDamage) return null

// Calculate the self-damage for the player
val selfDamage = crystalDamage(crystalPos, player)
if (selfDamage > maxSelfDamage) return null

if (priorityMode == Priority.Advantage && priorityMode.factor(targetDamage, selfDamage) < minDamageAdvantage) return null

// Return the calculated damage info if conditions are met
return Opportunity(
pos.toImmutable(),
targetDamage,
selfDamage,
blocked,
crystal
)
}
private fun SafeContext.updateBlueprint(target: LivingEntity) =
updateTimer.runIfPassed(updateDelay.toDuration(DurationUnit.MILLISECONDS)) {
resetBlueprint()

// Extra checks for placement, because you may explode but not place in special cases(crystal in the air)
@Suppress("ConvertArgumentToSet")
fun placeInfo(
pos: BlockPos,
target: LivingEntity
): Opportunity? {
// Check if crystals could be placed on the base block
val state = pos.blockState(world)
val isOfBlock = state.isOf(Blocks.OBSIDIAN) || state.isOf(Blocks.BEDROCK)
if (!isOfBlock) return null

// Check if the block above is air and other conditions for valid crystal placement
val above = pos.up()
if (!world.isAir(above)) return null
if (oldPlace && !world.isAir(above.up())) return null

// Exclude blocks blocked by entities
val crystalBox = pos.crystalBox

val entitiesNearby = fastEntitySearch<Entity>(3.5, pos)
val crystals = entitiesNearby.filterIsInstance<EndCrystalEntity>() as MutableList
val otherEntities = entitiesNearby - crystals + player

if (otherEntities.any {
it.boundingBox.intersects(crystalBox)
}) return null

// Placement collision checks
val baseCrystal = crystals.firstOrNull {
it.baseBlockPos == pos
// Build damage info
fun info(
pos: BlockPos, target: LivingEntity,
blocked: Boolean,
crystal: EndCrystalEntity? = null
): Opportunity? {
val crystalPos = pos.crystalPosition

// Calculate the damage to the target from the explosion of the crystal
val targetDamage = crystalDamage(crystalPos, target)
if (targetDamage < minTargetDamage) return null

// Calculate the self-damage for the player
val selfDamage = crystalDamage(crystalPos, player)
if (selfDamage > maxSelfDamage) return null

if (priorityMode == Priority.Advantage && priorityMode.factor(targetDamage, selfDamage) < minDamageAdvantage) return null

// Return the calculated damage info if conditions are met
return Opportunity(
pos.toImmutable(),
targetDamage,
selfDamage,
blocked,
crystal
)
}

val crystalPlaceBox = pos.crystalPlaceHitBox
val blocked = baseCrystal == null && crystals.any {
it.boundingBox.intersects(crystalPlaceBox)
}
// Extra checks for placement, because you may explode but not place in special cases(crystal in the air)
@Suppress("ConvertArgumentToSet")
fun placeInfo(
pos: BlockPos,
target: LivingEntity
): Opportunity? {
// Check if crystals could be placed on the base block
val state = pos.blockState(world)
val isOfBlock = state.isOf(Blocks.OBSIDIAN) || state.isOf(Blocks.BEDROCK)
if (!isOfBlock) return null

// Check if the block above is air and other conditions for valid crystal placement
val above = pos.up()
if (!world.isAir(above)) return null
if (oldPlace && !world.isAir(above.up())) return null

// Exclude blocks blocked by entities
val crystalBox = pos.crystalBox

val entitiesNearby = fastEntitySearch<Entity>(3.5, pos)
val crystals = entitiesNearby.filterIsInstance<EndCrystalEntity>() as MutableList
val otherEntities = entitiesNearby - crystals + player

if (otherEntities.any {
it.boundingBox.intersects(crystalBox)
}) return null

// Placement collision checks
val baseCrystal = crystals.firstOrNull {
it.baseBlockPos == pos
}

return info(
pos,
target,
blocked,
baseCrystal
)
}
val crystalPlaceBox = pos.crystalPlaceHitBox
val blocked = baseCrystal == null && crystals.any {
it.boundingBox.intersects(crystalPlaceBox)
}

val range = max(placeRange, explodeRange) + 1
val rangeInt = range.ceilToInt()
return info(
pos,
target,
blocked,
baseCrystal
)
}

// Iterate through existing crystals
val crystalBase = BlockPos.Mutable()
fastEntitySearch<EndCrystalEntity>(range).forEach { crystal ->
crystalBase.set(crystal.x, crystal.y - 0.5, crystal.z)
damage += info(crystalBase, target, false, crystal) ?: return@forEach
}
val range = max(placeRange, explodeRange) + 1
val rangeInt = range.ceilToInt()

// Iterate through possible place positions and calculate damage information for each
BlockPos.iterateOutwards(player.blockPos.up(), rangeInt, rangeInt, rangeInt).forEach { pos ->
if (pos distSq player.pos > range * range) return@forEach
if (damage.any { info -> info.blockPos == pos }) return@forEach
// Iterate through existing crystals
val crystalBase = BlockPos.Mutable()
fastEntitySearch<EndCrystalEntity>(range).forEach { crystal ->
crystalBase.set(crystal.x, crystal.y - 0.5, crystal.z)
damage += info(crystalBase, target, false, crystal) ?: return@forEach
}

damage += placeInfo(pos, target) ?: return@forEach
}
// Iterate through possible place positions and calculate damage information for each
BlockPos.iterateOutwards(player.blockPos.up(), rangeInt, rangeInt, rangeInt).forEach { pos ->
if (pos distSq player.pos > range * range) return@forEach
if (damage.any { info -> info.blockPos == pos }) return@forEach

// Map opportunities
damage.forEach {
blueprint[it.blockPos] = it
}
damage += placeInfo(pos, target) ?: return@forEach
}

// Map opportunities
damage.forEach {
blueprint[it.blockPos] = it
}

// Associate by actions
blueprint.values.forEach { opportunity ->
actionMap.getOrPut(opportunity.actionType, ::mutableListOf) += opportunity
// Associate by actions
blueprint.values.forEach { opportunity ->
actionMap.getOrPut(opportunity.actionType, ::mutableListOf) += opportunity

if (opportunity.actionType.priority > actionType.priority) {
actionType = opportunity.actionType
if (opportunity.actionType.priority > actionType.priority) {
actionType = opportunity.actionType
}
}
}

// Select best action
activeOpportunity = actionMap[actionType]?.maxByOrNull {
it.priority
// Select best action
activeOpportunity = actionMap[actionType]?.maxByOrNull {
it.priority
}
}
}

private fun resetBlueprint() {
blueprint.clear()
Expand Down Expand Up @@ -430,10 +433,10 @@ object CrystalAura : Module(
* Places the crystal on [blockPos]
* @return Whether the delay passed, null if the interaction failed
*/
fun place() = placeTimer.runSafeIfPassed(placeDelay) {
fun place() = placeTimer.runSafeIfPassed(placeDelay.toDuration(DurationUnit.MILLISECONDS)) {
placeInternal(blockPos, Hand.MAIN_HAND)

if (prediction.onPlace) predictionTimer.runIfNotPassed(packetLifetime, false) {
if (prediction.onPlace) predictionTimer.runIfNotPassed(packetLifetime.toDuration(DurationUnit.MILLISECONDS), false) {
val last = lastEntityId

repeat(placePredictions) {
Expand All @@ -451,12 +454,13 @@ object CrystalAura : Module(
* Explodes a crystal that is on [blockPos]
* @return Whether the delay passed, null if the interaction failed or no crystal found
*/
fun explode() = explodeTimer.runSafeIfPassed(explodeDelay) {
crystal?.let { crystal ->
explodeInternal(crystal.id)
explodeTimer.reset()
fun explode() =
explodeTimer.runSafeIfPassed(explodeDelay.toDuration(DurationUnit.MILLISECONDS)) {
crystal?.let { crystal ->
explodeInternal(crystal.id)
explodeTimer.reset()
}
}
}

fun buildDebug() {
withVertexTransform(buildWorldProjection(blockPos.crystalPosition, 0.4, Matrices.ProjRotationMode.TO_CAMERA)) {
Expand Down
Loading
Loading