Skip to content

Commit e693158

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 68527c3 + ecae048 commit e693158

File tree

15 files changed

+281
-155
lines changed

15 files changed

+281
-155
lines changed

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import net.fabricmc.loom.api.LoomGradleExtensionAPI
23
import net.fabricmc.loom.task.RemapJarTask
34

45
val modId = property("mod_id").toString()
@@ -8,6 +9,8 @@ val minecraftVersion = property("minecraft_version").toString()
89
val yarnMappings = property("yarn_mappings").toString()
910

1011
val libs = file("libs")
12+
val Project.loom: LoomGradleExtensionAPI
13+
get() = (this as ExtensionAware).extensions.getByName("loom") as LoomGradleExtensionAPI
1114

1215
plugins {
1316
kotlin("jvm") version "1.9.23"

common/src/main/kotlin/com/lambda/event/events/RotationEvent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import com.lambda.interaction.visibilty.VisibilityChecker.findRotation
1111
import com.lambda.threading.runSafe
1212
import com.lambda.util.world.raycast.RayCastUtils.blockResult
1313
import com.lambda.util.world.raycast.RayCastUtils.entityResult
14-
import net.minecraft.entity.LivingEntity
14+
import net.minecraft.entity.Entity
1515
import net.minecraft.util.math.BlockPos
1616
import net.minecraft.util.math.Direction
1717

@@ -37,7 +37,7 @@ abstract class RotationEvent : Event {
3737
fun lookAtEntity(
3838
rotationConfig: IRotationConfig,
3939
interactionConfig: InteractionConfig,
40-
entity: LivingEntity
40+
entity: Entity
4141
) {
4242
runSafe {
4343
findRotation(rotationConfig, interactionConfig, listOf(entity.boundingBox)) {
@@ -68,4 +68,4 @@ abstract class RotationEvent : Event {
6868
}
6969

7070
class Post(val context: RotationContext) : RotationEvent()
71-
}
71+
}

common/src/main/kotlin/com/lambda/module/modules/EntityTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.lambda.module.modules
33
import com.lambda.event.events.TickEvent
44
import com.lambda.event.listener.SafeListener.Companion.listener
55
import com.lambda.module.Module
6-
import com.lambda.util.world.EntityUtils.getClosestEntity
6+
import com.lambda.util.world.WorldUtils.getClosestEntity
77
import net.minecraft.entity.Entity
88

99
object EntityTest : Module(

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@ package com.lambda.module.modules.combat
22

33
import com.lambda.config.InteractionSettings
44
import com.lambda.config.RotationSettings
5-
import com.lambda.event.events.RotationEvent
65
import com.lambda.event.events.TickEvent
76
import com.lambda.event.listener.SafeListener.Companion.concurrentListener
87
import com.lambda.event.listener.SafeListener.Companion.listener
98
import com.lambda.module.Module
109
import com.lambda.module.tag.ModuleTag
11-
import com.lambda.util.Communication.info
12-
import com.lambda.util.combat.Explosion.velocity
13-
import com.lambda.util.world.EntityUtils.getClosestEntity
14-
import com.lambda.util.world.EntityUtils.getFastEntities
15-
import net.minecraft.entity.Entity
10+
import com.lambda.util.world.WorldUtils.getClosestEntity
1611
import net.minecraft.entity.LivingEntity
1712
import net.minecraft.util.Hand
18-
import net.minecraft.world.explosion.Explosion
1913

2014
object CrystalAura : Module(
2115
name = "CrystalAura",

common/src/main/kotlin/com/lambda/module/modules/movement/HorseUtils.kt renamed to common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,42 @@ import com.lambda.event.events.TickEvent
55
import com.lambda.event.listener.SafeListener.Companion.listener
66
import com.lambda.module.Module
77
import com.lambda.module.tag.ModuleTag
8-
import com.lambda.util.world.EntityUtils.getEntities
8+
import com.lambda.util.world.WorldUtils.getEntities
99
import net.minecraft.entity.passive.AbstractHorseEntity
1010
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket
1111

12-
object HorseUtils : Module(
13-
name = "HorseUtils",
14-
description = "Various utilities for horses.",
12+
object EntityControl : Module(
13+
name = "EntityControl",
14+
description = "Control mountable entities",
1515
defaultTags = setOf(ModuleTag.MOVEMENT, ModuleTag.BYPASS)
1616
) {
1717
private val page by setting("Page", Page.General)
1818

1919
/* General */
2020
private val forceMount by setting("Force Mount", true, description = "Attempts to force mount chested entities.", visibility = { page == Page.General })
21-
private val tameHorses by setting("Tame Horses", true, description = "Automatically tames horses (client-side only).", visibility = { page == Page.General })
2221

23-
/* Rendering */
24-
private val showInfo by setting("Show Info", true, description = "Renders information about entities.", visibility = { page == Page.Rendering })
25-
26-
private val theHonses = mutableListOf<AbstractHorseEntity>() // Petah, the honse is here
27-
private val tame: (AbstractHorseEntity) -> Unit = { horse -> if (tameHorses) horse.setHorseFlag(4, true) }
22+
/* Movement */
23+
private val speed by setting("Entity Speed", 2.0, 0.1..10.0, 0.1, description = "Speed for entities.", visibility = { page == Page.Movement })
2824

2925
private enum class Page {
30-
General, Rendering
26+
General, Movement
3127
}
3228

29+
private val theHonses = mutableListOf<AbstractHorseEntity>() // Petah, the honse is here
30+
3331
init {
3432
listener<TickEvent.Pre> {
35-
getEntities(theHonses, iterator = tame)
33+
getEntities(player.pos, 8.0, theHonses, { horse, _ -> horse.setHorseFlag(4, true) })
3634
}
3735

36+
/*listener<MovementEvent.Pre> {
37+
if (!player.isRiding) return@listener
38+
39+
// We can do this because the player movement depends on the entity movement
40+
player.vehicle?.motionX = speed
41+
player.vehicle?.motionZ = speed
42+
}*/
43+
3844
listener<PacketEvent.Send.Pre> { event ->
3945
if (!forceMount) return@listener
4046
if (event.packet !is PlayerInteractEntityC2SPacket) return@listener
@@ -45,5 +51,10 @@ object HorseUtils : Module(
4551

4652
event.cancel()
4753
}
54+
55+
onDisable {
56+
theHonses.forEach { horse -> horse.updateSaddle() }
57+
theHonses.clear()
58+
}
4859
}
4960
}

common/src/main/kotlin/com/lambda/module/modules/movement/RocketExtend.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.lambda.module.modules.movement
22

3+
import com.lambda.context.SafeContext
34
import com.lambda.event.events.PacketEvent
45
import com.lambda.event.listener.SafeListener.Companion.listener
56
import com.lambda.module.Module
67
import com.lambda.module.tag.ModuleTag
78
import com.lambda.threading.runSafe
9+
import com.lambda.util.collections.filterPointer
810
import net.minecraft.entity.projectile.FireworkRocketEntity
911
import net.minecraft.network.packet.c2s.common.CommonPongC2SPacket
1012
import net.minecraft.network.packet.s2c.play.EntitiesDestroyS2CPacket
@@ -25,24 +27,24 @@ object RocketExtend : Module(
2527
if (event.packet is PlayerPositionLookS2CPacket) reset()
2628

2729
if (event.packet is EntitiesDestroyS2CPacket) {
28-
val rockets = event.packet.entityIds.map(world::getEntityById)
29-
.filter { it is FireworkRocketEntity && it.shooter == player }
30-
.mapNotNull { it as? FireworkRocketEntity }
31-
.also { event.packet.entityIds.removeAll(it.map(FireworkRocketEntity::getId).toSet()) }
32-
extendedRockets.addAll(rockets)
30+
event.packet.entityIds.map(world::getEntityById)
31+
.filterPointer(extendedRockets, { _, id -> event.packet.entityIds.removeInt(id) }) { rocket -> rocket.shooter == player }
3332
}
3433
}
3534

3635
listener<PacketEvent.Send.Pre> { event ->
3736
if (event.packet !is CommonPongC2SPacket) return@listener
37+
3838
if (extendedRockets.isEmpty()) {
3939
lastPingTime = System.currentTimeMillis()
4040
return@listener
4141
}
42+
4243
if (System.currentTimeMillis() - lastPingTime > keepAliveTime * 1000) {
4344
reset()
4445
return@listener
4546
}
47+
4648
pingPacket = event.packet
4749
event.cancel()
4850
}
@@ -52,7 +54,7 @@ object RocketExtend : Module(
5254
}
5355
}
5456

55-
private fun reset() = runSafe {
57+
private fun SafeContext.reset() {
5658
extendedRockets.forEach(FireworkRocketEntity::discard)
5759
extendedRockets.clear()
5860
pingPacket?.let(connection::sendPacket)

common/src/main/kotlin/com/lambda/util/collections/Extensions.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ package com.lambda.util.collections
1111
* @param R The target type to filter elements to.
1212
* @param C The type of the destination mutable collection.
1313
* @param destination The mutable collection to which the filtered elements will be added.
14+
* @param iterator The iterator function that processes the filtered elements and their index.
1415
* @param predicate The predicate function that determines whether an element should be included based on its type and other criteria.
1516
*/
1617
inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterPointer(
17-
destination: C? = null,
18-
iterator: (R) -> Unit,
18+
destination: C?,
19+
iterator: (R, Int) -> Unit,
1920
predicate: (R) -> Boolean,
2021
) {
21-
for (element in this) if (element is R && predicate(element)) { iterator(element); destination?.add(element) }
22+
var index = 0
23+
for (element in this) if (element is R && predicate(element)) { iterator(element, index++); destination?.add(element) }
2224
}

common/src/main/kotlin/com/lambda/util/combat/Explosion.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.lambda.util.combat
33
import com.lambda.context.SafeContext
44
import com.lambda.util.math.VecUtils.minus
55
import com.lambda.util.math.VecUtils.times
6-
import com.lambda.util.world.EntityUtils.getFastEntities
6+
import com.lambda.util.world.WorldUtils.getFastEntities
77
import net.minecraft.enchantment.ProtectionEnchantment
88
import net.minecraft.entity.LivingEntity
99
import net.minecraft.util.math.BlockPos

common/src/main/kotlin/com/lambda/util/world/EntityUtils.kt

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

0 commit comments

Comments
 (0)