Skip to content

Commit

Permalink
LEGACY: Added HypixelBlink NoFall & Added BlinkUtils (#2813)
Browse files Browse the repository at this point in the history
- Added HypixelBlink Nofall (Still under testing).
- Added BlinkUtils (Quite unreliable).
- Fixed Text "blocking" crashing client due to null.
  • Loading branch information
EclipsesDev authored Apr 15, 2024
1 parent 951ce5b commit a8b23a7
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import net.ccbluex.liquidbounce.LiquidBounce.hud
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.modules.player.Blink
import net.ccbluex.liquidbounce.features.module.modules.player.Reach
import net.ccbluex.liquidbounce.script.api.global.Chat
import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification
import net.ccbluex.liquidbounce.utils.BlinkUtils
import net.ccbluex.liquidbounce.utils.EntityUtils
import net.ccbluex.liquidbounce.utils.EntityUtils.isLookingOnEntities
import net.ccbluex.liquidbounce.utils.PacketUtils.queuedPackets
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.RotationUtils.searchCenter
import net.ccbluex.liquidbounce.utils.SimulatedPlayer
import net.ccbluex.liquidbounce.utils.extensions.*
Expand All @@ -30,11 +29,8 @@ import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.network.Packet
import net.minecraft.network.handshake.client.C00Handshake
import net.minecraft.network.play.client.*
import net.minecraft.network.play.server.*
import net.minecraft.network.status.client.C00PacketServerQuery
import net.minecraft.network.status.client.C01PacketPing
import java.awt.Color

object TimerRange : Module("TimerRange", ModuleCategory.COMBAT) {
Expand Down Expand Up @@ -148,7 +144,7 @@ object TimerRange : Module("TimerRange", ModuleCategory.COMBAT) {

override fun onDisable() {
timerReset()
unblink()
BlinkUtils.unblink()

smartTick = 0
cooldownTick = 0
Expand Down Expand Up @@ -347,7 +343,7 @@ object TimerRange : Module("TimerRange", ModuleCategory.COMBAT) {
timerReset()

if (blink && blinked) {
unblink()
BlinkUtils.unblink()
blinked = false
}

Expand Down Expand Up @@ -471,30 +467,30 @@ object TimerRange : Module("TimerRange", ModuleCategory.COMBAT) {

if (blink) {
if (playerTicks > 0 && !blinked) {
blink(event)
BlinkUtils.blink(packet, event, sent = false, receive = true)
blinked = true
}

if (blink && blinked) {
when (packet) {
// Flush on doing/getting action.
is S08PacketPlayerPosLook, is C07PacketPlayerDigging, is C12PacketUpdateSign, is C19PacketResourcePackStatus -> {
unblink()
BlinkUtils.unblink()
return
}

// Flush on explosion
is S27PacketExplosion -> {
if (packet.field_149153_g != 0f || packet.field_149152_f != 0f || packet.field_149159_h != 0f) {
unblink()
BlinkUtils.unblink()
return
}
}

// Flush on damage
is S06PacketUpdateHealth -> {
if (packet.health < mc.thePlayer.health) {
unblink()
BlinkUtils.unblink()
return
}
}
Expand Down Expand Up @@ -530,51 +526,6 @@ object TimerRange : Module("TimerRange", ModuleCategory.COMBAT) {
}
}

private fun blink(event: PacketEvent) {
val packet = event.packet

if (mc.thePlayer == null || mc.thePlayer.isDead)
return

if (event.isCancelled)
return

// Prevent conflict while using Blink Module
if (Blink.state || mc.thePlayer.isRiding)
return

when (packet) {
is C00Handshake, is C00PacketServerQuery, is C01PacketPing, is S02PacketChat, is S40PacketDisconnect -> {
return
}
}

if (event.eventType == EventState.RECEIVE && mc.thePlayer.ticksExisted > ticksValue) {
event.cancelEvent()
synchronized(packetsReceived) {
packetsReceived += packet
}
}
if (event.eventType == EventState.SEND) {
synchronized(packets) {
sendPackets(*packets.toTypedArray(), triggerEvents = false)
}
packets.clear()
}
}

private fun unblink() {
synchronized(packetsReceived) {
queuedPackets.addAll(packetsReceived)
}
synchronized(packets) {
sendPackets(*packets.toTypedArray(), triggerEvents = false)
}

packets.clear()
packetsReceived.clear()
}

/**
* HUD Tag
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,18 @@ 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.modules.render.Breadcrumbs
import net.ccbluex.liquidbounce.utils.PacketUtils
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.Rotation
import net.ccbluex.liquidbounce.utils.RotationUtils.serverRotation
import net.ccbluex.liquidbounce.utils.BlinkUtils
import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow
import net.ccbluex.liquidbounce.utils.render.RenderUtils.glColor
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.IntegerValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.network.Packet
import net.minecraft.network.play.client.*
import net.minecraft.network.play.server.S02PacketChat
import net.minecraft.network.play.server.S40PacketDisconnect
import net.minecraft.network.status.client.C01PacketPing
import net.minecraft.network.handshake.client.C00Handshake
import net.minecraft.network.status.client.C00PacketServerQuery
import net.minecraft.util.Vec3
import org.lwjgl.opengl.GL11.*
import java.awt.Color

Expand All @@ -41,22 +34,19 @@ object Blink : Module("Blink", ModuleCategory.PLAYER, gameDetecting = false) {
private val fakePlayerMenu by BoolValue("FakePlayer", true)

private val pulseTimer = MSTimer()
private val packets = mutableListOf<Packet<*>>()
private val packetsReceived = mutableListOf<Packet<*>>()
private var fakePlayer: EntityOtherPlayerMP? = null
private val positions = mutableListOf<Vec3>()

override fun onEnable() {
pulseTimer.reset()

addFakePlayer()
if (fakePlayerMenu)
BlinkUtils.addFakePlayer()
}

override fun onDisable() {
if (mc.thePlayer == null)
return

blink()
BlinkUtils.unblink()
}

@EventTarget
Expand All @@ -77,103 +67,41 @@ object Blink : Module("Blink", ModuleCategory.PLAYER, gameDetecting = false) {

when (mode.lowercase()) {
"sent" -> {
if (event.eventType == EventState.RECEIVE) {
synchronized(packetsReceived) {
PacketUtils.queuedPackets.addAll(packetsReceived)
}
packetsReceived.clear()
}
if (event.eventType == EventState.SEND) {
event.cancelEvent()
synchronized(packets) {
packets += packet
}
if (packet is C03PacketPlayer && packet.isMoving) {
val packetPos = Vec3(packet.x, packet.y, packet.z)
synchronized(positions) {
positions += packetPos
}
}
}
BlinkUtils.blink(packet, event, sent = true, receive = false)
}
"received" -> {
if (event.eventType == EventState.RECEIVE && mc.thePlayer.ticksExisted > 10) {
event.cancelEvent()
synchronized(packetsReceived) {
packetsReceived += packet
}
}
if (event.eventType == EventState.SEND) {
synchronized(packets) {
sendPackets(*packets.toTypedArray(), triggerEvents = false)
}
packets.clear()
}
BlinkUtils.blink(packet, event, sent = false, receive = true)
}
"both" -> {
if (event.eventType == EventState.RECEIVE && mc.thePlayer.ticksExisted > 10) {
event.cancelEvent()
synchronized(packetsReceived) {
packetsReceived += packet
}
}
if (event.eventType == EventState.SEND) {
event.cancelEvent()
synchronized(packets) {
packets += packet
}
if (packet is C03PacketPlayer && packet.isMoving) {
val packetPos = Vec3(packet.x, packet.y, packet.z)
synchronized(positions) {
positions += packetPos
}
if (packet.rotating) {
serverRotation = Rotation(packet.yaw, packet.pitch)
}
}
}
BlinkUtils.blink(packet, event)
}
}
}

@EventTarget
fun onWorld(event: WorldEvent) {
// Clear packets on disconnect only
if (event.worldClient == null) {
packets.clear()
packetsReceived.clear()
positions.clear()
}
}

@EventTarget
fun onMotion(event: MotionEvent) {
if (event.eventState == EventState.POST) {
val thePlayer = mc.thePlayer ?: return

if (thePlayer.isDead || mc.thePlayer.ticksExisted <= 10) {
blink()
BlinkUtils.unblink()
}

when (mode.lowercase()) {
"sent" -> {
synchronized(packetsReceived) {
PacketUtils.queuedPackets.addAll(packetsReceived)
}
packetsReceived.clear()
BlinkUtils.syncSent()
}

"received" -> {
synchronized(packets) {
sendPackets(*packets.toTypedArray(), triggerEvents = false)
}
packets.clear()
BlinkUtils.syncReceived()
}
}

if (pulse && pulseTimer.hasTimePassed(pulseDelay)) {
blink()
addFakePlayer()
BlinkUtils.unblink()
if (fakePlayerMenu) {
BlinkUtils.addFakePlayer()
}
pulseTimer.reset()
}
}
Expand All @@ -185,7 +113,7 @@ object Blink : Module("Blink", ModuleCategory.PLAYER, gameDetecting = false) {
if (Breadcrumbs.colorRainbow) rainbow()
else Color(Breadcrumbs.colorRed, Breadcrumbs.colorGreen, Breadcrumbs.colorBlue)

synchronized(positions) {
synchronized(BlinkUtils.positions) {
glPushMatrix()
glDisable(GL_TEXTURE_2D)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
Expand All @@ -200,7 +128,7 @@ object Blink : Module("Blink", ModuleCategory.PLAYER, gameDetecting = false) {
val renderPosY = mc.renderManager.viewerPosY
val renderPosZ = mc.renderManager.viewerPosZ

for (pos in positions)
for (pos in BlinkUtils.positions)
glVertex3d(pos.xCoord - renderPosX, pos.yCoord - renderPosY, pos.zCoord - renderPosZ)

glColor4d(1.0, 1.0, 1.0, 1.0)
Expand All @@ -214,48 +142,7 @@ object Blink : Module("Blink", ModuleCategory.PLAYER, gameDetecting = false) {
}

override val tag
get() = (packets.size + packetsReceived.size).toString()

private fun blink() {
synchronized(packetsReceived) {
PacketUtils.queuedPackets.addAll(packetsReceived)
}
synchronized(packets) {
sendPackets(*packets.toTypedArray(), triggerEvents = false)
}

packets.clear()
packetsReceived.clear()
positions.clear()

// Remove fake player
fakePlayer?.let {
mc.theWorld?.removeEntityFromWorld(it.entityId)
fakePlayer = null
}
}

private fun addFakePlayer() {
if (!fakePlayerMenu) return

val thePlayer = mc.thePlayer ?: return

val faker = EntityOtherPlayerMP(mc.theWorld, thePlayer.gameProfile)

faker.rotationYawHead = thePlayer.rotationYawHead
faker.renderYawOffset = thePlayer.renderYawOffset
faker.copyLocationAndAnglesFrom(thePlayer)
faker.rotationYawHead = thePlayer.rotationYawHead
faker.inventory = thePlayer.inventory
mc.theWorld.addEntityToWorld(-1337, faker)

fakePlayer = faker

// Add positions indicating a blink start
// val pos = thePlayer.positionVector
// positions += pos.addVector(.0, thePlayer.eyeHeight / 2.0, .0)
// positions += pos
}
get() = (BlinkUtils.packets.size + BlinkUtils.packetsReceived.size).toString()

fun blinkingSend() = handleEvents() && (mode == "Sent" || mode == "Both")
fun blinkingReceive() = handleEvents() && (mode == "Received" || mode == "Both")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ object NoFall : Module("NoFall", ModuleCategory.PLAYER) {
Cancel,
Spartan,
CubeCraft,
Hypixel
Hypixel,
HypixelBlink
)

private val modes = noFallModes.map { it.modeName }.toTypedArray()
Expand All @@ -45,6 +46,19 @@ object NoFall : Module("NoFall", ModuleCategory.PLAYER) {
val minFallDistance by FloatValue("MinMLGHeight", 5f, 2f..50f, subjective = true) { mode == "MLG" }
val retrieveDelay by IntegerValue("RetrieveDelay", 100, 100..500, subjective = true) { mode == "MLG" }

val minFallDist: FloatValue = object : FloatValue("MinFallDistance", 2.5f, 0f..10f, subjective = true) {
override fun isSupported() = mode == "HypixelBlink"
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxFallDist.get())
}
val maxFallDist: FloatValue = object : FloatValue("MaxFallDistance", 20f, 0f..100f, subjective = true) {
override fun isSupported() = mode == "HypixelBlink"
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minFallDist.get())
}

val autoOff by BoolValue("AutoOff", true)
val simulateDebug by BoolValue("SimulationDebug", false, subjective = true) { mode == "HypixelBlink" }
val fakePlayer by BoolValue("FakePlayer", true, subjective = true) { mode == "HypixelBlink" }

override fun onEnable() {
modeModule.onEnable()
}
Expand Down
Loading

0 comments on commit a8b23a7

Please sign in to comment.