Skip to content

Commit

Permalink
Merge branch 'nextgen' into fork/ccetl/anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Jan 7, 2025
2 parents 340aaa4 + 3ff66be commit 9d88ab3
Show file tree
Hide file tree
Showing 45 changed files with 562 additions and 474 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.spongepowered.asm.mixin.injection.At;

@Pseudo
@Mixin(value = ChunkAwareBlockCollisionSweeper.class, remap = false)
@Mixin(value = ChunkAwareBlockCollisionSweeper.class)
public class MixinChunkAwareBlockCollisionSweeper {

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void injectRender(DrawContext context, int mouseX, int mouseY, float del
@Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;Lnet/minecraft/client/network/CookieStorage;)V", at = @At("HEAD"))
private void injectConnect(MinecraftClient client, ServerAddress address, ServerInfo info, CookieStorage cookieStorage, CallbackInfo ci) {
this.serverAddress = address;
EventManager.INSTANCE.callEvent(new ServerConnectEvent(info.name, info.address));
EventManager.INSTANCE.callEvent(new ServerConnectEvent(info));
}

@ModifyConstant(method = "render", constant = @Constant(intValue = 50))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ private boolean shouldRenderOutline(Entity entity) {
return true;
} else if (ModuleTNTTimer.INSTANCE.getRunning() && ModuleTNTTimer.INSTANCE.getEsp() && entity instanceof TntEntity) {
return true;
} else if (ModuleStorageESP.Glow.INSTANCE.getRunning() && ModuleStorageESP.categorize(entity) != null) {
return true;
} else {
return false;
}
Expand All @@ -217,9 +219,14 @@ private int injectTeamColor(int original, @Local Entity entity) {
return ModuleItemESP.INSTANCE.getColor().toARGB();
} else if (entity instanceof TntEntity tntEntity && ModuleTNTTimer.INSTANCE.getRunning() && ModuleTNTTimer.INSTANCE.getEsp()) {
return ModuleTNTTimer.INSTANCE.getTntColor(tntEntity.getFuse()).toARGB();
} else {
return original;
} else if (ModuleStorageESP.Glow.INSTANCE.getRunning()) {
var color = ModuleStorageESP.categorize(entity);
if (color != null) {
return color.getColor().toARGB();
}
}

return original;
}

@Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;draw()V", shift = At.Shift.BEFORE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ val ALL_EVENT_CLASSES: Array<KClass<out Event>> = arrayOf(
VirtualScreenEvent::class,
FpsChangeEvent::class,
ClientPlayerDataEvent::class,
SimulatedTickEvent::class,
RotationUpdateEvent::class,
SplashOverlayEvent::class,
SplashProgressEvent::class,
RefreshArrayListEvent::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import net.ccbluex.liquidbounce.integration.interop.protocol.event.WebSocketEven
import net.ccbluex.liquidbounce.integration.interop.protocol.rest.v1.game.PlayerData
import net.ccbluex.liquidbounce.integration.theme.component.Component
import net.ccbluex.liquidbounce.utils.client.Nameable
import net.ccbluex.liquidbounce.utils.entity.SimulatedPlayer
import net.ccbluex.liquidbounce.utils.inventory.InventoryAction
import net.ccbluex.liquidbounce.utils.inventory.InventoryActionChain
import net.ccbluex.liquidbounce.utils.inventory.InventoryConstraints
Expand Down Expand Up @@ -196,14 +195,8 @@ class ServerPingedEvent(val server: ServerInfo) : Event()
@WebSocketEvent(serializer = GsonInstance.ACCESSIBLE_INTEROP)
class ComponentsUpdate(val components: List<Component>) : Event()

/**
* The simulated tick event is called by the [MovementInputEvent] with a simulated movement context.
* This context includes a simulated player position one tick into the future.
* Position changes will not apply within the simulated tick. Only use this for prediction purposes as
* updating the rotation or target.
*/
@Nameable("simulatedTick")
class SimulatedTickEvent(val movementEvent: MovementInputEvent, val simulatedPlayer: SimulatedPlayer) : Event()
@Nameable("rotationUpdate")
object RotationUpdateEvent : Event()

@Nameable("resourceReload")
object ResourceReloadEvent : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import net.ccbluex.liquidbounce.integration.interop.protocol.event.WebSocketEven
import net.ccbluex.liquidbounce.utils.client.Nameable
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.network.ServerInfo
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.option.Perspective
import net.minecraft.client.session.Session
Expand Down Expand Up @@ -113,7 +114,7 @@ class SplashProgressEvent(val progress: Float, val isComplete: Boolean) : Event(

@Nameable("serverConnect")
@WebSocketEvent
class ServerConnectEvent(val serverName: String, val serverAddress: String) : Event()
class ServerConnectEvent(val serverInfo: ServerInfo) : Event()

@Nameable("disconnect")
@WebSocketEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ object Reconnect : EventListener {

private var lastServer: ServerInfo? = null

val handleServerConnect = handler<ServerConnectEvent> {
lastServer = ServerInfo(it.serverName, it.serverAddress, ServerInfo.ServerType.OTHER)
@Suppress("unused")
private val handleServerConnect = handler<ServerConnectEvent> { event ->
lastServer = event.serverInfo
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,40 @@ import io.netty.handler.codec.http.HttpObjectAggregator
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory
import io.netty.handler.codec.http.websocketx.WebSocketVersion
import io.netty.handler.ssl.SslContext
import io.netty.handler.ssl.SslContextBuilder
import io.netty.handler.ssl.util.InsecureTrustManagerFactory
import net.ccbluex.liquidbounce.api.core.withScope
import net.ccbluex.liquidbounce.authlib.yggdrasil.GameProfileRepository
import net.ccbluex.liquidbounce.event.EventManager
import net.ccbluex.liquidbounce.event.events.*
import net.ccbluex.liquidbounce.features.chat.packet.*
import net.ccbluex.liquidbounce.utils.client.chat
import net.ccbluex.liquidbounce.utils.client.mc
import net.minecraft.util.Util
import java.net.URI
import java.util.*

class ChatClient {

var channel: Channel? = null
private var channel: Channel? = null

private val serializer = PacketSerializer().apply {
registerPacket("RequestMojangInfo", ServerRequestMojangInfoPacket::class.java)
registerPacket("LoginMojang", ServerLoginMojangPacket::class.java)
registerPacket("Message", ServerMessagePacket::class.java)
registerPacket("PrivateMessage", ServerPrivateMessagePacket::class.java)
registerPacket("BanUser", ServerBanUserPacket::class.java)
registerPacket("UnbanUser", ServerUnbanUserPacket::class.java)
registerPacket("RequestJWT", ServerRequestJWTPacket::class.java)
registerPacket("LoginJWT", ServerLoginJWTPacket::class.java)
register<ServerRequestMojangInfoPacket>("RequestMojangInfo")
register<ServerLoginMojangPacket>("LoginMojang")
register<ServerMessagePacket>("Message")
register<ServerPrivateMessagePacket>("PrivateMessage")
register<ServerBanUserPacket>("BanUser")
register<ServerUnbanUserPacket>("UnbanUser")
register<ServerRequestJWTPacket>("RequestJWT")
register<ServerLoginJWTPacket>("LoginJWT")
}

private val deserializer = PacketDeserializer().apply {
registerPacket("MojangInfo", ClientMojangInfoPacket::class.java)
registerPacket("NewJWT", ClientNewJWTPacket::class.java)
registerPacket("Message", ClientMessagePacket::class.java)
registerPacket("PrivateMessage", ClientPrivateMessagePacket::class.java)
registerPacket("Error", ClientErrorPacket::class.java)
registerPacket("Success", ClientSuccessPacket::class.java)
register<ClientMojangInfoPacket>("MojangInfo")
register<ClientNewJWTPacket>("NewJWT")
register<ClientMessagePacket>("Message")
register<ClientPrivateMessagePacket>("PrivateMessage")
register<ClientErrorPacket>("Error")
register<ClientSuccessPacket>("Success")
}

val connected: Boolean
Expand All @@ -79,13 +79,24 @@ class ChatClient {
private var isConnecting = false
var loggedIn = false

private val serializerGson by lazy {
GsonBuilder()
.registerTypeAdapter(Packet::class.java, serializer)
.create()
}

private val deserializerGson by lazy {
GsonBuilder()
.registerTypeAdapter(Packet::class.java, deserializer)
.create()
}

fun connectAsync() {
if (isConnecting || connected) {
return
}

// Async connecting using IO worker from Minecraft
Util.getIoWorkerExecutor().execute {
withScope {
connect()
}
}
Expand All @@ -95,7 +106,7 @@ class ChatClient {
* Supports SSL and non-SSL connections.
* Be aware SSL takes insecure certificates.
*/
fun connect() = runCatching {
private fun connect() = runCatching {
EventManager.callEvent(ClientChatStateChange(ClientChatStateChange.State.CONNECTING))
isConnecting = true
loggedIn = false
Expand All @@ -104,7 +115,7 @@ class ChatClient {

val ssl = uri.scheme.equals("wss", true)
val sslContext = if (ssl) {
SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE)
SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build()
} else {
null
}
Expand Down Expand Up @@ -227,11 +238,7 @@ class ChatClient {
* Send packet to server
*/
internal fun sendPacket(packet: Packet) {
val gson = GsonBuilder()
.registerTypeAdapter(Packet::class.java, serializer)
.create()

channel?.writeAndFlush(TextWebSocketFrame(gson.toJson(packet, Packet::class.java)))
channel?.writeAndFlush(TextWebSocketFrame(serializerGson.toJson(packet, Packet::class.java)))
}

private fun handleFunctionalPacket(packet: Packet) {
Expand Down Expand Up @@ -315,11 +322,7 @@ class ChatClient {
* Handle incoming message of websocket
*/
internal fun handlePlainMessage(message: String) {
val gson = GsonBuilder()
.registerTypeAdapter(Packet::class.java, deserializer)
.create()

val packet = gson.fromJson(message, Packet::class.java)
val packet = deserializerGson.fromJson(message, Packet::class.java)
handleFunctionalPacket(packet)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class PacketSerializer : JsonSerializer<Packet> {
packetRegistry[packetClass] = packetName
}

inline fun <reified T : Packet> register(name: String) {
registerPacket(name, T::class.java)
}

/**
* Gson invokes this call-back method during serialization when it encounters a field of the
* specified type.
Expand Down Expand Up @@ -80,6 +84,10 @@ class PacketDeserializer : JsonDeserializer<Packet> {
packetRegistry[packetName] = packetClass
}

inline fun <reified T : Packet> register(name: String) {
registerPacket(name, T::class.java)
}

/**
* Gson invokes this call-back method during deserialization when it encounters a field of the
* specified type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.MouseRotationEvent
import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
Expand Down Expand Up @@ -73,7 +73,7 @@ object ModuleAimbot : ClientModule("Aimbot", Category.COMBAT, aliases = arrayOf(
private var targetRotation: Rotation? = null
private var playerRotation: Rotation? = null

private val tickHandler = handler<SimulatedTickEvent> { _ ->
private val tickHandler = handler<RotationUpdateEvent> { _ ->
this.targetTracker.validateLock { target -> target.boxedDistanceTo(player) <= range }
this.playerRotation = player.rotation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.config.types.NamedChoice
import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.tickHandler
Expand All @@ -47,16 +47,11 @@ import net.ccbluex.liquidbounce.utils.item.findHotbarSlot
import net.ccbluex.liquidbounce.utils.item.isNothing
import net.ccbluex.liquidbounce.utils.kotlin.Priority
import net.ccbluex.liquidbounce.utils.render.WorldTargetRenderer
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryData
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfo
import net.minecraft.entity.LivingEntity
import net.minecraft.item.Item
import net.minecraft.item.Items
import net.minecraft.util.Hand
import kotlin.math.atan
import kotlin.math.atan2
import kotlin.math.pow
import kotlin.math.sqrt

/**
* A module that automatically shoots at the nearest enemy.
Expand Down Expand Up @@ -115,7 +110,7 @@ object ModuleAutoShoot : ClientModule("AutoShoot", Category.COMBAT) {
* as fast possible. This means we already pre-aim before we peek around the corner.
*/
@Suppress("unused")
val simulatedTickHandler = handler<SimulatedTickEvent> {
val simulatedTickHandler = handler<RotationUpdateEvent> {
targetTracker.cleanup()

// Find the recommended target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
package net.ccbluex.liquidbounce.features.module.modules.combat.crystalaura

import net.ccbluex.liquidbounce.config.types.Configurable
import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.render.renderEnvironmentForWorld
import net.ccbluex.liquidbounce.utils.aiming.NoRotationMode
import net.ccbluex.liquidbounce.utils.aiming.NormalRotationMode
import net.ccbluex.liquidbounce.utils.aiming.RotationMode
import net.ccbluex.liquidbounce.utils.combat.CombatManager
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
import net.ccbluex.liquidbounce.utils.kotlin.Priority
Expand Down Expand Up @@ -81,7 +80,7 @@ object ModuleCrystalAura : ClientModule(
}

@Suppress("unused")
val simulatedTickHandler = handler<SimulatedTickEvent> {
val simulatedTickHandler = handler<RotationUpdateEvent> {
CrystalAuraDamageOptions.cacheMap.clear()
if (CombatManager.shouldPauseCombat) {
return@handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.google.gson.JsonObject
import net.ccbluex.liquidbounce.config.types.NamedChoice
import net.ccbluex.liquidbounce.event.Sequence
import net.ccbluex.liquidbounce.event.events.InputHandleEvent
import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.tickHandler
Expand Down Expand Up @@ -157,7 +157,7 @@ object ModuleKillAura : ClientModule("KillAura", Category.COMBAT) {
}

@Suppress("unused")
val rotationUpdateHandler = handler<SimulatedTickEvent> {
val rotationUpdateHandler = handler<RotationUpdateEvent> {
// Make sure killaura-logic is not running while inventory is open
val isInInventoryScreen =
InventoryManager.isInventoryOpen || mc.currentScreen is GenericContainerScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object ModuleAntiStaff : ClientModule("AntiStaff", Category.MISC) {

@Suppress("unused")
val handleServerConnect = sequenceHandler<ServerConnectEvent> { event ->
val address = event.serverAddress.dropPort().rootDomain()
val address = event.serverInfo.address.dropPort().rootDomain()

if (serverStaffList.containsKey(address)) {
return@sequenceHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ import com.oracle.truffle.runtime.collection.ArrayQueue
import net.ccbluex.liquidbounce.config.types.NamedChoice
import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.PacketEvent
import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.sequenceHandler
import net.ccbluex.liquidbounce.event.tickHandler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura
import net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.HotbarItemSlot
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfo
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfoRenderer
import net.ccbluex.liquidbounce.utils.aiming.Rotation
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
import net.ccbluex.liquidbounce.utils.aiming.RotationUtil
Expand All @@ -43,6 +41,8 @@ import net.ccbluex.liquidbounce.utils.inventory.OFFHAND_SLOT
import net.ccbluex.liquidbounce.utils.inventory.useHotbarSlotOrOffhand
import net.ccbluex.liquidbounce.utils.item.findHotbarItemSlot
import net.ccbluex.liquidbounce.utils.kotlin.Priority
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfo
import net.ccbluex.liquidbounce.utils.render.trajectory.TrajectoryInfoRenderer
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityDimensions
import net.minecraft.entity.EntityType
Expand Down Expand Up @@ -111,7 +111,7 @@ object ModuleAutoPearl : ClientModule("AutoPearl", Category.MISC, aliases = arra
}

@Suppress("unused")
private val simulatedTickHandler = sequenceHandler<SimulatedTickEvent> {
private val simulatedTickHandler = sequenceHandler<RotationUpdateEvent> {
val rotation = queue.peek() ?: return@sequenceHandler

CombatManager.pauseCombatForAtLeast(combatPauseTime)
Expand Down
Loading

0 comments on commit 9d88ab3

Please sign in to comment.