@@ -43,6 +43,7 @@ import net.minecraft.util.Hand
4343import net.minecraft.util.math.BlockPos
4444import net.minecraft.util.math.Box
4545import net.minecraft.util.math.Direction
46+ import net.minecraft.util.math.Vec3d
4647import java.awt.Color
4748import java.time.Instant
4849
@@ -93,11 +94,7 @@ object CrystalAura : Module(
9394 }
9495
9596 private fun SafeContext.validPositions (target : LivingEntity ): Sequence <BlockPos > {
96- return blockSearch(
97- range = placing.reach.toInt(),
98- step = minSeparation, // Need to change this behavior
99- pos = player.blockPos,
100- ) { pos, _ -> canPlace(pos, target) }
97+ return blockSearch(range = placing.reach.toInt()) { pos, _ -> canPlace(pos, target) }
10198 .keys.asSequence()
10299 .sortedByDescending { placeMethod.sorted(this , target, it.up()) } // The explosion source of the crystal is not at its base
103100 }
@@ -107,6 +104,8 @@ object CrystalAura : Module(
107104 // and the player and the place position is <= to the placing range
108105 return player dist target <= placing.reach &&
109106 player dist pos <= placing.reach &&
107+ // Checks if the position is within the player hitbox
108+ ! player.boundingBox.intersects(Box .of(pos.up().toCenterPos(), 1.0 , 2.0 , 1.0 )) &&
110109 // Checks if the support block is either obsidian or bedrock
111110 (pos.blockState(world).isOf(Blocks .OBSIDIAN )
112111 || pos.blockState(world).isOf(Blocks .BEDROCK )) &&
@@ -125,6 +124,8 @@ object CrystalAura : Module(
125124 // if (multiPlace) !placedCrystal.any { (crystalPos, _) -> pos.up() == crystalPos } else true
126125 }
127126
127+ private val testRender = mutableListOf<BlockPos >()
128+
128129
129130 init {
130131 rotate(
@@ -133,9 +134,13 @@ object CrystalAura : Module(
133134 onUpdate {
134135 if (! rotate) return @onUpdate null
135136
136- val blockpos = validPositions(
137+ val poss = validPositions(
137138 target ? : return @onUpdate null
138- ).firstOrNull() ? : return @onUpdate null
139+ )
140+
141+ testRender.addAll(poss.take(3 ))
142+
143+ val blockpos = poss.firstOrNull() ? : return @onUpdate null
139144
140145 // Taskflow interact block
141146 // placedCrystal.add()
@@ -146,11 +151,23 @@ object CrystalAura : Module(
146151 listen<RenderEvent .StaticESP > {
147152 worldCrystals(target ? : return @listen).forEach { crystal ->
148153 it.renderer.build(
149- Box .of(crystal.pos, 1.0 , 1.0 , 1.0 ),
150- crystalColor.compared(this , target ? : return @forEach, crystal.blockPos),
151- crystalColor.compared(this , target ? : return @forEach, crystal.blockPos)
154+ Box .of(crystal.blockPos.toCenterPos(), 1.0 , 1.0 , 1.0 ),
155+ crystalColor.compared(this , target ? : return @forEach, crystal.pos),
156+ crystalColor.compared(this , target ? : return @forEach, crystal.pos)
157+ )
158+ }
159+
160+ testRender.forEachIndexed { index, pos ->
161+ val center = pos.toCenterPos()
162+ val blurple = Color (85 , 57 , 204 , 50 )
163+ it.renderer.build(
164+ Box .of(center, 1.0 , 1.0 , 1.0 ),
165+ blurple,
166+ blurple
152167 )
153168 }
169+
170+ testRender.clear()
154171 }
155172 }
156173
@@ -162,13 +179,25 @@ object CrystalAura : Module(
162179 Rendering
163180 }
164181
182+ /* *
183+ * Damage sorter parameter
184+ *
185+ * deadly -> always prioritize enemy damage no matter what
186+ * balanced -> sort by the highest ratio of enemy damage to self damage
187+ * safe -> always prioritize the least amount of self damage
188+ */
165189 private enum class DamageSort (val sorted : SafeContext .(LivingEntity , BlockPos ) -> Double ) {
166190 Deadly ({ target, source -> explosionDamage(source, target, 6.0 ) }),
167191 Balanced ({ target, source -> explosionDamage(source, player, 6.0 ) - explosionDamage(source, target, 6.0 ) }),
168192 Safe ({ target, source -> explosionDamage(source, target, 6.0 ) - explosionDamage(source, player, 6.0 ) });
169193 }
170194
171- private enum class ColorComparator (val compared : SafeContext .(LivingEntity , BlockPos ) -> Color ) {
195+ /* *
196+ * Comparator for different render modes
197+ *
198+ * @param compared Lambda that takes in a living target and crystal position and then returns a color
199+ */
200+ private enum class ColorComparator (val compared : SafeContext .(LivingEntity , Vec3d ) -> Color ) {
172201 Distance ({ target, dest ->
173202 val red = transform(target dist dest, 0.0 , explodeRange, 255.0 , 0.0 ).toInt()
174203 Color (red, 255 - red, 0 , crystalAlpha)
0 commit comments