Skip to content

Commit

Permalink
Fix fix fix fix fix你马勒戈壁
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
Memorial1337 committed Nov 11, 2023
1 parent 277a64c commit fd18443
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ModuleManager : Listenable {
ClientUtils.logInfo("[ModuleManager] Loading modules...")

ClassUtils.resolvePackage("${this.javaClass.`package`.name}.modules", Module::class.java)
.forEach(this::registerModule)
.forEach(this::registerModule)

modules.forEach { it.onInitialize() }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.event.EntityMovementEvent
import net.ccbluex.liquidbounce.event.EventTarget
import net.ccbluex.liquidbounce.event.PacketEvent
import net.ccbluex.liquidbounce.event.Render3DEvent
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo
import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox
import net.ccbluex.liquidbounce.utils.render.RenderUtils
import net.ccbluex.liquidbounce.value.IntegerValue
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.network.play.server.S0CPacketSpawnPlayer
import org.lwjgl.opengl.GL11.*
import java.awt.Color
import java.util.*

@ModuleInfo(name = "BackTrack", category = ModuleCategory.COMBAT)
object Backtrack : Module() {

// This will be used as maximum possible delay. (In milliseconds)
private val maximumDelay = IntegerValue("MaxDelay", 250, 0, 1000)

// This will be used to set the maximum data of a player. This can be used to prevent memory leaks and lag.
// Might be useful on servers with a lot of players or AntiCheat plugins which try to cause issues by exploiting this.
private val maximumCachedPositions = IntegerValue("MaxCachedPositions", 10, 1, 20)

private val backtrackedPlayer = mutableMapOf<UUID, MutableList<BacktrackData>>()

@EventTarget
fun onPacket(event: PacketEvent) {

when (val packet = event.packet) {
// Check if packet is a spawn player packet
is S0CPacketSpawnPlayer -> {
// Insert first backtrack data
addBacktrackData(packet.player, packet.x / 32.0, packet.y / 32.0, packet.z / 32.0, System.currentTimeMillis())
}
}

backtrackedPlayer.forEach { (key, backtrackData) ->
// Remove old data
backtrackData.removeIf { it.time + maximumDelay.get() < System.currentTimeMillis() }

// Remove player if there is no data left. This prevents memory leaks.
if (backtrackData.isEmpty()) {
removeBacktrackData(key)
}
}
}

/**
* This event is being called when an entity moves (e.g. a player), which is being sent from the server.
*
* We use this to track the player movement.
*/
@EventTarget
fun onEntityMove(event: EntityMovementEvent) {
val entity = event.movedEntity

// Check if entity is a player
if (entity is EntityPlayer) {
// Add new data
addBacktrackData(entity.uniqueID, entity.posX, entity.posY, entity.posZ, System.currentTimeMillis())
}
}

@EventTarget
fun onRender3D(event: Render3DEvent) {
val color = Color.RED

for (entity in mc.theWorld.loadedEntityList) {
if (entity is EntityPlayer) {
glPushMatrix()
glDisable(GL_TEXTURE_2D)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_LINE_SMOOTH)
glEnable(GL_BLEND)
glDisable(GL_DEPTH_TEST)

mc.entityRenderer.disableLightmap()

glBegin(GL_LINE_STRIP)
RenderUtils.glColor(color)

val renderPosX = mc.renderManager.viewerPosX
val renderPosY = mc.renderManager.viewerPosY
val renderPosZ = mc.renderManager.viewerPosZ

loopThroughBacktrackData(entity) {
glVertex3d(entity.posX - renderPosX, entity.posY - renderPosY, entity.posZ - renderPosZ)
false
}

glColor4d(1.0, 1.0, 1.0, 1.0)
glEnd()
glEnable(GL_DEPTH_TEST)
glDisable(GL_LINE_SMOOTH)
glDisable(GL_BLEND)
glEnable(GL_TEXTURE_2D)
glPopMatrix()
}
}
}

private fun addBacktrackData(id: UUID, x: Double, y: Double, z: Double, time: Long) {
// Get backtrack data of player
val backtrackData = getBacktrackData(id)

// Check if there is already data of the player
if (backtrackData != null) {
// Check if there is already enough data of the player
if (backtrackData.size >= maximumCachedPositions.get()) {
// Remove first data
backtrackData.removeAt(0)
}

// Insert new data
backtrackData.add(BacktrackData(x, y, z, time))
} else {
// Create new list
backtrackedPlayer[id] = mutableListOf(BacktrackData(x, y, z, time))
}
}

private fun getBacktrackData(id: UUID) = backtrackedPlayer[id]

private fun removeBacktrackData(id: UUID) {
backtrackedPlayer.remove(id)
}

/**
* This function will return the nearest tracked range of an entity.
*/
fun getNearestTrackedDistance(entity: Entity): Double {
var nearestRange = 0.0

loopThroughBacktrackData(entity) {
val range = entity.getDistanceToEntityBox(mc.thePlayer)

if (range < nearestRange || nearestRange == 0.0) {
nearestRange = range
}

false
}

return nearestRange
}

/**
* This function will loop through the backtrack data of an entity.
*/
fun loopThroughBacktrackData(entity: Entity, action: () -> Boolean) {
if (!Backtrack.state || entity !is EntityPlayer) {
return
}

val backtrackDataArray = getBacktrackData(entity.uniqueID) ?: return
val entityPosition = entity.positionVector
val prevPosition = Triple(entity.prevPosX, entity.prevPosY, entity.prevPosZ)

// This will loop through the backtrack data. We are using reversed() to loop through the data from the newest to the oldest.
for (backtrackData in backtrackDataArray.reversed()) {
entity.setPosition(backtrackData.x, backtrackData.y, backtrackData.z)
entity.prevPosX = backtrackData.x
entity.prevPosY = backtrackData.y
entity.prevPosZ = backtrackData.z
if (action()) {
break
}
}

// Reset position
val (prevX, prevY, prevZ) = prevPosition
entity.prevPosX = prevX
entity.prevPosY = prevY
entity.prevPosZ = prevZ

entity.setPosition(entityPosition.xCoord, entityPosition.yCoord, entityPosition.zCoord)
}

}

data class BacktrackData(val x: Double, val y: Double, val z: Double, val time: Long)
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,13 @@ object KillAura : Module() {
}

var distance = mc.thePlayer.getDistanceToEntityBox(entity)
if (Backtrack.state) {
val trackedDistance = Backtrack.getNearestTrackedDistance(entity)

if (distance > trackedDistance) {
distance = trackedDistance
}
}

val entityFov = RotationUtils.getRotationDifference(entity)

Expand Down Expand Up @@ -704,6 +711,24 @@ object KillAura : Module() {

// Find best target
for (entity in discoveredTargets) {
// Update rotations to current target
if (!updateRotations(entity)) {
var success = false
Backtrack.loopThroughBacktrackData(entity) {
if (updateRotations(entity)) {
success = true
return@loopThroughBacktrackData true
}

return@loopThroughBacktrackData false
}

if (!success) {
// when failed then try another target
continue
}
}

// Set target to current entity
if (mc.thePlayer.getDistanceToEntityBox(entity) < rangeValue.get()) {
currentTarget = entity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package net.ccbluex.liquidbounce.features.module.modules.movement

import net.ccbluex.liquidbounce.LiquidBounce
import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo
import net.ccbluex.liquidbounce.features.module.modules.combat.KillAura
import net.ccbluex.liquidbounce.utils.ClientUtils
import net.ccbluex.liquidbounce.utils.MovementUtils
import net.ccbluex.liquidbounce.utils.PacketUtils
import net.ccbluex.liquidbounce.utils.timer.MSTimer
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
import net.ccbluex.liquidbounce.value.IntegerValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.item.*
import net.minecraft.network.Packet
import net.minecraft.network.play.INetHandlerPlayServer
import net.minecraft.network.play.client.*
import net.minecraft.network.play.client.C03PacketPlayer.C06PacketPlayerPosLook
import net.minecraft.network.play.server.S08PacketPlayerPosLook
import net.minecraft.util.BlockPos
import net.minecraft.util.EnumFacing
import java.util.*
import kotlin.math.sqrt

@ModuleInfo(name = "NoSlowDwon", category = ModuleCategory.MOVEMENT)
class NoSlowDown : Module() {

@EventTarget
fun onMotion(event: MotionEvent) {
if ((mc.thePlayer.isBlocking || LiquidBounce.moduleManager[KillAura::class.java]!!.blockingStatus) && mc.thePlayer.heldItem.item is ItemSword) {
if (event.eventState == EventState.PRE) {
PacketUtils.sendPacketNoEvent(
C07PacketPlayerDigging(
C07PacketPlayerDigging.Action.RELEASE_USE_ITEM,
BlockPos.ORIGIN,
EnumFacing.DOWN
)
)
}
if (event.eventState == EventState.POST) {
mc.netHandler.addToSendQueue(C08PacketPlayerBlockPlacement(mc.thePlayer.heldItem))
}
}
}
@EventTarget
fun onSlowDown(event: SlowDownEvent) {
if(mc.thePlayer == null || mc.theWorld == null)
return

if ((mc.thePlayer.isBlocking || LiquidBounce.moduleManager[KillAura::class.java]!!.blockingStatus) && mc.thePlayer.heldItem.item is ItemSword) {
event.forward = 1.0F
event.strafe = 1.0F
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,7 @@ module.GrimSpeed.name=Grim加速
module.GrimSpeed.description=在Grim反作弊中 使用加速

module.BorderWarn.name=边缘检测
module.BorderWarn.description=检测你在方块边缘发出警告
module.BorderWarn.description=检测你在方块边缘发出警告

module.NoSlowDown.name=没有慢
module.NoSlowDown.description=在GrimAC中使用剑无减速检测

0 comments on commit fd18443

Please sign in to comment.