From c0cf366ae0446374a79e8c3203110dffb734e85b Mon Sep 17 00:00:00 2001 From: XeContrast <1683481541@qq.com> Date: Sat, 9 Nov 2024 08:07:13 +0800 Subject: [PATCH] =?UTF-8?q?2D=E6=AD=A3=E6=96=B9=E5=BD=A2=E7=9B=AE=E6=A0=87?= =?UTF-8?q?ESP=20Fix=20&&=20Fucker=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hanabi/gui/cloudmusic/MusicManager.java | 4 +- .../net/ccbluex/liquidbounce/event/Events.kt | 9 +- .../module/modules/client/NoAchievements.kt | 4 +- .../module/modules/combat/TickBase.kt | 2 +- .../module/modules/combat/Velocity.kt | 37 ++-- .../module/modules/exploit/ServerCrasher.kt | 2 +- .../features/module/modules/movement/Speed.kt | 2 +- .../features/module/modules/other/AntiBot.kt | 14 ++ .../module/modules/other/AntiStaff.kt | 3 - .../module/modules/visual/CombatVisuals.kt | 15 +- .../module/modules/visual/Particles.kt | 49 ++--- .../module/modules/world/FastBreak.kt | 4 +- .../modules/world/{Breaker.kt => Fucker.kt} | 110 ++++++++--- .../forge/mixins/client/MixinMinecraft.java | 4 +- .../mixins/entity/MixinEntityPlayerSP.java | 177 ++++++++++-------- .../liquidbounce/script/api/ScriptModule.kt | 2 +- .../style/styles/Slight/RenderUtil.java | 26 ++- .../ccbluex/liquidbounce/utils/MathUtils.kt | 2 + .../ccbluex/liquidbounce/utils/MouseUtils.kt | 4 +- .../liquidbounce/utils/PacketCounterUtils.kt | 2 +- .../ccbluex/liquidbounce/utils/PlayerUtils.kt | 75 +++++++- .../liquidbounce/utils/RotationUtils.kt | 29 ++- .../liquidbounce/utils/block/BlockUtils.kt | 19 ++ .../liquidbounce/utils/waitTickUtils.kt | 5 +- 24 files changed, 408 insertions(+), 192 deletions(-) rename src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/{Breaker.kt => Fucker.kt} (88%) diff --git a/src/main/java/cn/hanabi/gui/cloudmusic/MusicManager.java b/src/main/java/cn/hanabi/gui/cloudmusic/MusicManager.java index d7cc33a..0db0efd 100644 --- a/src/main/java/cn/hanabi/gui/cloudmusic/MusicManager.java +++ b/src/main/java/cn/hanabi/gui/cloudmusic/MusicManager.java @@ -7,7 +7,7 @@ import javafx.scene.media.MediaPlayer; import net.ccbluex.liquidbounce.FDPClient; import net.ccbluex.liquidbounce.event.EventTarget; -import net.ccbluex.liquidbounce.event.TickEvent; +import net.ccbluex.liquidbounce.event.GameTickEvent; import net.ccbluex.liquidbounce.utils.ClientUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IImageBuffer; @@ -311,7 +311,7 @@ public void play(Track track) throws Exception { } @EventTarget - public void onTick(TickEvent evt) { + public void onTick(GameTickEvent evt) { if (this.getMediaPlayer() != null) { long mill = (long) this.getMediaPlayer().getCurrentTime().toMillis(); if (!this.lrc.isEmpty()) { diff --git a/src/main/java/net/ccbluex/liquidbounce/event/Events.kt b/src/main/java/net/ccbluex/liquidbounce/event/Events.kt index 658939b..4aae9f7 100644 --- a/src/main/java/net/ccbluex/liquidbounce/event/Events.kt +++ b/src/main/java/net/ccbluex/liquidbounce/event/Events.kt @@ -105,6 +105,7 @@ class SlowDownEvent(var strafe: Float, var forward: Float) : Event() */ class StrafeEvent(var strafe: Float, var forward: Float, var friction: Float, var yaw: Float) : CancellableEvent() +class RotationUpdateEvent : Event() /** * Called when an other entity moves @@ -181,9 +182,13 @@ class TextEvent(var text: String?) : Event() /** * tick... tack... tick... tack */ -class TickEvent : Event() - class GameTickEvent : Event() + +/** + * tick tack for player + */ +class PlayerTickEvent(val state: EventState) : CancellableEvent() + /** * Called when minecraft player will be updated */ diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/NoAchievements.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/NoAchievements.kt index 0836258..21a4df8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/NoAchievements.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/NoAchievements.kt @@ -6,7 +6,7 @@ package net.ccbluex.liquidbounce.features.module.modules.client import net.ccbluex.liquidbounce.event.EventTarget -import net.ccbluex.liquidbounce.event.TickEvent +import net.ccbluex.liquidbounce.event.GameTickEvent import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.features.module.ModuleInfo @@ -14,7 +14,7 @@ import net.ccbluex.liquidbounce.features.module.ModuleInfo @ModuleInfo(name = "NoAchievements", category = ModuleCategory.CLIENT, array = false, defaultOn = true) object NoAchievements : Module() { @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { mc.guiAchievement.clearAchievements() } } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/TickBase.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/TickBase.kt index 354c2db..de278fd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/TickBase.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/TickBase.kt @@ -89,7 +89,7 @@ object TickBase : Module() { playerTicks = 0 } @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { if (onlykillaura.get() && !FDPClient.moduleManager[KillAura::class.java]!!.state) { return } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt index 54da640..2103665 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Velocity.kt @@ -92,10 +92,7 @@ object Velocity : Module() { ).displayable { mainMode.get() == "Other" } private val horizontal = FloatValue("Horizontal", 0F, -1F, 1F).displayable { - mainMode.get() in arrayOf( - "AAC", - "Vanilla" - ) && (vanillaMode.get() == "Simple") + mainMode.get() == "Vanilla" && (vanillaMode.get() == "Simple") } private val vertical = FloatValue("Vertical", 0F, -1F, 1F).displayable { mainMode.get() in arrayOf( @@ -340,6 +337,9 @@ object Velocity : Module() { private var lastAttackTime = 0L private var intaveDamageTick = 0 + //KKCraft + private var lastGround = false + @EventTarget(priority = -1) fun onPacket(event: PacketEvent) { val packet = event.packet @@ -553,8 +553,13 @@ object Velocity : Module() { } } - "intavereduce", "attackreduce", "grimvertical","kkcraft" -> hasReceivedVelocity = true + "intavereduce", "attackreduce", "grimvertical" -> hasReceivedVelocity = true + "kkcraft" -> { + hasReceivedVelocity = true + if (mc.thePlayer.onGround) lastGround = true + if (packet is S12PacketEntityVelocity) motionXZ = getMotionNoXZ(packet) + } "phase" -> { if (packet is S12PacketEntityVelocity) { if (!mc.thePlayer.onGround && phaseOnlyGroundValue.get()) { @@ -809,7 +814,7 @@ object Velocity : Module() { } @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { if (mainMode.get() == "Cancel" && cancelMode.get() == "GrimC07") { if (hasReceivedVelocity || alwaysValue.get()) { // packet processed event pls val pos = BlockPos(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ) @@ -838,17 +843,20 @@ object Velocity : Module() { } "kkcraft" -> { + if (player.hurtTime in 3..8 && lastGround) { + player.motionX *= reduceAmount.get() + player.motionZ *= reduceAmount.get() + } + if (player.hurtTime == 0 && lastGround && player.onGround) { + lastGround = false + } if (hasReceivedVelocity) { - if (player.hurtTime in 1..8) { - player.motionX *= reduceAmount.get() - player.motionZ *= reduceAmount.get() - } - if (player.hurtTime == 2 && player.onGround) { + if (player.hurtTime == 6 && player.onGround && !mc.gameSettings.keyBindJump.isKeyDown) { player.jump() - player.motionX *= 0.3 - player.motionZ *= 0.3 - hasReceivedVelocity = false + player.motionX *= motionXZ + player.motionZ *= motionXZ } + hasReceivedVelocity = false } } @@ -1176,6 +1184,7 @@ object Velocity : Module() { @EventTarget override fun onDisable() { + lastGround = false mc.timer.timerSpeed = 1f flag = false isMatrixOnGround = false diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ServerCrasher.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ServerCrasher.kt index 15d0d9e..da2b59f 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ServerCrasher.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ServerCrasher.kt @@ -411,7 +411,7 @@ object ServerCrasher : Module() { } @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { if (mc.thePlayer == null || mc.theWorld == null) { mc.timer.timerSpeed = 1.00f state = false // Disable module in case you left the server diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Speed.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Speed.kt index dfaf956..422a8ff 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Speed.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Speed.kt @@ -76,7 +76,7 @@ object Speed : Module() { } @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { if (mc.thePlayer.isSneaking || (mc.thePlayer.isInWater && noWater.get())) { return } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiBot.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiBot.kt index 3c8fb21..fd6b14a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiBot.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiBot.kt @@ -39,6 +39,7 @@ object AntiBot : Module() { private val removeFromWorld = BoolValue("RemoveFromWord", false) private val debugValue = BoolValue("Debug", true) + private val kkBot = BoolValue("KKBot",false) private val tabValue = BoolValue("Tab", true).displayable { modeValue.get() == "Custom"} private val tabModeValue = ListValue("TabMode", arrayOf("Equals", "Contains"), "Contains").displayable { modeValue.get() == "Custom"} private val entityIDValue = BoolValue("EntityID", true).displayable { modeValue.get() == "Custom"} @@ -118,6 +119,7 @@ object AntiBot : Module() { private val swing = mutableListOf() private val invisible = mutableListOf() private val hitted = mutableListOf() + private val KKList = mutableListOf() private val spawnInCombat = mutableListOf() private val notAlwaysInRadius = mutableListOf() private val propertiesList = mutableSetOf() @@ -224,6 +226,14 @@ object AntiBot : Module() { for (bot in bots) removeBot(bot) } + + if (kkBot.get()) { + mc.theWorld.playerEntities.forEach { player -> + if (player.inventory.armorInventory.all { it == null }) { + KKList.add(player.entityId) + } + } + } } private fun removeBot(bot: Entity) { @@ -247,6 +257,9 @@ object AntiBot : Module() { if (entity in botList) return true + if (kkBot.get() && KKList.contains(entity.entityId)) + return true + if (modeValue.get() != "Custom") return false @@ -635,6 +648,7 @@ object AntiBot : Module() { hasRemovedEntities.clear() matrix.clear() propertiesList.clear() + KKList.clear() } } \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiStaff.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiStaff.kt index 617d54c..b7de42e 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiStaff.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/AntiStaff.kt @@ -30,9 +30,6 @@ import java.util.concurrent.ConcurrentHashMap @ModuleInfo("AntiStaff", category = ModuleCategory.OTHER) object AntiStaff : Module() { - - const val CLIENT_CLOUD = "https://cloud.liquidbounce.net/LiquidBounce" - private val staffMode = object : ListValue("StaffMode", arrayOf("BlocksMC", "CubeCraft", "Gamster", "AgeraPvP", "HypeMC", "Hypixel", "SuperCraft", "PikaNetwork", "GommeHD","KKCraft"), "BlocksMC") { } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/CombatVisuals.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/CombatVisuals.kt index 0dacdc5..30dc4f0 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/CombatVisuals.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/CombatVisuals.kt @@ -45,6 +45,7 @@ import net.minecraft.potion.Potion import net.minecraft.util.EnumParticleTypes import net.minecraft.util.MathHelper import net.minecraft.util.ResourceLocation +import org.lwjgl.opengl.GL11 import java.awt.Color import java.io.File import java.io.IOException @@ -171,16 +172,12 @@ object CombatVisuals : Module() { ) "rectangle","round" -> { - // No null pointer anymore - auraESPAnim.setDirection( - if (!(combat.target!!.isDead || mc.thePlayer.getDistanceToEntity( - combat.target - ) > 10) - ) Direction.FORWARDS else Direction.BACKWARDS - ) - if (!auraESPAnim.finished(Direction.BACKWARDS)) { + if (!(combat.target!!.isDead || mc.thePlayer.getDistanceToEntity( + combat.target + ) > 10) + ) { val dst = mc.thePlayer.getSmoothDistanceToEntity(combat.target) - val vector2f = RenderUtil.targetESPSPos(combat.target, event.partialTicks) ?: return + val vector2f = RenderUtil.targetESPSPos(combat.target, event.partialTicks) RenderUtil.drawTargetESP2D( vector2f.x, vector2f.y, diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/Particles.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/Particles.kt index c8b761d..eb76e37 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/Particles.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/Particles.kt @@ -32,12 +32,12 @@ class Particles : Module() { private val physics = BoolValue("Physics", true) - private val startred = IntegerValue("StartRed", 255 ,0, 255) - private val startgreen = IntegerValue("StartGreen", 150 ,0, 255) - private val startblue = IntegerValue("StartBlue", 200 ,0, 255) - private val endred = IntegerValue("EndRed", 100 ,0, 255) - private val endgreen = IntegerValue("EndGreen", 110 ,0, 255) - private val endblue = IntegerValue("EndBlue", 195 ,0, 255) + private val startred = IntegerValue("StartRed", 255, 0, 255) + private val startgreen = IntegerValue("StartGreen", 150, 0, 255) + private val startblue = IntegerValue("StartBlue", 200, 0, 255) + private val endred = IntegerValue("EndRed", 100, 0, 255) + private val endgreen = IntegerValue("EndGreen", 110, 0, 255) + private val endblue = IntegerValue("EndBlue", 195, 0, 255) private val particles: MutableList = EvictingList(100) private val timer = ParticleTimer() @@ -69,6 +69,7 @@ class Particles : Module() { target = null } } + private fun renderParticles(particles: List) { GL11.glEnable(GL11.GL_BLEND) GL11.glDisable(GL11.GL_TEXTURE_2D) @@ -112,7 +113,8 @@ class Particles : Module() { 0.0 ) val c = RenderUtils.getGradientOffset( - Color(startred.get(), startgreen.get(), startblue.get(), 1), Color(endred.get(), endgreen.get(), endblue.get(), 1), + Color(startred.get(), startgreen.get(), startblue.get(), 1), + Color(endred.get(), endgreen.get(), endblue.get(), 1), (abs( (System.currentTimeMillis() / 100 + (20 / 10)).toDouble() ) / 10) @@ -151,25 +153,26 @@ class Particles : Module() { @EventTarget fun onRender3D(event: Render3DEvent?) { - if (particles.isEmpty()) return + if (particles.isNotEmpty()) { - var i = 0 - while (i <= timer.elapsedTime / 1E+11) { - if (physics.get()) particles.forEach(Consumer { obj: Particle -> obj.update() }) - else particles.forEach(Consumer { obj: Particle -> obj.updateWithoutPhysics() }) - i++ - } + var i = 0 + while (i <= timer.elapsedTime / 1E+11) { + if (physics.get()) particles.forEach(Consumer { obj: Particle -> obj.update() }) + else particles.forEach(Consumer { obj: Particle -> obj.updateWithoutPhysics() }) + i++ + } - particles.removeIf { particle: Particle -> - mc.thePlayer.getDistanceSq( - particle.position.xCoord, - particle.position.yCoord, - particle.position.zCoord - ) > 50 * 10 - } + particles.removeIf { particle: Particle -> + mc.thePlayer.getDistanceSq( + particle.position.xCoord, + particle.position.yCoord, + particle.position.zCoord + ) > 50 * 10 + } - timer.reset() + timer.reset() - renderParticles(particles) + renderParticles(particles) + } } } \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/FastBreak.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/FastBreak.kt index 68d4985..357d08a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/FastBreak.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/FastBreak.kt @@ -25,8 +25,8 @@ object FastBreak : Module() { mc.playerController.curBlockDamageMP = 1F } - if (Breaker.currentDamage > breakDamageValue.get()) { - Breaker.currentDamage = 1F + if (Fucker.currentDamage > breakDamageValue.get()) { + Fucker.currentDamage = 1F } } } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Breaker.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt similarity index 88% rename from src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Breaker.kt rename to src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt index 5f43ca5..9bb3f08 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Breaker.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt @@ -25,6 +25,10 @@ import net.ccbluex.liquidbounce.utils.block.BlockUtils.getCenterDistance import net.ccbluex.liquidbounce.utils.extensions.getBlock import net.ccbluex.liquidbounce.utils.extensions.getEyeVec3 import net.ccbluex.liquidbounce.utils.render.RenderUtils +import net.ccbluex.liquidbounce.utils.render.RenderUtils.disableGlCap +import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBlockBox +import net.ccbluex.liquidbounce.utils.render.RenderUtils.enableGlCap +import net.ccbluex.liquidbounce.utils.render.RenderUtils.resetCaps import net.ccbluex.liquidbounce.utils.timer.MSTimer import net.minecraft.block.Block import net.minecraft.block.BlockAir @@ -37,16 +41,21 @@ import net.minecraft.item.ItemFood import net.minecraft.item.ItemPotion import net.minecraft.network.play.client.C07PacketPlayerDigging import net.minecraft.network.play.client.C0APacketAnimation +import net.minecraft.network.play.server.S08PacketPlayerPosLook import net.minecraft.util.BlockPos import net.minecraft.util.EnumFacing import net.minecraft.util.Vec3 +import net.minecraft.util.Vec3i +import org.lwjgl.opengl.GL11.* import java.awt.Color import java.text.DecimalFormat import java.text.DecimalFormatSymbols import java.util.* +import kotlin.math.pow +import kotlin.math.roundToInt -@ModuleInfo(name = "Breaker", category = ModuleCategory.PLAYER) -object Breaker : Module() { +@ModuleInfo(name = "Fucker", category = ModuleCategory.PLAYER) +object Fucker : Module() { /** * SETTINGS @@ -74,8 +83,9 @@ object Breaker : Module() { private val coolDownValue = IntegerValue("Cooldown-Seconds", 15, 0, 60) private val toggleResetCDValue = BoolValue("ResetCoolDownWhenToggled", false) private val resetOnWorldValue = BoolValue("ResetOnWorldChange", false).displayable { ignoreFirstBlockValue.get() } - private val renderValue = ListValue("Render-Mode", arrayOf("Box", "Outline", "2D", "None"), "Box") - private val renderBed = BoolValue("RenderBed", true) + + private val ignoreOwnBed = BoolValue("IgnoreOwnBed", true) + private val ownBedDist = IntegerValue("MaxBedDistance", 16, 1,32) /** * VALUES @@ -96,6 +106,8 @@ object Breaker : Module() { private var lastWorld: WorldClient? = null + private var spawnLocation: Vec3? = null + //Bed ESP private val searchTimer = MSTimer() private val posList: MutableList = ArrayList() @@ -208,6 +220,10 @@ object Breaker : Module() { var currentPos = pos ?: return var rotations = RotationUtils.faceBlock(currentPos) ?: return + if (ignoreOwnBed.get() && isBedNearSpawn(currentPos)) { + return + } + // Surroundings var surroundings = false @@ -348,28 +364,74 @@ object Breaker : Module() { } @EventTarget - fun onRender3D(event: Render3DEvent) { - val blockPoss = pos!! - val x = blockPoss.x - mc.renderManager.renderPosX - val y = blockPoss.y - mc.renderManager.renderPosY - val z = blockPoss.z - mc.renderManager.renderPosZ - if (renderBed.get()) { - synchronized(posList) { - for (blockPos in posList) { - val bedx = blockPos.x - mc.renderManager.renderPosX - val bedy = blockPos.y - mc.renderManager.renderPosY - val bedz = blockPos.z - mc.renderManager.renderPosZ - RenderUtils.renderBox(bedx + 0.5, bedy - 0.5, bedz + 0.5, 1.0F, 1.0F, color) - GlStateManager.resetColor() - } - } + fun onPacket(event: PacketEvent) { + val packet = event.packet + if (packet is S08PacketPlayerPosLook) { + val pos = BlockPos(packet.x, packet.y, packet.z) + + spawnLocation = Vec3(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble()) } - when (renderValue.get().lowercase()) { - "box" -> RenderUtils.drawBlockBox(pos ?: return, if (!coolDownTimer.hasTimePassed(coolDownValue.get().toLong() * 1000L)) Color.DARK_GRAY else Color.RED, false) - "outline" -> RenderUtils.drawBlockBox(pos ?: return, if (!coolDownTimer.hasTimePassed(coolDownValue.get().toLong() * 1000L)) Color.DARK_GRAY else Color.RED, true) - "2d" -> RenderUtils.draw2D(pos ?: return, if (!coolDownTimer.hasTimePassed(coolDownValue.get().toLong() * 1000L)) Color.DARK_GRAY.rgb else Color.RED.rgb, Color.BLACK.rgb) - else -> RenderUtils.drawBlockBox(pos ?: return, if (!coolDownTimer.hasTimePassed(coolDownValue.get().toLong() * 1000L)) Color.DARK_GRAY else Color.RED, false) + } + + /** + * Check if the bed at the given position is near the spawn location + */ + private fun isBedNearSpawn(currentPos: BlockPos): Boolean { + if (getBlock(currentPos) != Block.getBlockById(blockValue.get()) || spawnLocation == null) { + return false } + + val spawnPos = BlockPos(spawnLocation) + return currentPos.distanceSq(Vec3i(spawnPos.x, spawnPos.y, spawnPos.z)) < ownBedDist.get().toDouble().pow(2).roundToInt() + } + + @EventTarget + fun onRender3D(event: Render3DEvent) { + val pos = pos ?: return + val player = mc.thePlayer ?: return + val renderManager = mc.renderManager + + if (getBlockName(blockValue.get()) == "Air") return + + val progress = ((currentDamage * 100).coerceIn(0f, 100f)).toInt() + val progressText = "%d%%".format(progress) + + glPushAttrib(GL_ENABLE_BIT) + glPushMatrix() + + // Translate to block position + glTranslated( + pos.x + 0.5 - renderManager.renderPosX, + pos.y + 0.5 - renderManager.renderPosY, + pos.z + 0.5 - renderManager.renderPosZ + ) + + glRotatef(-renderManager.playerViewY, 0F, 1F, 0F) + glRotatef(renderManager.playerViewX, 1F, 0F, 0F) + + disableGlCap(GL_LIGHTING, GL_DEPTH_TEST) + enableGlCap(GL_BLEND) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) + + val fontRenderer = Fonts.font40 + val color = Color.RED.rgb + + // Scale + val scale = ((player.getDistanceSq(pos) / 8F).coerceAtLeast(1.5) / 150F) * 2f + glScaled(-scale, -scale, scale) + + // Draw text + val width = mc.fontRendererObj.getStringWidth(progressText) * 0.5f + mc.fontRendererObj.drawString( + progressText, -width, if (fontRenderer == Fonts.minecraftFont) 1F else 1.5F, color, true + ) + + resetCaps() + glPopMatrix() + glPopAttrib() + + // Render block box + drawBlockBox(pos, Color.RED, true) } @EventTarget diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java index 1759ffb..b421d89 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java @@ -52,8 +52,6 @@ import java.nio.ByteBuffer; import java.util.Objects; -import static net.minecraft.client.Minecraft.getSystemTime; - @Mixin(Minecraft.class) public abstract class MixinMinecraft { @@ -214,7 +212,7 @@ private void injectGameRuntimeTicks(CallbackInfo ci) { @Inject(method = "runTick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;joinPlayerCounter:I", shift = At.Shift.BEFORE, ordinal = 0)) private void onTick(final CallbackInfo callbackInfo) { - FDPClient.eventManager.callEvent(new TickEvent()); + FDPClient.eventManager.callEvent(new GameTickEvent()); } @Inject(method = "dispatchKeypresses", at = @At(value = "HEAD")) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java index 3891f6c..9548ad4 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java @@ -38,6 +38,7 @@ import net.minecraft.network.play.client.C0BPacketEntityAction; import net.minecraft.potion.Potion; import net.minecraft.util.*; +import net.minecraftforge.fml.common.gameevent.TickEvent; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -137,101 +138,100 @@ public abstract class MixinEntityPlayerSP extends MixinAbstractClientPlayer { */ @Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true) public void onUpdateWalkingPlayer(CallbackInfo ci) { - try { - final StrafeFix strafeFix = FDPClient.moduleManager.getModule(StrafeFix.class); - Objects.requireNonNull(strafeFix).updateOverwrite(); - - MotionEvent motionEvent = new MotionEvent( - posX, - getEntityBoundingBox().minY, - posZ, - onGround, - EventState.PRE - ); - - FDPClient.eventManager.callEvent(motionEvent); - - boolean flag = this.isSprinting(); - //alert("Attempt: " + debug_AttemptSprint + " Actual: " + this.isSprinting() + " Server: " + this.serverSprintState); - if (flag != this.serverSprintState) { - if (flag) { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.START_SPRINTING)); - } else { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.STOP_SPRINTING)); - } - - this.serverSprintState = flag; + final StrafeFix strafeFix = FDPClient.moduleManager.getModule(StrafeFix.class); + Objects.requireNonNull(strafeFix).updateOverwrite(); + + MotionEvent motionEvent = new MotionEvent( + posX, + getEntityBoundingBox().minY, + posZ, + onGround, + EventState.PRE + ); + + FDPClient.eventManager.callEvent(motionEvent); + + boolean flag = this.isSprinting(); + //alert("Attempt: " + debug_AttemptSprint + " Actual: " + this.isSprinting() + " Server: " + this.serverSprintState); + if (flag != this.serverSprintState) { + if (flag) { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.START_SPRINTING)); + } else { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.STOP_SPRINTING)); } - boolean flag1 = this.isSneaking(); - if (flag1 != this.serverSneakState) { - if (flag1) { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.START_SNEAKING)); - } else { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.STOP_SNEAKING)); - } + this.serverSprintState = flag; + } - this.serverSneakState = flag1; + boolean flag1 = this.isSneaking(); + if (flag1 != this.serverSneakState) { + if (flag1) { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.START_SNEAKING)); + } else { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction((EntityPlayerSP) (Object) this, C0BPacketEntityAction.Action.STOP_SNEAKING)); } - if (this.isCurrentViewEntity()) { - float yaw = rotationYaw; - float pitch = rotationPitch; - float lastReportedYaw = Objects.requireNonNull(RotationUtils.serverRotation).getYaw(); - float lastReportedPitch = RotationUtils.serverRotation.getPitch(); + this.serverSneakState = flag1; + } - if (RotationUtils.targetRotation != null) { - yaw = RotationUtils.targetRotation.getYaw(); - pitch = RotationUtils.targetRotation.getPitch(); - } + if (this.isCurrentViewEntity()) { + float yaw = rotationYaw; + float pitch = rotationPitch; + float lastReportedYaw = Objects.requireNonNull(RotationUtils.serverRotation).getYaw(); + float lastReportedPitch = RotationUtils.serverRotation.getPitch(); - double xDiff = this.posX - this.lastReportedPosX; - double yDiff = this.getEntityBoundingBox().minY - this.lastReportedPosY; - double zDiff = this.posZ - this.lastReportedPosZ; - double yawDiff = yaw - lastReportedYaw; - double pitchDiff = pitch - lastReportedPitch; - - final Flight fly = FDPClient.moduleManager.getModule(Flight.class); - final Criticals criticals = FDPClient.moduleManager.getModule(Criticals.class); - final AntiDesync antiDesync = FDPClient.moduleManager.getModule(AntiDesync.class); - boolean moved = xDiff * xDiff + yDiff * yDiff + zDiff * zDiff > 9.0E-4D || this.positionUpdateTicks >= 20 || (Objects.requireNonNull(fly).getState() && fly.getAntiDesync()) || (Objects.requireNonNull(criticals).getState() && criticals.getAntiDesync()) || (Objects.requireNonNull(antiDesync).getState() && xDiff * xDiff + yDiff * yDiff + zDiff * zDiff > 0.0D); - boolean rotated = yawDiff != 0.0D || pitchDiff != 0.0D; - - if (this.ridingEntity == null) { - if (moved && rotated) { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.posX, this.getEntityBoundingBox().minY, this.posZ, yaw, pitch, this.onGround)); - } else if (moved) { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.posX, this.getEntityBoundingBox().minY, this.posZ, this.onGround)); - } else if (rotated) { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, this.onGround)); - } else { - this.sendQueue.addToSendQueue(new C03PacketPlayer(this.onGround)); - } + if (RotationUtils.targetRotation != null) { + yaw = RotationUtils.targetRotation.getYaw(); + pitch = RotationUtils.targetRotation.getPitch(); + } + + double xDiff = motionEvent.getX() - this.lastReportedPosX; + double yDiff = motionEvent.getY() - this.lastReportedPosY; + double zDiff = motionEvent.getZ() - this.lastReportedPosZ; + double yawDiff = yaw - lastReportedYaw; + double pitchDiff = pitch - lastReportedPitch; + + final Flight fly = FDPClient.moduleManager.getModule(Flight.class); + final Criticals criticals = FDPClient.moduleManager.getModule(Criticals.class); + final AntiDesync antiDesync = FDPClient.moduleManager.getModule(AntiDesync.class); + double v = xDiff * xDiff + yDiff * yDiff + zDiff * zDiff; + boolean moved = v > 9.0E-4D || this.positionUpdateTicks >= 20 || (Objects.requireNonNull(fly).getState() && fly.getAntiDesync()) || (Objects.requireNonNull(criticals).getState() && criticals.getAntiDesync()) || (Objects.requireNonNull(antiDesync).getState() && v > 0.0D); + boolean rotated = yawDiff != 0.0D || pitchDiff != 0.0D; + + if (this.ridingEntity == null) { + if (moved && rotated) { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(motionEvent.getX(), motionEvent.getY(), motionEvent.getZ(), yaw, pitch, motionEvent.getOnGround())); + } else if (moved) { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(motionEvent.getX(), motionEvent.getY(), motionEvent.getZ(), motionEvent.getOnGround())); + } else if (rotated) { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, motionEvent.getOnGround())); } else { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D, this.motionZ, yaw, pitch, this.onGround)); - moved = false; + this.sendQueue.addToSendQueue(new C03PacketPlayer(motionEvent.getOnGround())); } + } else { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D, this.motionZ, yaw, pitch, motionEvent.getOnGround())); + moved = false; + } - ++this.positionUpdateTicks; - - if (moved) { - this.lastReportedPosX = this.posX; - this.lastReportedPosY = this.getEntityBoundingBox().minY; - this.lastReportedPosZ = this.posZ; - this.positionUpdateTicks = 0; - } + ++this.positionUpdateTicks; - if (rotated) { - this.lastReportedYaw = this.rotationYaw; - this.lastReportedPitch = this.rotationPitch; - } + if (moved) { + this.lastReportedPosX = motionEvent.getX(); + this.lastReportedPosY = motionEvent.getY(); + this.lastReportedPosZ = motionEvent.getZ(); + this.positionUpdateTicks = 0; } - FDPClient.eventManager.callEvent(new MotionEvent(posX, getEntityBoundingBox().minY, posZ, onGround, EventState.POST)); - } catch (final Exception e) { - e.printStackTrace(); + if (rotated) { + this.lastReportedYaw = this.rotationYaw; + this.lastReportedPitch = this.rotationPitch; + } } + FDPClient.eventManager.callEvent(new MotionEvent(posX, getEntityBoundingBox().minY, posZ, onGround, EventState.POST)); + + FDPClient.eventManager.callEvent(new RotationUpdateEvent()); + ci.cancel(); } @@ -790,5 +790,22 @@ public void moveEntity(double x, double y, double z) { worldObj.theProfiler.endSection(); } } + + @Inject(method = "onUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;onUpdate()V", shift = At.Shift.BEFORE, ordinal = 0), cancellable = true) + private void preTickEvent(CallbackInfo ci) { + final PlayerTickEvent tickEvent = new PlayerTickEvent(EventState.PRE); + FDPClient.eventManager.callEvent(tickEvent); + + if (tickEvent.isCancelled()) { + FDPClient.eventManager.callEvent(new RotationUpdateEvent()); + ci.cancel(); + } + } + + @Inject(method = "onUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;onUpdate()V", shift = At.Shift.AFTER, ordinal = 0)) + private void postTickEvent(CallbackInfo ci) { + final PlayerTickEvent tickEvent = new PlayerTickEvent(EventState.POST); + FDPClient.eventManager.callEvent(tickEvent); + } } diff --git a/src/main/java/net/ccbluex/liquidbounce/script/api/ScriptModule.kt b/src/main/java/net/ccbluex/liquidbounce/script/api/ScriptModule.kt index 3304f93..e6cfc7a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/script/api/ScriptModule.kt +++ b/src/main/java/net/ccbluex/liquidbounce/script/api/ScriptModule.kt @@ -124,7 +124,7 @@ class ScriptModule(private val moduleObject: JSObject) : Module() { fun onScreen(screenEvent: ScreenEvent) = callEvent("screen", screenEvent) @EventTarget - fun onTick(tickEvent: TickEvent) = callEvent("tick", tickEvent) + fun onTick(tickEvent: GameTickEvent) = callEvent("tick", tickEvent) @EventTarget fun onKey(keyEvent: KeyEvent) = callEvent("key", keyEvent) diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/clickgui/style/styles/Slight/RenderUtil.java b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/clickgui/style/styles/Slight/RenderUtil.java index 1caeaaf..dfa1398 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/clickgui/style/styles/Slight/RenderUtil.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/clickgui/style/styles/Slight/RenderUtil.java @@ -24,6 +24,8 @@ import java.nio.IntBuffer; import java.util.Objects; +import static org.lwjgl.opengl.GL11.*; + public enum RenderUtil { ; @@ -89,7 +91,7 @@ public static void drawDimRect(double x, double y, double x2, double y2, int col GL11.glVertex2d(x2, y); GL11.glVertex2d(x, y2); GL11.glVertex2d(x2, y2); - GL11.glEnd(); + glEnd(); GL11.glPopMatrix(); GL11.glEnable(3553); GL11.glDisable(3042); @@ -116,12 +118,12 @@ public static void drawImage(ResourceLocation image, int x, int y, int width, in new ScaledResolution(Minecraft.getMinecraft()); GL11.glDisable(2929); GL11.glEnable(3042); - GL11.glDepthMask(false); + glDepthMask(false); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); Minecraft.getMinecraft().getTextureManager().bindTexture(image); Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, width, height2, (float) width, (float) height2); - GL11.glDepthMask(true); + glDepthMask(true); GL11.glDisable(3042); GL11.glEnable(2929); } @@ -229,7 +231,7 @@ public static void arcEllipse(float x, float y, float start, float end, float w, GL11.glVertex2f(x + ldx, y + ldy); } - GL11.glEnd(); + glEnd(); GL11.glDisable(2848); } @@ -241,7 +243,7 @@ public static void arcEllipse(float x, float y, float start, float end, float w, GL11.glVertex2f(x + ldx, y + ldy); } - GL11.glEnd(); + glEnd(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } @@ -276,7 +278,7 @@ public static void arcEllipse(float x, float y, float start, float end, float w, GL11.glVertex2f(x + ldx, y + ldy); } - GL11.glEnd(); + glEnd(); GL11.glDisable(2848); } @@ -288,7 +290,7 @@ public static void arcEllipse(float x, float y, float start, float end, float w, GL11.glVertex2f(x + ldx, y + ldy); } - GL11.glEnd(); + glEnd(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } @@ -439,6 +441,16 @@ private static void drawESPImage(ResourceLocation resource, double x, double y, tessellator.draw(); GlStateManager.depthMask(true); GlStateManager.shadeModel(7424); + glEnd(); + + glShadeModel(GL_FLAT); + glDepthMask(true); + glEnable(GL_DEPTH_TEST); + GlStateManager.enableCull(); + glDisable(GL_LINE_SMOOTH); + glEnable(GL_TEXTURE_2D); + glPopMatrix(); + glColor4f(1f, 1f, 1f, 1f); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/MathUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/MathUtils.kt index f25393d..5478c4c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/MathUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/MathUtils.kt @@ -23,6 +23,8 @@ fun Double.toRadians() = this * 0.017453292 fun Double.toRadiansF() = toRadians().toFloat() fun Double.toDegrees() = this * 57.295779513 fun Double.toDegreesF() = toDegrees().toFloat() + +fun Vec3.toFloatTriple() = Triple(xCoord.toFloat(), yCoord.toFloat(), zCoord.toFloat()) object MathUtils { const val DEGREES_TO_RADIANS = 0.017453292519943295 diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/MouseUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/MouseUtils.kt index a4c31ce..72b55c6 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/MouseUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/MouseUtils.kt @@ -8,7 +8,7 @@ package net.ccbluex.liquidbounce.utils import net.ccbluex.liquidbounce.FDPClient import net.ccbluex.liquidbounce.event.ClickBlockEvent import net.ccbluex.liquidbounce.features.module.modules.exploit.MultiActions -import net.ccbluex.liquidbounce.features.module.modules.world.Breaker +import net.ccbluex.liquidbounce.features.module.modules.world.Fucker import net.ccbluex.liquidbounce.utils.MinecraftInstance.Companion.mc import net.minecraft.block.material.Material import net.minecraft.util.BlockPos @@ -64,7 +64,7 @@ object MouseUtils { mc.effectRenderer.addBlockHitEffects(blockpos, mc.objectMouseOver.sideHit) mc.thePlayer.swingItem() } - } else if (!FDPClient.moduleManager.getModule(Breaker::class.java)!!.state) { + } else if (!FDPClient.moduleManager.getModule(Fucker::class.java)!!.state) { mc.playerController.resetBlockRemoving() } } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/PacketCounterUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/PacketCounterUtils.kt index 15dc4cd..f4dc4b5 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/PacketCounterUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/PacketCounterUtils.kt @@ -26,7 +26,7 @@ object PacketCounterUtils : Listenable { } @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { if (packetTimer.hasTimePassed(1000L)) { avgInBound = inBound avgOutBound = outBound diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/PlayerUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/PlayerUtils.kt index 08f9152..8960949 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/PlayerUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/PlayerUtils.kt @@ -1,8 +1,12 @@ package net.ccbluex.liquidbounce.utils +import kevin.utils.minus import kevin.utils.multiply import net.ccbluex.liquidbounce.features.module.modules.client.Animations import net.ccbluex.liquidbounce.utils.MinecraftInstance.Companion.mc +import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket +import net.ccbluex.liquidbounce.utils.block.BlockUtils.getState +import net.ccbluex.liquidbounce.utils.block.BlockUtils.toVec import net.ccbluex.liquidbounce.utils.extensions.eyes import net.minecraft.block.BlockSlime import net.minecraft.client.entity.EntityPlayerSP @@ -12,14 +16,14 @@ import net.minecraft.entity.boss.EntityDragonPart import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayerMP import net.minecraft.item.* +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement import net.minecraft.network.play.server.S12PacketEntityVelocity import net.minecraft.potion.Potion import net.minecraft.stats.AchievementList import net.minecraft.stats.StatList -import net.minecraft.util.AxisAlignedBB -import net.minecraft.util.DamageSource -import net.minecraft.util.MathHelper +import net.minecraft.util.* import net.minecraftforge.common.ForgeHooks +import net.minecraftforge.event.ForgeEventFactory import kotlin.math.roundToInt @@ -120,8 +124,7 @@ object PlayerUtils { var f: Float = mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage).attributeValue.toFloat() var i = 0 - var f1 = 0.0f - f1 = if (entity is EntityLivingBase) { + val f1: Float = if (entity is EntityLivingBase) { EnchantmentHelper.getModifierForCreature( mc.thePlayer.heldItem, entity.creatureAttribute @@ -231,4 +234,66 @@ object PlayerUtils { } } + // Modified mc.playerController.onPlayerRightClick() that sends correct stack in its C08 + fun EntityPlayerSP.onPlayerRightClick( + clickPos: BlockPos, side: EnumFacing, clickVec: Vec3, + stack: ItemStack?, + ): Boolean { + if (clickPos !in worldObj.worldBorder) + return false + + mc.playerController?.updateController() + + val (facingX, facingY, facingZ) = (clickVec - clickPos.toVec()).toFloatTriple() + + val sendClick = { + sendPacket(C08PacketPlayerBlockPlacement(clickPos, side.index, stack, facingX, facingY, facingZ)) + true + } + + // If player is a spectator, send click and return true + if (mc.playerController.isSpectator) + return sendClick() + + val item = stack?.item + + if (item?.onItemUseFirst(stack, this, worldObj, clickPos, side, facingX, facingY, facingZ) == true) + return true + + val blockState = getState(clickPos) + + // If click had activated a block, send click and return true + if ((!isSneaking || item == null || item.doesSneakBypassUse(worldObj, clickPos, this)) + && blockState.block?.onBlockActivated(worldObj, + clickPos, + blockState, + this, + side, + facingX, + facingY, + facingZ + ) == true) + return sendClick() + + if (item is ItemBlock && !item.canPlaceBlockOnSide(worldObj, clickPos, side, this, stack)) + return false + + sendClick() + + if (stack == null) + return false + + val prevMetadata = stack.metadata + val prevSize = stack.stackSize + + return stack.onItemUse(this, worldObj, clickPos, side, facingX, facingY, facingZ).also { + if (mc.playerController.isInCreativeMode) { + stack.itemDamage = prevMetadata + stack.stackSize = prevSize + } else if (stack.stackSize <= 0) { + ForgeEventFactory.onPlayerDestroyItem(this, stack) + } + } + } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt index 0b8b59e..18413bd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt @@ -5,16 +5,14 @@ */ package net.ccbluex.liquidbounce.utils -import kevin.utils.component1 -import kevin.utils.component2 -import kevin.utils.component3 -import kevin.utils.minus +import kevin.utils.* import net.ccbluex.liquidbounce.event.EventTarget import net.ccbluex.liquidbounce.event.Listenable import net.ccbluex.liquidbounce.event.PacketEvent -import net.ccbluex.liquidbounce.event.TickEvent +import net.ccbluex.liquidbounce.event.GameTickEvent import net.ccbluex.liquidbounce.utils.RaycastUtils.raycastEntity import net.ccbluex.liquidbounce.utils.extensions.eyes +import net.ccbluex.liquidbounce.utils.extensions.getBlock import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.projectile.EntityEgg @@ -30,7 +28,7 @@ class RotationUtils : MinecraftInstance(), Listenable { * @param event Tick event */ @EventTarget - fun onTick(event: TickEvent?) { + fun onTick(event: GameTickEvent?) { if (targetRotation != null) { //ClientUtils.INSTANCE.displayAlert(keepLength + " " + revTick); keepLength-- @@ -961,5 +959,24 @@ class RotationUtils : MinecraftInstance(), Listenable { val pitch = (-(atan2(y, dist) * 180.0 / 3.141592653589793)).toFloat() return Rotation(yaw, pitch) } + + @JvmStatic + fun performRaytrace( + blockPos: BlockPos, + rotation: Rotation, + reach: Float = mc.playerController.blockReachDistance, + ): MovingObjectPosition? { + val world = mc.theWorld ?: return null + val player = mc.thePlayer ?: return null + + val eyes = player.eyes + + return blockPos.getBlock()?.collisionRayTrace( + world, + blockPos, + eyes, + eyes + (getVectorForRotation(rotation) * reach.toDouble()) + ) + } } } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/block/BlockUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/block/BlockUtils.kt index 0ce3aea..1dea45d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/block/BlockUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/block/BlockUtils.kt @@ -150,6 +150,25 @@ object BlockUtils : MinecraftInstance() { return false } + /** + * Check if block bounding box is full or partial (non-full) + */ + fun isBlockBBValid(blockPos: BlockPos, blockState: IBlockState? = null, supportSlabs: Boolean = false, supportPartialBlocks: Boolean = false): Boolean { + val state = blockState ?: getState(blockPos) ?: return false + + val box = state.block.getCollisionBoundingBox(mc.theWorld, blockPos, state) ?: return false + + // Support blocks like stairs, slab (1x), dragon-eggs, glass-panes, fences, etc + if (supportPartialBlocks && (box.maxY - box.minY < 1.0 || box.maxX - box.minX < 1.0 || box.maxZ - box.minZ < 1.0)) { + return true + } + + // The slab will only return true if it's placed at a level that can be placed like any normal full block + return box.maxX - box.minX == 1.0 && (box.maxY - box.minY == 1.0 || supportSlabs && box.maxY % 1.0 == 0.0) && box.maxZ - box.minZ == 1.0 + } + + fun BlockPos.toVec() = Vec3(this) + @JvmStatic fun floorVec3(vec3: Vec3) = Vec3(floor(vec3.xCoord), floor(vec3.yCoord), floor(vec3.zCoord)) } \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/waitTickUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/waitTickUtils.kt index 1ff7997..725e5b0 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/waitTickUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/waitTickUtils.kt @@ -6,9 +6,8 @@ package net.ccbluex.liquidbounce.utils.timing import net.ccbluex.liquidbounce.event.EventTarget -import net.ccbluex.liquidbounce.event.GameTickEvent import net.ccbluex.liquidbounce.event.Listenable -import net.ccbluex.liquidbounce.event.TickEvent +import net.ccbluex.liquidbounce.event.GameTickEvent import net.ccbluex.liquidbounce.utils.ClientUtils import net.ccbluex.liquidbounce.utils.MinecraftInstance @@ -21,7 +20,7 @@ object WaitTickUtils : MinecraftInstance(), Listenable { } @EventTarget - fun onTick(event: TickEvent) { + fun onTick(event: GameTickEvent) { val currentTick = ClientUtils.runTimeTicks val iterator = scheduledActions.iterator()