[1.20.4] Feat: Fast vector by emyfops · Pull Request #46 · lambda-client/lambda · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 7 additions & 26 deletions common/src/main/kotlin/com/lambda/config/groups/Targeting.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.lambda.core.annotations

import kotlin.annotation.AnnotationTarget.*

@RequiresOptIn(
message = "Only use if you know what you are doing, no support will be provided whatsoever, use at your own risk",
)
@Target(CLASS, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER, TYPEALIAS)
internal annotation class InternalApi
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import com.lambda.config.groups.InteractionSettings
import com.lambda.config.groups.RotationSettings
import com.lambda.event.events.TickEvent
import com.lambda.event.listener.SafeListener.Companion.concurrentListener
import com.lambda.event.listener.SafeListener.Companion.listener
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.world.WorldUtils.getClosestEntity
import net.minecraft.entity.LivingEntity
import net.minecraft.util.Hand

object CrystalAura : Module(
Expand Down Expand Up @@ -56,9 +53,5 @@ object CrystalAura : Module(
/*listener<RotationEvent.Pre> { event ->
event.lookAtEntity(rotation, interac, getClosestEntity<LivingEntity>(player.eyePos, placeRange) ?: return@listener)
}*/

listener<TickEvent.Pre> {
getClosestEntity<LivingEntity>(player.eyePos, 64.0)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.lambda.module.modules.debug

import com.lambda.event.events.RenderEvent
import com.lambda.event.listener.SafeListener.Companion.listener
import com.lambda.graphics.renderer.esp.builders.build
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.world.blockSearch
import net.minecraft.block.Blocks
import net.minecraft.util.math.Vec3i
import java.awt.Color

object BlockTest : Module(
name = "BlockTest",
description = "BlockTest",
defaultTags = setOf(ModuleTag.DEBUG),
) {
private val rangeX by setting("Range X", 5, 1..7, 1, "Range X")
private val rangeY by setting("Range Y", 5, 1..7, 1, "Range Y")
private val rangeZ by setting("Range Z", 5, 1..7, 1, "Range Z")
private val stepX by setting("Step X", 1, 1..7, 1, "Step X")
private val stepY by setting("Step Y", 1, 1..7, 1, "Step Y")
private val stepZ by setting("Step Z", 1, 1..7, 1, "Step Z")

private val range: Vec3i
get() = Vec3i(rangeX, rangeY, rangeZ)

private val step: Vec3i
get() = Vec3i(stepX, stepY, stepZ)

private val filledColor = Color(100, 150, 255, 128)
private val outlineColor = Color(100, 150, 255, 51)

init {
listener<RenderEvent.StaticESP> {
blockSearch(range, step) { _, state ->
state.isOf(Blocks.DIAMOND_BLOCK)
}.forEach { (pos, state) ->
state.getOutlineShape(world, pos).boundingBoxes.forEach { box ->
it.renderer.build(box.offset(pos), filledColor, outlineColor)
}
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.lambda.graphics.renderer.esp.builders.build
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.math.ColorUtils.setAlpha
import com.lambda.util.world.WorldUtils.getClosestEntity
import com.lambda.util.world.entitySearch
import net.minecraft.entity.LivingEntity
import net.minecraft.util.math.Box
import java.awt.Color
Expand All @@ -29,12 +29,14 @@ object RenderTest : Module(

init {
listener<RenderEvent.DynamicESP> {
val entity = getClosestEntity<LivingEntity>(player.pos, 8.0) ?: return@listener
it.renderer.build(entity.dynamicBox, filledColor, outlineColor)
entitySearch<LivingEntity>(8.0)
.forEach { entity ->
it.renderer.build(entity.dynamicBox, filledColor, outlineColor)
}
}

listener<RenderEvent.StaticESP> {
it.renderer.build(Box.of(player.pos, 0.3, 0.3, 0.3), filledColor, outlineColor)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.lambda.event.events.TickEvent
import com.lambda.event.listener.SafeListener.Companion.listener
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.world.WorldUtils.getEntities
import com.lambda.util.world.entitySearch
import net.minecraft.entity.passive.AbstractHorseEntity
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket

Expand All @@ -15,38 +15,23 @@ object EntityControl : Module(
description = "Control mountable entities",
defaultTags = setOf(ModuleTag.MOVEMENT)
) {
private val page by setting("Page", Page.GENERAL)

/* General */
private val forceMount by setting("Force Mount", true, description = "Attempts to force mount chested entities.", visibility = { page == Page.GENERAL }).apply {
private val forceMount by setting("Force Mount", true, description = "Attempts to force mount chested entities.").apply {
onValueChange { _, _ ->
horses.forEach { horse -> horse.updateSaddle() }
resetMounts()
}
}

/* Movement */
private val speed by setting("Entity Speed", 2.0, 0.1..10.0, 0.1, description = "Speed for entities.", visibility = { page == Page.MOVEMENT })

private enum class Page {
GENERAL, MOVEMENT
}

private val horses = mutableListOf<AbstractHorseEntity>()
private val modified = mutableSetOf<AbstractHorseEntity>()

init {
listener<TickEvent.Pre> {
if (forceMount) {
getEntities(player.pos, 8.0, horses, { horse, _ -> horse.setHorseFlag(4, true) })
}
}

/*listener<MovementEvent.Pre> {
if (!player.isRiding) return@listener
if (!forceMount) return@listener

// We can do this because the player movement depends on the entity movement
player.vehicle?.motionX = speed
player.vehicle?.motionZ = speed
}*/
entitySearch<AbstractHorseEntity>(8.0)
.forEach {
it.setHorseFlag(4, true)
modified.add(it)
}
}

listener<PacketEvent.Send.Pre> { event ->
if (!forceMount) return@listener
Expand All @@ -60,7 +45,11 @@ object EntityControl : Module(
}

onDisable {
horses.clear()
resetMounts()
}
}

private fun resetMounts() {
modified.forEach { it.updateSaddle() }
}
}
24 changes: 7 additions & 17 deletions common/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.Nameable
import com.lambda.util.player.MovementUtils.addSpeed
import com.lambda.util.player.MovementUtils.buildMovementInput
import com.lambda.util.player.MovementUtils.calcMoveYaw
import com.lambda.util.player.MovementUtils.handledByBaritone
import com.lambda.util.player.MovementUtils.isInputting
import com.lambda.util.player.MovementUtils.mergeFrom
import com.lambda.util.player.MovementUtils.motionY
import com.lambda.util.player.MovementUtils.moveDelta
import com.lambda.util.player.MovementUtils.newMovementInput
import com.lambda.util.player.MovementUtils.roundedForward
import com.lambda.util.player.MovementUtils.roundedStrafing
import com.lambda.util.player.MovementUtils.setSpeed
import com.lambda.util.extension.contains
import com.lambda.util.world.WorldUtils.getFastEntities
import com.lambda.util.world.entitySearch
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.decoration.ArmorStandEntity
import net.minecraft.entity.vehicle.BoatEntity
Expand Down Expand Up @@ -134,22 +132,14 @@ object Speed : Module(

var boostAmount = 0.0

getFastEntities<LivingEntity>(
player.pos, 3.0,
predicate = { player.boundingBox.expand(1.0) in it.boundingBox && it !is ArmorStandEntity },
iterator = { e, _ ->
val colliding = player.boundingBox in e.boundingBox
val multiplier = if (colliding) grimCollideMultiplier else 1.0
boostAmount += 0.08 * grimEntityBoost * multiplier
}
)
boostAmount += entitySearch<LivingEntity>(3.0) {
player.boundingBox.expand(1.0) in it.boundingBox && it !is ArmorStandEntity
}.sumOf { 0.08 * grimEntityBoost }

if (grimBoatBoost > 0.0) {
getFastEntities<BoatEntity>(
player.pos, 4.0,
predicate = { player.boundingBox in it.boundingBox.expand(0.01) },
iterator = { _, _ -> boostAmount += grimBoatBoost }
)
boostAmount += entitySearch<BoatEntity>(4.0) {
player.boundingBox in it.boundingBox.expand(0.01)
}.sumOf { grimBoatBoost }
}

addSpeed(boostAmount)
Expand Down
51 changes: 42 additions & 9 deletions common/src/main/kotlin/com/lambda/util/collections/Extensions.kt
Loading