Skip to content

Commit 5a18dd0

Browse files
committed
Fix: Entity utils returning player in list
1 parent d64849d commit 5a18dd0

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.lambda.module.modules.combat
2+
3+
import com.lambda.config.InteractionSettings
4+
import com.lambda.config.RotationSettings
5+
import com.lambda.event.events.RotationEvent
6+
import com.lambda.event.events.TickEvent
7+
import com.lambda.event.listener.SafeListener.Companion.concurrentListener
8+
import com.lambda.event.listener.SafeListener.Companion.listener
9+
import com.lambda.module.Module
10+
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
16+
import net.minecraft.entity.LivingEntity
17+
import net.minecraft.util.Hand
18+
import net.minecraft.world.explosion.Explosion
19+
20+
object CrystalAura : Module(
21+
name = "CrystalAura",
22+
description = "Automatically attacks entities with crystals",
23+
defaultTags = setOf(ModuleTag.COMBAT),
24+
) {
25+
private val page by setting("Page", Page.General)
26+
27+
/* Rotation */
28+
private val rotation = RotationSettings(this) { page == Page.Targeting }
29+
30+
/* Placing */
31+
private val swap by setting("Swap", Hand.MAIN_HAND, "Automatically swap to crystals") { page == Page.Placing }
32+
private val multiPlace by setting("Multi Place", true, "Place multiple crystals") { page == Page.Placing }
33+
private val placeDelay by setting("Place Delay", 0, 0..20, 1, "Delay between crystal placements", unit = "ticks", visibility = { page == Page.Placing })
34+
private val placeRange by setting("Place Range", 5.0, 0.1..7.0, 0.1, "Range to place crystals from the player eyes", visibility = { page == Page.Placing })
35+
private val placeRangeWalls by setting("Place Range Walls", 3.5, 0.1..7.0, 0.1, "Range to place crystals through walls", visibility = { page == Page.Placing })
36+
private val placeMinHealth by setting("Place Min Health", 10.0, 0.0..20.0, 0.5, "Minimum health to place a crystal", visibility = { page == Page.Placing })
37+
private val placeMaxSelfDamage by setting("Place Max Self Damage", 8.0, 0.0..20.0, 0.5, "Maximum self damage to place a crystal", visibility = { page == Page.Placing })
38+
private val placeMinDamage by setting("Place Min Damage", 6.0, 0.0..20.0, 0.5, "Minimum damage to place a crystal", visibility = { page == Page.Placing })
39+
40+
/* Exploding */
41+
private val explode by setting("Explode", true, "Explode crystals") { page == Page.Exploding }
42+
private val explodeDelay by setting("Explode Delay", 0, 0..20, 1, "Delay between crystal explosions", unit = "ticks", visibility = { page == Page.Exploding })
43+
private val explodeRange by setting("Explode Range", 5.0, 0.1..7.0, 0.1, "Range to explode crystals", visibility = { page == Page.Exploding })
44+
private val explodeRangeWalls by setting("Explode Range Walls", 3.5, 0.1..7.0, 0.1, "Range to explode crystals through walls", visibility = { page == Page.Exploding })
45+
private val preventDeath by setting("Prevent Death", true, "Prevent death from crystal explosions", visibility = { page == Page.Exploding })
46+
private val explodeMinDamage by setting("Explode Min Damage", 6.0, 0.0..20.0, 0.5, "Minimum damage to explode a crystal", visibility = { page == Page.Exploding })
47+
private val noWeakness by setting("No Weakness", true, "Switch to a weapon when you have a weakness effect", visibility = { page == Page.Exploding })
48+
49+
/* Rendering */
50+
51+
52+
/* Interaction */
53+
private val interac = InteractionSettings(this) // Canadian interbank meme
54+
55+
private enum class Page {
56+
General, Targeting, Placing, Exploding, Rendering
57+
}
58+
59+
init {
60+
concurrentListener<TickEvent.Pre> {}
61+
62+
/*listener<RotationEvent.Pre> { event ->
63+
event.lookAtEntity(rotation, interac, getClosestEntity<LivingEntity>(player.eyePos, placeRange) ?: return@listener)
64+
}*/
65+
66+
listener<TickEvent.Pre> {
67+
getClosestEntity<LivingEntity>(player.eyePos, 64.0)
68+
}
69+
}
70+
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object EntityUtils {
2828
if (range > 64) getEntities(predicate)
2929
else getFastEntities(pos, range, predicate)
3030

31-
return entities.minByOrNull { it.squaredDistanceTo(pos) } // There is probably a faster way to do this
31+
return entities.minByOrNull { it.squaredDistanceTo(pos) }
3232
}
3333

3434
/**
@@ -78,7 +78,9 @@ object EntityUtils {
7878
for (y in sectionY - chunks..sectionY + chunks) {
7979
for (z in sectionZ - chunks..sectionZ + chunks) {
8080
val section = world.entityManager.cache.findTrackingSection(ChunkSectionPos.asLong(x, y, z)) ?: continue
81-
section.collection.filterIsInstanceTo(entities, predicate)
81+
section.collection.filterIsInstanceTo(entities) { entity ->
82+
entity != player && predicate(entity)
83+
}
8284
}
8385
}
8486
}

0 commit comments

Comments
 (0)