From 8887f0b53b3b90d9e1c6cd96e879102906cf762f Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Thu, 6 Oct 2022 16:00:12 +0100 Subject: [PATCH 1/4] Rewrite the old KAMI Jesus --- .../mixin/MixinStateImplementation.java | 8 +- .../player/AccessorEntityPlayerSP.java | 3 + .../events/AddCollisionBoxToListEvent.kt | 10 + .../client/module/modules/movement/Jesus.kt | 219 ++++++++++++++---- 4 files changed, 191 insertions(+), 49 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt diff --git a/src/main/java/com/lambda/mixin/MixinStateImplementation.java b/src/main/java/com/lambda/mixin/MixinStateImplementation.java index 209588a58..9272b984b 100644 --- a/src/main/java/com/lambda/mixin/MixinStateImplementation.java +++ b/src/main/java/com/lambda/mixin/MixinStateImplementation.java @@ -1,9 +1,12 @@ package com.lambda.mixin; +import com.lambda.client.event.LambdaEventBus; +import com.lambda.client.event.events.AddCollisionBoxToListEvent; import com.lambda.client.module.modules.movement.Jesus; import com.lambda.client.module.modules.render.Xray; import net.minecraft.block.Block; import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; @@ -26,7 +29,10 @@ public class MixinStateImplementation { @Inject(method = "addCollisionBoxToList", at = @At("HEAD")) public void addCollisionBoxToList(World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, Entity entityIn, boolean isActualState, CallbackInfo ci) { - Jesus.handleAddCollisionBoxToList(pos, block, entityIn, collidingBoxes); + + if (entityIn instanceof EntityPlayerSP) + LambdaEventBus.INSTANCE.post(new AddCollisionBoxToListEvent(collidingBoxes)); + } @Inject(method = "shouldSideBeRendered", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java b/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java index 9d1e069de..0831fd077 100644 --- a/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java @@ -10,4 +10,7 @@ public interface AccessorEntityPlayerSP { @Accessor("handActive") void kbSetHandActive(boolean value); + @Accessor("lastReportedPosY") + void lcSetLastReportedY(double value); + } diff --git a/src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt b/src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt new file mode 100644 index 000000000..ba9f3eaa6 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt @@ -0,0 +1,10 @@ +package com.lambda.client.event.events + +import com.lambda.client.event.Event +import net.minecraft.util.math.AxisAlignedBB + +/** + * @author Doogie13 + * @since 06/10/2022 + */ +class AddCollisionBoxToListEvent(val collisionBoxList : MutableList) : Event \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index 659f3263b..7dd70cdd1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -1,98 +1,221 @@ package com.lambda.client.module.modules.movement -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.event.events.AddCollisionBoxToListEvent import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.PlayerTravelEvent -import com.lambda.client.mixin.extension.playerMoving +import com.lambda.client.event.events.PlayerMoveEvent +import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.EntityUtils import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP import net.minecraft.block.Block -import net.minecraft.block.BlockLiquid -import net.minecraft.entity.Entity -import net.minecraft.entity.item.EntityBoat +import net.minecraft.init.Blocks import net.minecraft.network.play.client.CPacketPlayer +import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.math.AxisAlignedBB import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.BlockPos.PooledMutableBlockPos +import net.minecraftforge.client.event.InputUpdateEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent +import kotlin.math.ceil +import kotlin.math.floor +import kotlin.math.hypot + object Jesus : Module( name = "Jesus", description = "Allows you to walk on water", category = Category.MOVEMENT ) { - private val mode by setting("Mode", Mode.SOLID) - private enum class Mode { - SOLID, DOLPHIN + private val mode by setting("Mode", Mode.STRICT) + + enum class Mode { + SOLID, + STRICT, + DOLPHIN } - private val waterWalkBox = AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.99, 1.0) + private val preventJump by setting("Prevent Jumping", false, { mode == Mode.SOLID || mode == Mode.STRICT }, description = "Prevent jumping when using jesus") + + private val bb = AxisAlignedBB(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0) + + private var ticksEnabled = 0 + private var fakeY = 0.0 init { - onToggle { - BaritoneUtils.settings?.assumeWalkOnWater?.value = it + + onDisable { + + ticksEnabled = 0 + + var i = 0 + while (true) { + i++ + fakeY += .1 + if (fakeY > 0) break + mc.player.connection.sendPacket(CPacketPlayer.Position(mc.player.posX, mc.player.posY + fakeY, mc.player.posZ, false)) + } + + modifyTimer(50 * i.toFloat()) + + fakeY = .0 + + } + + safeListener { + + if (it.phase == TickEvent.Phase.START) + ticksEnabled++ + } - safeListener { - if (mc.gameSettings.keyBindSneak.isKeyDown || player.fallDistance > 3.0f || !isInWater(player)) return@safeListener + safeListener { - if (mode == Mode.DOLPHIN) { - player.motionY += 0.03999999910593033 // regular jump speed - } else { - player.motionY = 0.1 + if (mc.gameSettings.keyBindSneak.isKeyDown) + return@safeListener - player.ridingEntity?.let { - if (it !is EntityBoat) it.motionY = 0.3 + if ((mode == Mode.SOLID || mode == Mode.STRICT) + && mc.world.getBlockState(BlockPos(mc.player.positionVector.add(.0, -.1 + mc.player.motionY, .0))).material.isLiquid) + it.collisionBoxList.add(bb.offset(mc.player.posX, floor(mc.player.posY), mc.player.posZ)) + + } + + safeListener { event -> + + (player as AccessorEntityPlayerSP).lcSetLastReportedY(-99.9) + + if (mc.gameSettings.keyBindSneak.isKeyDown) + return@safeListener + + (mc.player as AccessorEntityPlayerSP).lcSetLastReportedY(-999.0) + + if (mc.player.isInWater || mc.world.getBlockState(BlockPos(mc.player.positionVector)).material.isLiquid) event.y = (.11.also { mc.player.motionY = it }) + + if (mc.player.onGround && !checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, -.01, .0), + listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) { + + if (mode == Mode.DOLPHIN) { + + if (hypot(event.x, event.y) > .2873 * .9) { + event.x *= .95 + event.z *= .95 + } + + } else if (mode == Mode.STRICT) { + val lava = !checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, -.01, .0), listOf(Blocks.AIR, Blocks.LAVA, Blocks.FLOWING_LAVA)) + // .38 is from lava liquid speed at max speed, 1.24 is from water liquid speed at max speed + // because of the way "Lambda Client" handled its "PlayerMoveEvent" I have to use "magic numbers" to compensate + event.x *= if (lava) .57 else 1.09 + event.z *= if (lava) .57 else 1.09 } + } } + safeListener { + + if (preventJump && + !checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, -.01, .0), + listOf(Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA)) + ) + it.movementInput.jump = false + + } + safeListener { - if (it.packet !is CPacketPlayer || !it.packet.playerMoving) return@safeListener - if (mc.gameSettings.keyBindSneak.isKeyDown || player.ticksExisted % 2 != 0) return@safeListener - val entity = player.ridingEntity ?: player + if (it.packet is CPacketPlayer) { + if (mc.gameSettings.keyBindSneak.isKeyDown) { + + if (mode == Mode.STRICT) + mc.player.posY -= fakeY + + fakeY = 0.0 + + return@safeListener + + } + + val playerBB = mc.player.entityBoundingBox + if (mc.player.isInWater || + !mc.world.getBlockState(BlockPos(mc.player.positionVector.add(.0, -.1 + mc.player.motionY, .0))).material.isLiquid || + mc.world.getCollisionBoxes(mc.player, playerBB.offset(0.0, -.0001, 0.0)).isEmpty()) { + fakeY = 0.0 + return@safeListener + } + + val packet = it.packet + + if (mode == Mode.STRICT) { + + if ((-.4).coerceAtLeast(fakeY).also { fakeY = it } > -.4) { + + fakeY -= .08 + fakeY *= .98 + packet.playerY += fakeY + + } else + packet.playerY += fakeY - if (ticksEnabled % 2 == 0) .0 else -.00001 + + if (checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, packet.playerY - mc.player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) + packet.playerY = mc.player.posY + + } else if (mode == Mode.SOLID) { + + fakeY = 0.0 + + if (ticksEnabled % 2 == 0) + packet.playerY -= .001 + + if (checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, packet.playerY - mc.player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) + packet.playerY = mc.player.posY + } - if (EntityUtils.isAboveLiquid(entity, true) && !isInWater(entity)) { - it.packet.playerY += 0.02 } + + } + + safeListener { + + if (it.packet is SPacketPlayerPosLook) + fakeY = mc.player.posY - it.packet.y + } } - @JvmStatic - fun handleAddCollisionBoxToList(pos: BlockPos, block: Block, entity: Entity?, collidingBoxes: MutableList) { - if (isDisabled || mode == Mode.DOLPHIN) return - if (mc.gameSettings.keyBindSneak.isKeyDown) return - if (block !is BlockLiquid) return - if (entity == null || entity is EntityBoat) return + // modified mc code + private fun checkBlockCollisionNoLiquid(bb: AxisAlignedBB, allowed: List): Boolean { - val player = mc.player ?: return - if (player.fallDistance > 3.0f) return + val minX = floor(bb.minX).toInt() + val maxX = ceil(bb.maxX).toInt() + val minY = floor(bb.minY).toInt() + val maxY = ceil(bb.maxY).toInt() + val minZ = floor(bb.minZ).toInt() + val maxZ = ceil(bb.maxZ).toInt() - if (entity != player && entity != player.ridingEntity) return - if (isInWater(entity) || entity.posY < pos.y) return - if (!EntityUtils.isAboveLiquid(entity)) return + val mutableBlockPos = PooledMutableBlockPos.retain() - collidingBoxes.add(waterWalkBox.offset(pos)) - } + for (x in minX until maxX) { + for (y in minY until maxY) { + for (z in minZ until maxZ) { + + val blockState = mc.world.getBlockState(mutableBlockPos.setPos(x, y, z)) - private fun isInWater(entity: Entity): Boolean { - mc.world?.let { - val y = (entity.posY + 0.01).floorToInt() + if (!allowed.contains(blockState.block)) { + mutableBlockPos.release() + return true + } - for (x in entity.posX.floorToInt() until entity.posX.ceilToInt()) { - for (z in entity.posZ.floorToInt() until entity.posZ.ceilToInt()) { - val pos = BlockPos(x, y, z) - if (it.getBlockState(pos).block is BlockLiquid) return true } } } + mutableBlockPos.release() return false + } } \ No newline at end of file From 595e01592dd5e17031afb3ec07f4ef39ff8aef01 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 16 Jan 2023 04:48:49 +0100 Subject: [PATCH 2/4] Refactor --- .../client/module/modules/movement/Jesus.kt | 180 +++++++++--------- 1 file changed, 87 insertions(+), 93 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index 7dd70cdd1..af96a3d4a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -1,5 +1,6 @@ package com.lambda.client.module.modules.movement +import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.AddCollisionBoxToListEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerMoveEvent @@ -7,6 +8,8 @@ import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.util.EntityUtils.flooredPosition +import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP import net.minecraft.block.Block @@ -38,7 +41,7 @@ object Jesus : Module( DOLPHIN } - private val preventJump by setting("Prevent Jumping", false, { mode == Mode.SOLID || mode == Mode.STRICT }, description = "Prevent jumping when using jesus") + private val preventJump by setting("Prevent Jumping", false, { mode == Mode.SOLID || mode == Mode.STRICT }, description = "Prevent jumping when using Jesus") private val bb = AxisAlignedBB(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0) @@ -46,149 +49,144 @@ object Jesus : Module( private var fakeY = 0.0 init { - onDisable { + runSafe { + ticksEnabled = 0 + var i = 0 + + while (fakeY <= 0) { + i++ + fakeY += .1 + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + fakeY, player.posZ, false)) + } - ticksEnabled = 0 - - var i = 0 - while (true) { - i++ - fakeY += .1 - if (fakeY > 0) break - mc.player.connection.sendPacket(CPacketPlayer.Position(mc.player.posX, mc.player.posY + fakeY, mc.player.posZ, false)) + modifyTimer(50f * i) + fakeY = .0 } - - modifyTimer(50 * i.toFloat()) - - fakeY = .0 - } safeListener { - if (it.phase == TickEvent.Phase.START) ticksEnabled++ - } safeListener { - if (mc.gameSettings.keyBindSneak.isKeyDown) return@safeListener if ((mode == Mode.SOLID || mode == Mode.STRICT) - && mc.world.getBlockState(BlockPos(mc.player.positionVector.add(.0, -.1 + mc.player.motionY, .0))).material.isLiquid) - it.collisionBoxList.add(bb.offset(mc.player.posX, floor(mc.player.posY), mc.player.posZ)) - + && world.getBlockState(BlockPos(player.positionVector.add(.0, -.1 + player.motionY, .0))).material.isLiquid + ) { + it.collisionBoxList.add(bb.offset(player.posX, floor(player.posY), player.posZ)) + } } safeListener { event -> - (player as AccessorEntityPlayerSP).lcSetLastReportedY(-99.9) - if (mc.gameSettings.keyBindSneak.isKeyDown) - return@safeListener - - (mc.player as AccessorEntityPlayerSP).lcSetLastReportedY(-999.0) + if (mc.gameSettings.keyBindSneak.isKeyDown) return@safeListener - if (mc.player.isInWater || mc.world.getBlockState(BlockPos(mc.player.positionVector)).material.isLiquid) event.y = (.11.also { mc.player.motionY = it }) + (player as AccessorEntityPlayerSP).lcSetLastReportedY(-999.0) - if (mc.player.onGround && !checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, -.01, .0), - listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) { - - if (mode == Mode.DOLPHIN) { + if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { + event.y = (.11.also { player.motionY = it }) + } - if (hypot(event.x, event.y) > .2873 * .9) { - event.x *= .95 - event.z *= .95 + if (player.onGround && + !checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, -.01, .0), + listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA) + ) + ) { + when (mode) { + Mode.DOLPHIN -> { + if (hypot(event.x, event.y) > .2873 * .9) { + event.x *= .95 + event.z *= .95 + } } - - } else if (mode == Mode.STRICT) { - val lava = !checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, -.01, .0), listOf(Blocks.AIR, Blocks.LAVA, Blocks.FLOWING_LAVA)) - // .38 is from lava liquid speed at max speed, 1.24 is from water liquid speed at max speed - // because of the way "Lambda Client" handled its "PlayerMoveEvent" I have to use "magic numbers" to compensate - event.x *= if (lava) .57 else 1.09 - event.z *= if (lava) .57 else 1.09 + Mode.STRICT -> { + val lava = !checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, -.01, .0), + listOf(Blocks.AIR, Blocks.LAVA, Blocks.FLOWING_LAVA) + ) + // .38 is from lava liquid speed at max speed, 1.24 is from water liquid speed at max speed + // because of the way "Lambda Client" handled its "PlayerMoveEvent" I have to use "magic numbers" to compensate + event.x *= if (lava) .57 else 1.09 + event.z *= if (lava) .57 else 1.09 + } + else -> { } } - } } safeListener { - if (preventJump && - !checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, -.01, .0), - listOf(Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA)) - ) - it.movementInput.jump = false - + !checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, -.01, .0), + listOf(Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA) + ) + ) it.movementInput.jump = false } - safeListener { - - if (it.packet is CPacketPlayer) { - if (mc.gameSettings.keyBindSneak.isKeyDown) { - - if (mode == Mode.STRICT) - mc.player.posY -= fakeY - - fakeY = 0.0 - - return@safeListener + safeListener { event -> + if (event.packet !is CPacketPlayer) return@safeListener + if (mc.gameSettings.keyBindSneak.isKeyDown) { + if (mode == Mode.STRICT) { + player.posY -= fakeY } - val playerBB = mc.player.entityBoundingBox - if (mc.player.isInWater || - !mc.world.getBlockState(BlockPos(mc.player.positionVector.add(.0, -.1 + mc.player.motionY, .0))).material.isLiquid || - mc.world.getCollisionBoxes(mc.player, playerBB.offset(0.0, -.0001, 0.0)).isEmpty()) { - fakeY = 0.0 - return@safeListener - } + fakeY = 0.0 + return@safeListener + } - val packet = it.packet + val playerBB = player.entityBoundingBox + if (player.isInWater + || !world.getBlockState(BlockPos(player.positionVector.add(.0, -.1 + player.motionY, .0))).material.isLiquid + || world.getCollisionBoxes(player, playerBB.offset(0.0, -.0001, 0.0)).isEmpty() + ) { + fakeY = 0.0 + return@safeListener + } - if (mode == Mode.STRICT) { + val packet = event.packet + when (mode) { + Mode.STRICT -> { if ((-.4).coerceAtLeast(fakeY).also { fakeY = it } > -.4) { - fakeY -= .08 fakeY *= .98 packet.playerY += fakeY - - } else + } else { packet.playerY += fakeY - if (ticksEnabled % 2 == 0) .0 else -.00001 + } - if (checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, packet.playerY - mc.player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) - packet.playerY = mc.player.posY - - } else if (mode == Mode.SOLID) { - + if (checkBlockCollisionNoLiquid(player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) { + packet.playerY = player.posY + } + } + Mode.SOLID -> { fakeY = 0.0 - if (ticksEnabled % 2 == 0) - packet.playerY -= .001 + if (ticksEnabled % 2 == 0) packet.playerY -= .001 - if (checkBlockCollisionNoLiquid(mc.player.entityBoundingBox.offset(.0, packet.playerY - mc.player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) - packet.playerY = mc.player.posY + if (checkBlockCollisionNoLiquid(player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) { + packet.playerY = player.posY + } } - + else -> { } } - } safeListener { + if (it.packet !is SPacketPlayerPosLook) return@safeListener - if (it.packet is SPacketPlayerPosLook) - fakeY = mc.player.posY - it.packet.y - + fakeY = mc.player.posY - it.packet.y } } - // modified mc code - private fun checkBlockCollisionNoLiquid(bb: AxisAlignedBB, allowed: List): Boolean { - + private fun SafeClientEvent.checkBlockCollisionNoLiquid(bb: AxisAlignedBB, allowed: List): Boolean { val minX = floor(bb.minX).toInt() val maxX = ceil(bb.maxX).toInt() val minY = floor(bb.minY).toInt() @@ -201,21 +199,17 @@ object Jesus : Module( for (x in minX until maxX) { for (y in minY until maxY) { for (z in minZ until maxZ) { - - val blockState = mc.world.getBlockState(mutableBlockPos.setPos(x, y, z)) + val blockState = world.getBlockState(mutableBlockPos.setPos(x, y, z)) if (!allowed.contains(blockState.block)) { mutableBlockPos.release() return true } - } } } mutableBlockPos.release() return false - } - } \ No newline at end of file From dc53c3292ede10987fa3c2840128dcdd40845b7a Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 16 Jan 2023 04:54:28 +0100 Subject: [PATCH 3/4] Fix build --- .../kotlin/com/lambda/client/module/modules/movement/Jesus.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index af96a3d4a..9d2ec39e6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -82,11 +82,11 @@ object Jesus : Module( } safeListener { event -> - (player as AccessorEntityPlayerSP).lcSetLastReportedY(-99.9) + (player as AccessorEntityPlayerSP).lcSetLastReportedPosY(-99.9) if (mc.gameSettings.keyBindSneak.isKeyDown) return@safeListener - (player as AccessorEntityPlayerSP).lcSetLastReportedY(-999.0) + (player as AccessorEntityPlayerSP).lcSetLastReportedPosY(-999.0) if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { event.y = (.11.also { player.motionY = it }) From 17442d63ffcadbb1761e8a34620e78ec873c23f0 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 16 Jan 2023 05:39:20 +0100 Subject: [PATCH 4/4] Fix jump prevention not working --- .../client/module/modules/movement/Jesus.kt | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index 9d2ec39e6..fb8f2fbad 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -44,30 +44,21 @@ object Jesus : Module( private val preventJump by setting("Prevent Jumping", false, { mode == Mode.SOLID || mode == Mode.STRICT }, description = "Prevent jumping when using Jesus") private val bb = AxisAlignedBB(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0) + private val liquids = listOf(Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA) private var ticksEnabled = 0 private var fakeY = 0.0 init { onDisable { - runSafe { - ticksEnabled = 0 - var i = 0 - - while (fakeY <= 0) { - i++ - fakeY += .1 - connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + fakeY, player.posZ, false)) - } - - modifyTimer(50f * i) - fakeY = .0 - } + ticksEnabled = 0 + fakeY = .0 } safeListener { - if (it.phase == TickEvent.Phase.START) - ticksEnabled++ + if (it.phase != TickEvent.Phase.START) return@safeListener + + ticksEnabled++ } safeListener { @@ -95,7 +86,7 @@ object Jesus : Module( if (player.onGround && !checkBlockCollisionNoLiquid( player.entityBoundingBox.offset(.0, -.01, .0), - listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA) + liquids + Blocks.AIR ) ) { when (mode) { @@ -115,17 +106,15 @@ object Jesus : Module( event.x *= if (lava) .57 else 1.09 event.z *= if (lava) .57 else 1.09 } - else -> { } + + else -> {} } } } safeListener { if (preventJump && - !checkBlockCollisionNoLiquid( - player.entityBoundingBox.offset(.0, -.01, .0), - listOf(Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA) - ) + fakeY != .0 ) it.movementInput.jump = false } @@ -162,7 +151,10 @@ object Jesus : Module( packet.playerY += fakeY - if (ticksEnabled % 2 == 0) .0 else -.00001 } - if (checkBlockCollisionNoLiquid(player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) { + if (checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), + liquids + Blocks.AIR + )) { packet.playerY = player.posY } } @@ -171,18 +163,22 @@ object Jesus : Module( if (ticksEnabled % 2 == 0) packet.playerY -= .001 - if (checkBlockCollisionNoLiquid(player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), listOf(Blocks.AIR, Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA))) { + if (checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), + liquids + Blocks.AIR + )) { packet.playerY = player.posY } } - else -> { } + + else -> {} } } safeListener { if (it.packet !is SPacketPlayerPosLook) return@safeListener - fakeY = mc.player.posY - it.packet.y + fakeY = player.posY - it.packet.y } }