Skip to content

Commit

Permalink
修复Raycast问题
Browse files Browse the repository at this point in the history
  • Loading branch information
contionability committed Feb 28, 2023
1 parent bc48836 commit 1aed4b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@ import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo
import net.ccbluex.liquidbounce.features.module.modules.client.HUD
import net.ccbluex.liquidbounce.features.module.modules.movement.Fly
import net.ccbluex.liquidbounce.features.module.modules.movement.TargetStrafe
import net.ccbluex.liquidbounce.features.module.modules.movement.StrafeFix
import net.ccbluex.liquidbounce.features.module.modules.movement.TargetStrafe
import net.ccbluex.liquidbounce.features.module.modules.player.Blink
import net.ccbluex.liquidbounce.features.module.modules.render.FreeCam
import net.ccbluex.liquidbounce.features.module.modules.world.Scaffold
import net.ccbluex.liquidbounce.features.value.BoolValue
import net.ccbluex.liquidbounce.features.value.FloatValue
import net.ccbluex.liquidbounce.features.value.IntegerValue
import net.ccbluex.liquidbounce.features.value.ListValue
import net.ccbluex.liquidbounce.utils.*
import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox
import net.ccbluex.liquidbounce.utils.extensions.rayTraceWithServerSideRotation
import net.ccbluex.liquidbounce.utils.misc.RandomUtils
import net.ccbluex.liquidbounce.utils.render.EaseUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils
import net.ccbluex.liquidbounce.utils.timer.MSTimer
import net.ccbluex.liquidbounce.utils.timer.TimeUtils
import net.ccbluex.liquidbounce.features.value.BoolValue
import net.ccbluex.liquidbounce.features.value.FloatValue
import net.ccbluex.liquidbounce.features.value.IntegerValue
import net.ccbluex.liquidbounce.features.value.ListValue
import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.item.ItemAxe
import net.minecraft.item.ItemPickaxe
import net.minecraft.item.ItemSword
import net.minecraft.network.play.client.*
import net.minecraft.potion.Potion
Expand All @@ -46,7 +44,6 @@ import net.minecraft.world.WorldSettings
import org.lwjgl.input.Keyboard
import org.lwjgl.opengl.GL11
import org.lwjgl.util.glu.Cylinder
import scala.annotation.switch
import java.awt.Color
import java.util.*
import kotlin.math.*
Expand Down Expand Up @@ -245,7 +242,6 @@ class KillAura : Module() {
var target: EntityLivingBase? = null
private var currentTarget: EntityLivingBase? = null
private var hitable = false
private var lastPacketSent = false
private var packetSent = false
private val prevTargetEntities = mutableListOf<Int>()
private val discoveredTargets = mutableListOf<EntityLivingBase>()
Expand Down Expand Up @@ -405,7 +401,7 @@ class KillAura : Module() {
* Update event
*/
@EventTarget
fun onUpdate(e: UpdateEvent) {
fun onUpdate(IgnoredEvent: UpdateEvent) {
if (cancelRun) {
target = null
currentTarget = null
Expand Down Expand Up @@ -849,7 +845,6 @@ class KillAura : Module() {
*/
private fun updateTarget() {
// Settings
val hurtTime = hurtTimeValue.get()
val fov = fovValue.get()
val switchMode = targetModeValue.equals("Switch")

Expand All @@ -876,7 +871,7 @@ class KillAura : Module() {

val entityFov = RotationUtils.getRotationDifference(entity)

if (distance <= discoverRangeValue.get() && (fov == 180F || entityFov <= fov) && entity.hurtTime <= hurtTime) {
if (distance <= discoverRangeValue.get() && (fov == 180F || entityFov <= fov)) {
discoveredTargets.add(entity)
}
}
Expand All @@ -893,7 +888,7 @@ class KillAura : Module() {
}

inRangeDiscoveredTargets.clear()
inRangeDiscoveredTargets.addAll(discoveredTargets.filter { mc.thePlayer.getDistanceToEntityBox(it) < getRange(it) })
inRangeDiscoveredTargets.addAll(discoveredTargets.filter { mc.thePlayer.getDistanceToEntityBox(it) < (rangeValue.get() - if (mc.thePlayer.isSprinting) rangeSprintReducementValue.get() else 0F) })

// Cleanup last targets when no targets found and try again
if (inRangeDiscoveredTargets.isEmpty() && prevTargetEntities.isNotEmpty()) {
Expand Down Expand Up @@ -925,15 +920,13 @@ class KillAura : Module() {
// Set target to current entity
if (mc.thePlayer.getDistanceToEntityBox(entity) < discoverRangeValue.get()) {
target = entity
canSwing = (mc.thePlayer.getDistanceToEntityBox(entity) < swingRangeValue.get())
LiquidBounce.moduleManager[TargetStrafe::class.java]!!.targetEntity = target?:return
LiquidBounce.moduleManager[TargetStrafe::class.java]!!.doStrafe = LiquidBounce.moduleManager[TargetStrafe::class.java]!!.toggleStrafe()
return
}
}

target = null
canSwing = false
LiquidBounce.moduleManager[TargetStrafe::class.java]!!.doStrafe = false
}

Expand Down Expand Up @@ -1029,7 +1022,7 @@ class KillAura : Module() {
(randomCenRangeValue.get()).toDouble(),
boundingBox,
predictValue.get() && rotationModeValue.get() != "Test",
mc.thePlayer.getDistanceToEntityBox(entity) <= throughWallsRangeValue.get()
true
) ?: return false

if (rotationModeValue.get() == "OldMatrix") directRotation.pitch = 89.9f
Expand Down Expand Up @@ -1088,17 +1081,19 @@ class KillAura : Module() {
* Check if enemy is hitable with current rotations
*/
private fun updateHitable() {
val entityDist = mc.thePlayer.getDistanceToEntityBox(currentTarget as Entity)
canSwing = entityDist < swingRangeValue.get() && (currentTarget as EntityLivingBase).hurtTime <= hurtTimeValue.get()
if (hitAbleValue.get()) {
hitable = currentTarget != null && mc.thePlayer.getDistanceToEntityBox(currentTarget as Entity) < maxRange.toDouble()
hitable = currentTarget != null && entityDist <= maxRange.toDouble()
return
}
// Disable hitable check if turn speed is zero
if (maxTurnSpeedValue.get() <= 0F) {
hitable = true
return
}

hitable = RotationUtils.isFaced(currentTarget, maxRange.toDouble())
val wallTrace = mc.thePlayer.rayTraceWithServerSideRotation(entityDist)
hitable = RotationUtils.isFaced(currentTarget, maxRange.toDouble()) && (entityDist < throughWallsRangeValue.get() || wallTrace.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) && (currentTarget as EntityLivingBase).hurtTime <= hurtTimeValue.get()
}

/**
Expand Down Expand Up @@ -1202,9 +1197,6 @@ class KillAura : Module() {
private val maxRange: Float
get() = max(rangeValue.get(), throughWallsRangeValue.get())

private fun getRange(entity: Entity) =
(if (mc.thePlayer.getDistanceToEntityBox(entity) >= throughWallsRangeValue.get()) rangeValue.get() else throughWallsRangeValue.get()) - if (mc.thePlayer.isSprinting) rangeSprintReducementValue.get() else 0F

/**
* HUD Tag
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public static Vec3 getVectorForRotation(final Rotation rotation) {
* @return if crosshair is over target
*/
public static boolean isFaced(final Entity targetEntity, double blockReachDistance) {
return RaycastUtils.raycastEntity(blockReachDistance, entity -> entity == targetEntity) == null;
return RaycastUtils.raycastEntity(blockReachDistance, entity -> entity == targetEntity) != null;
}

/**
Expand Down

0 comments on commit 1aed4b2

Please sign in to comment.