@@ -32,13 +32,15 @@ import com.lambda.util.BlockUtils.blockState
3232import com.lambda.util.collections.LimitedDecayQueue
3333import com.lambda.util.combat.CombatUtils.explosionDamage
3434import com.lambda.util.math.VecUtils.dist
35+ import com.lambda.util.math.VecUtils.vec3d
3536import com.lambda.util.math.transform
3637import com.lambda.util.world.blockSearch
3738import com.lambda.util.world.fastEntitySearch
3839import net.minecraft.block.Blocks
3940import net.minecraft.entity.Entity
4041import net.minecraft.entity.LivingEntity
4142import net.minecraft.entity.decoration.EndCrystalEntity
43+ import net.minecraft.item.EndCrystalItem
4244import net.minecraft.util.Hand
4345import net.minecraft.util.math.BlockPos
4446import net.minecraft.util.math.Box
@@ -96,7 +98,7 @@ object CrystalAura : Module(
9698 private fun SafeContext.validPositions (target : LivingEntity ): Sequence <BlockPos > {
9799 return blockSearch(range = placing.reach.toInt()) { pos, _ -> canPlace(pos, target) }
98100 .keys.asSequence()
99- .sortedByDescending { placeMethod.sorted(this , target, it.up()) } // The explosion source of the crystal is not at its base
101+ .sortedByDescending { placeMethod.sorted(this , target, it.up()) }
100102 }
101103
102104 private fun SafeContext.canPlace (pos : BlockPos , target : LivingEntity ): Boolean {
@@ -105,7 +107,7 @@ object CrystalAura : Module(
105107 return player dist target <= placing.reach &&
106108 player dist pos <= placing.reach &&
107109 // Checks if the position is within the player hitbox
108- ! player.boundingBox.intersects(Box .of(pos.up().toCenterPos() , 1.0 , 2 .0 , 1.0 )) &&
110+ ! player.boundingBox.intersects(Box .of(pos.vec3d , 1.0 , 1 .0 , 1.0 )) &&
109111 // Checks if the support block is either obsidian or bedrock
110112 (pos.blockState(world).isOf(Blocks .OBSIDIAN )
111113 || pos.blockState(world).isOf(Blocks .BEDROCK )) &&
@@ -114,11 +116,11 @@ object CrystalAura : Module(
114116 // Or if there's another crystal 2 blocks around the air block
115117 world.isAir(pos.up()) &&
116118 fastEntitySearch<Entity >(0.5 , pos.up()).isEmpty() &&
117- fastEntitySearch<EndCrystalEntity >(1.5 , pos.up()).isEmpty() && // Doesn't handle the edge case where there is a crystal floating
119+ fastEntitySearch<EndCrystalEntity >(2.0 , pos.up()).isEmpty() && // Replace by intersection check bc blockpos is corner
118120
119- player.health + player.absorptionAmount >= placeMinHealth &&
120- explosionDamage(pos, target, 6.0 ) >= placeMinDamage &&
121- explosionDamage(pos, player, 6.0 ) <= placeMaxSelfDamage &&
121+ // player.health + player.absorptionAmount >= placeMinHealth &&
122+ explosionDamage(pos.up() , target, 6.0 ) >= placeMinDamage &&
123+ explosionDamage(pos.up() , player, 6.0 ) <= placeMaxSelfDamage &&
122124 // Checks if the last crystal was set more than [placeDelay] ms ago
123125 placedCrystal.peek()?.second?.plusMillis(placeDelay)?.isBefore(Instant .now()) ? : true
124126 // if (multiPlace) !placedCrystal.any { (crystalPos, _) -> pos.up() == crystalPos } else true
@@ -128,17 +130,15 @@ object CrystalAura : Module(
128130
129131
130132 init {
131- rotate(
132- priority = 100 ,
133- ) {
133+ rotate {
134134 onUpdate {
135135 if (! rotate) return @onUpdate null
136136
137137 val poss = validPositions(
138138 target ? : return @onUpdate null
139139 )
140140
141- testRender.addAll(poss.take( 3 ) )
141+ testRender.addAll(poss)
142142
143143 val blockpos = poss.firstOrNull() ? : return @onUpdate null
144144
@@ -204,7 +204,10 @@ object CrystalAura : Module(
204204 }),
205205
206206 Damage ({ target, dest ->
207- val red = transform(explosionDamage(dest, target, 6.0 ), 0.0 , target.health.toDouble(), 0.0 , 255.0 ).toInt()
207+ val damage = explosionDamage(dest, target, 6.0 )
208+ .coerceIn(0.0 , target.health.toDouble())
209+
210+ val red = transform(damage, 0.0 , target.health.toDouble(), 0.0 , 255.0 ).toInt()
208211 Color (red, 255 - red, 0 , crystalAlpha)
209212 })
210213 }
0 commit comments