From 46459b9ec3bd0df7a83c622428935d1f6f0280a9 Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 4 Oct 2022 02:53:02 +0200 Subject: [PATCH 01/40] Sketch --- .../module/modules/player/ScaffoldRewrite.kt | 88 +++++++++++++++++++ .../com/lambda/client/util/world/Interact.kt | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt new file mode 100644 index 000000000..e314baeaf --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt @@ -0,0 +1,88 @@ +package com.lambda.client.module.modules.player + +import com.lambda.client.LambdaMod +import com.lambda.client.event.events.PlayerTravelEvent +import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.manager.managers.HotbarManager.serverSideItem +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.EntityUtils.flooredPosition +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.ESPRenderer +import com.lambda.client.util.threads.safeListener +import com.lambda.client.util.world.* +import net.minecraft.block.BlockBarrier +import net.minecraft.block.state.IBlockState +import net.minecraft.init.Blocks +import net.minecraft.item.ItemBlock +import net.minecraft.util.EnumHand +import net.minecraft.util.SoundCategory +import net.minecraft.util.math.BlockPos + +object ScaffoldRewrite : Module( + name = "ScaffoldRewrite", + description = "Places blocks under you", + category = Category.PLAYER, + modulePriority = 500 +) { + private val page by setting("Page", Page.SETTINGS) + + private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") + private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") + private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") + private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") + private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") + + private enum class Page { + SETTINGS, RENDER + } + + val renderer by lazy { ESPRenderer() } + +// var currentStructure: Set = emptySet() + var baseBlock: BlockPos = BlockPos.ORIGIN + + init { + safeListener { + val basePos = player.flooredPosition.down() + + if (world.isPlaceable(basePos)) { +// LambdaMod.LOG.error(player.position.down()) + val placeSequence = getNeighbourSequence(basePos, 1, visibleSideCheck = true) + + if (placeSequence.isNotEmpty()) { + placeSequence.firstOrNull()?.let { + world.setBlockState(basePos, Blocks.BARRIER.defaultState) + + connection.sendPacket(it.toPlacePacket(EnumHand.MAIN_HAND)) + player.swingArm(EnumHand.MAIN_HAND) + + val itemStack = player.serverSideItem + val block = (itemStack.item as? ItemBlock?)?.block ?: return@safeListener + val metaData = itemStack.metadata + val blockState = block.getStateForPlacement(world, it.pos, it.side, it.hitVecOffset.x.toFloat(), it.hitVecOffset.y.toFloat(), it.hitVecOffset.z.toFloat(), metaData, player, EnumHand.MAIN_HAND) + val soundType = blockState.block.getSoundType(blockState, world, it.pos, player) + world.playSound(player, it.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) + } + } + +// if (baseBlock != basePos) { +// +// } + baseBlock = basePos +// world.setBlockState(basePos, Blocks.BARRIER.defaultState) + } + } + + safeListener { + renderer.aFilled = if (filled) alphaFilled else 0 + renderer.aOutline = if (outline) alphaOutline else 0 + renderer.thickness = thickness + + renderer.add(baseBlock, ColorHolder(0, 255, 0)) + + renderer.render(clear = true) + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index 30d10fe41..c919c46e8 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -285,5 +285,5 @@ fun SafeClientEvent.placeBlock( world.playSound(player, placeInfo.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) } -private fun PlaceInfo.toPlacePacket(hand: EnumHand) = +fun PlaceInfo.toPlacePacket(hand: EnumHand) = CPacketPlayerTryUseItemOnBlock(this.pos, this.side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file From fba90773835958056574fc15882887c66ad48e23 Mon Sep 17 00:00:00 2001 From: Constructor Date: Thu, 6 Oct 2022 08:21:35 +0200 Subject: [PATCH 02/40] Working sketch --- .../module/modules/player/PacketLogger.kt | 10 +- .../client/module/modules/player/Scaffold.kt | 188 +++++++++++------- .../module/modules/player/ScaffoldRewrite.kt | 88 -------- 3 files changed, 124 insertions(+), 162 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt index 6a146cc9a..34f55b9fd 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt @@ -43,7 +43,10 @@ object PacketLogger : Module( private val ignoreUnknown by setting("Ignore Unknown Packets", false, description = "Ignore packets that aren't explicitly handled.") private val ignoreChat by setting("Ignore Chat", true, description = "Ignore chat packets.") private val ignoreCancelled by setting("Ignore Cancelled", true, description = "Ignore cancelled packets.") - private val openLogFolder = setting("Open Log Folder...", false) + private val openLogFolder by setting("Open Packet Log Folder...", false, consumer = { _, it -> + if (it) FolderUtils.openFolder(FolderUtils.packetLogFolder) + false + }) private val fileTimeFormatter = DateTimeFormatter.ofPattern("HH-mm-ss_SSS") @@ -135,11 +138,6 @@ object PacketLogger : Module( sendPacket(it.packet) } - - openLogFolder.consumers.add { _, it -> - if (it) FolderUtils.openFolder(FolderUtils.logFolder) - false - } } private fun receivePacket(packet: Packet<*>) { diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index f33e6d938..0d8929180 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -1,41 +1,46 @@ package com.lambda.client.module.modules.player +import com.lambda.client.LambdaMod import com.lambda.client.event.Phase import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent +import com.lambda.client.event.events.RenderWorldEvent import com.lambda.client.event.listener.listener -import com.lambda.client.manager.managers.HotbarManager.resetHotbar import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.util.EntityUtils.prevPosVector +import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.items.HotbarSlot -import com.lambda.client.util.items.firstItem -import com.lambda.client.util.items.hotbarSlots -import com.lambda.client.util.items.swapToSlot +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.ESPRenderer +import com.lambda.client.util.items.* import com.lambda.client.util.math.RotationUtils.getRotationTo -import com.lambda.client.util.math.VectorUtils.toBlockPos +import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.placeBlock import com.lambda.mixin.entity.MixinEntity +import net.minecraft.block.Block +import net.minecraft.init.Blocks import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction +import net.minecraft.network.play.client.CPacketPlayer +import net.minecraft.network.play.server.SPacketBlockChange import net.minecraft.network.play.server.SPacketPlayerPosLook -import net.minecraft.util.EnumFacing import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.RayTraceResult import net.minecraft.util.math.Vec3d +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent +import java.util.concurrent.ConcurrentHashMap import kotlin.math.floor -import kotlin.math.roundToInt /** * @see MixinEntity.moveInvokeIsSneakingPre @@ -52,39 +57,89 @@ object Scaffold : Module( val safeWalk by setting("Safe Walk", true) private val sneak by setting("Sneak", true) private val strictDirection by setting("Strict Direction", false) - private val delay by setting("Delay", 2, 1..10, 1, unit = " ticks") + private val delay by setting("Delay", 2, 0..10, 1, unit = " ticks") + private val timeout by setting("Timeout", 20, 1..40, 1, unit = " ticks") private val maxRange by setting("Max Range", 1, 0..3, 1) + private val maxPending by setting("Max Pending", 1, 0..10, 1) + private val below by setting("below", 1.0, 0.0..5.0, 0.1) + private val filled by setting("Filled", true, description = "Renders surfaces") + private val outline by setting("Outline", true, description = "Renders outline") + private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled }, description = "Alpha for surfaces") + private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline }, description = "Alpha for outline") + private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline }, description = "Changes thickness of the outline") - private var lastHitVec: Vec3d? = null private var placeInfo: PlaceInfo? = null - private var inactiveTicks = 69 + private val renderer = ESPRenderer() private val placeTimer = TickTimer(TimeUnit.TICKS) private val rubberBandTimer = TickTimer(TimeUnit.TICKS) + private var lastPosVec = Vec3d.ZERO + + private val pendingBlocks = ConcurrentHashMap() override fun isActive(): Boolean { - return isEnabled && inactiveTicks <= 5 + return isEnabled } init { onDisable { placeInfo = null - inactiveTicks = 69 + pendingBlocks.clear() } - listener { - if (it.packet !is SPacketPlayerPosLook) return@listener - rubberBandTimer.reset() + listener { event -> + when (val packet = event.packet) { + is SPacketPlayerPosLook -> { + rubberBandTimer.reset() + MessageSendHelper.sendChatMessage("RUBBER") + runSafe { + pendingBlocks.values.forEach { + world.setBlockState(it.blockPos, Blocks.AIR.defaultState) + } + } + } + + is SPacketBlockChange -> { + pendingBlocks[packet.blockPosition]?.let { pendingBlock -> + if (pendingBlock.block == packet.blockState.block) { + pendingBlocks.remove(packet.blockPosition) + LambdaMod.LOG.error("Confirmed: $pendingBlock") + } else { + LambdaMod.LOG.error("Other confirm: ${packet.blockPosition} ${packet.blockState.block}") + } + } + } + } } safeListener { - if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || inactiveTicks > 5 || !isHoldingBlock) return@safeListener + if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener if (rubberBandTimer.tick(10, false)) { - if (shouldTower) player.motionY = 0.41999998688697815 + if (shouldTower) { + if (floor(lastPosVec.y) < floor(player.posY)) { + connection.sendPacket(CPacketPlayer(true)) + } + + player.motionY = 0.41999998688697815 + + lastPosVec = player.positionVector + } } else if (player.fallDistance <= 2.0f) { player.motionY = -0.169 } } + + safeListener { + renderer.aFilled = if (filled) alphaFilled else 0 + renderer.aOutline = if (outline) alphaOutline else 0 + renderer.thickness = thickness + + pendingBlocks.keys.forEach { + renderer.add(it, ColorHolder(0, 0, 255)) + } + + renderer.render(clear = true) + } } private val SafeClientEvent.isHoldingBlock: Boolean @@ -92,72 +147,58 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround - && player.posY - floor(player.posY) <= 0.1 +// && pendingBlocks.isEmpty() + && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() init { - safeListener { event -> - if (event.phase != Phase.PRE) return@safeListener - - inactiveTicks++ - placeInfo = calcNextPos()?.let { - getNeighbour(it, 1, visibleSideCheck = strictDirection, sides = arrayOf(EnumFacing.DOWN)) - ?: getNeighbour(it, 3, visibleSideCheck = strictDirection, sides = EnumFacing.HORIZONTALS) - } - - placeInfo?.let { - lastHitVec = it.hitVec - swapAndPlace(it) - } + safeListener { event -> + if (event.phase != TickEvent.Phase.START) return@safeListener + + pendingBlocks.values + .filter { it.age > timeout * 50L } + .forEach { pendingBlock -> + LambdaMod.LOG.error("Timeout: ${pendingBlock.blockPos}") + pendingBlocks.remove(pendingBlock.blockPos) + } - if (inactiveTicks > 5) { - resetHotbar() - } else if (isHoldingBlock) { - lastHitVec?.let { - sendPlayerPacket { - rotate(getRotationTo(it)) + placeInfo?.let { placeInfo -> + pendingBlocks[placeInfo.placedPos]?.let { + if (it.age < timeout * 50L) { + LambdaMod.LOG.error("Age: ${it.age}") + return@safeListener } } + + swapAndPlace(placeInfo) + sendPlayerPacket { + rotate(getRotationTo(placeInfo.hitVec)) + } } } - } - private fun SafeClientEvent.calcNextPos(): BlockPos? { - val posVec = player.positionVector - val blockPos = posVec.toBlockPos() - return checkPos(blockPos) - ?: run { - val realMotion = posVec.subtract(player.prevPosVector) - val nextPos = blockPos.add(roundToRange(realMotion.x), 0, roundToRange(realMotion.z)) - checkPos(nextPos) - } - } + safeListener { event -> + if (event.phase != Phase.PRE) return@safeListener - private fun SafeClientEvent.checkPos(blockPos: BlockPos): BlockPos? { - val center = Vec3d(blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) - val rayTraceResult = world.rayTraceBlocks( - center, - center.subtract(0.0, 0.5, 0.0), - false, - true, - false - ) - return blockPos.down().takeIf { rayTraceResult?.typeOfHit != RayTraceResult.Type.BLOCK } + placeInfo = getNeighbour(player.flooredPosition.down(), maxRange, visibleSideCheck = strictDirection) + } } - private fun roundToRange(value: Double) = - (value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange) - private fun SafeClientEvent.swapAndPlace(placeInfo: PlaceInfo) { getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) else swapToSlot(slot) - inactiveTicks = 0 - - if (placeTimer.tick(delay.toLong())) { + if (placeTimer.tick(delay.toLong()) + && pendingBlocks.size < maxPending + ) { val shouldSneak = sneak && !player.isSneaking if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) + placeBlock(placeInfo) + world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) + pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, slot.stack.item.block) + LambdaMod.LOG.error("Placed: ${placeInfo.placedPos} ${slot.stack.item.block.localizedName}") + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) } } @@ -165,7 +206,18 @@ object Scaffold : Module( private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { playerController.syncCurrentPlayItem() - return player.hotbarSlots.firstItem() + return if (isUsableBlock(player.heldItemMainhand.item.block)) { + player.hotbarSlots[player.inventory.currentItem] + } else { + player.hotbarSlots.firstOrNull { isUsableBlock(it.stack.item.block) } + } + } + + private data class PendingBlock(val timestamp: Long, val blockPos: BlockPos, val block: Block) { + constructor(blockPos: BlockPos, block: Block) : this(System.currentTimeMillis(), blockPos, block) + + val age get() = System.currentTimeMillis() - timestamp } + private fun isUsableBlock(block: Block) = InventoryManager.ejectList.contains(block.item.registryName.toString()) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt deleted file mode 100644 index e314baeaf..000000000 --- a/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt +++ /dev/null @@ -1,88 +0,0 @@ -package com.lambda.client.module.modules.player - -import com.lambda.client.LambdaMod -import com.lambda.client.event.events.PlayerTravelEvent -import com.lambda.client.event.events.RenderWorldEvent -import com.lambda.client.manager.managers.HotbarManager.serverSideItem -import com.lambda.client.module.Category -import com.lambda.client.module.Module -import com.lambda.client.util.EntityUtils.flooredPosition -import com.lambda.client.util.color.ColorHolder -import com.lambda.client.util.graphics.ESPRenderer -import com.lambda.client.util.threads.safeListener -import com.lambda.client.util.world.* -import net.minecraft.block.BlockBarrier -import net.minecraft.block.state.IBlockState -import net.minecraft.init.Blocks -import net.minecraft.item.ItemBlock -import net.minecraft.util.EnumHand -import net.minecraft.util.SoundCategory -import net.minecraft.util.math.BlockPos - -object ScaffoldRewrite : Module( - name = "ScaffoldRewrite", - description = "Places blocks under you", - category = Category.PLAYER, - modulePriority = 500 -) { - private val page by setting("Page", Page.SETTINGS) - - private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") - private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") - private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") - private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") - private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") - - private enum class Page { - SETTINGS, RENDER - } - - val renderer by lazy { ESPRenderer() } - -// var currentStructure: Set = emptySet() - var baseBlock: BlockPos = BlockPos.ORIGIN - - init { - safeListener { - val basePos = player.flooredPosition.down() - - if (world.isPlaceable(basePos)) { -// LambdaMod.LOG.error(player.position.down()) - val placeSequence = getNeighbourSequence(basePos, 1, visibleSideCheck = true) - - if (placeSequence.isNotEmpty()) { - placeSequence.firstOrNull()?.let { - world.setBlockState(basePos, Blocks.BARRIER.defaultState) - - connection.sendPacket(it.toPlacePacket(EnumHand.MAIN_HAND)) - player.swingArm(EnumHand.MAIN_HAND) - - val itemStack = player.serverSideItem - val block = (itemStack.item as? ItemBlock?)?.block ?: return@safeListener - val metaData = itemStack.metadata - val blockState = block.getStateForPlacement(world, it.pos, it.side, it.hitVecOffset.x.toFloat(), it.hitVecOffset.y.toFloat(), it.hitVecOffset.z.toFloat(), metaData, player, EnumHand.MAIN_HAND) - val soundType = blockState.block.getSoundType(blockState, world, it.pos, player) - world.playSound(player, it.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) - } - } - -// if (baseBlock != basePos) { -// -// } - baseBlock = basePos -// world.setBlockState(basePos, Blocks.BARRIER.defaultState) - } - } - - safeListener { - renderer.aFilled = if (filled) alphaFilled else 0 - renderer.aOutline = if (outline) alphaOutline else 0 - renderer.thickness = thickness - - renderer.add(baseBlock, ColorHolder(0, 255, 0)) - - renderer.render(clear = true) - } - } - -} \ No newline at end of file From a8fad4fda7af0913e6da0a609aeb9b53ccc12b0a Mon Sep 17 00:00:00 2001 From: Constructor Date: Thu, 6 Oct 2022 08:23:32 +0200 Subject: [PATCH 03/40] Better default settings --- .../com/lambda/client/module/modules/player/Scaffold.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 0d8929180..f1d50f3ec 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -57,11 +57,11 @@ object Scaffold : Module( val safeWalk by setting("Safe Walk", true) private val sneak by setting("Sneak", true) private val strictDirection by setting("Strict Direction", false) - private val delay by setting("Delay", 2, 0..10, 1, unit = " ticks") + private val delay by setting("Delay", 0, 0..10, 1, unit = " ticks") private val timeout by setting("Timeout", 20, 1..40, 1, unit = " ticks") - private val maxRange by setting("Max Range", 1, 0..3, 1) + private val maxRange by setting("Max Range", 0, 0..3, 1) private val maxPending by setting("Max Pending", 1, 0..10, 1) - private val below by setting("below", 1.0, 0.0..5.0, 0.1) + private val below by setting("Max Tower Distance", 0.3, 0.0..5.0, 0.1) private val filled by setting("Filled", true, description = "Renders surfaces") private val outline by setting("Outline", true, description = "Renders outline") private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled }, description = "Alpha for surfaces") @@ -91,7 +91,6 @@ object Scaffold : Module( when (val packet = event.packet) { is SPacketPlayerPosLook -> { rubberBandTimer.reset() - MessageSendHelper.sendChatMessage("RUBBER") runSafe { pendingBlocks.values.forEach { world.setBlockState(it.blockPos, Blocks.AIR.defaultState) From db538b7088733fb5a21ae1b4433877f92ce59c3a Mon Sep 17 00:00:00 2001 From: Constructor Date: Thu, 6 Oct 2022 09:26:43 +0200 Subject: [PATCH 04/40] Fix rubberbanding --- .../client/module/modules/player/Scaffold.kt | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index f1d50f3ec..61afb5a18 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -7,7 +7,6 @@ import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.event.events.RenderWorldEvent -import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket @@ -21,8 +20,6 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.items.* import com.lambda.client.util.math.RotationUtils.getRotationTo -import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour @@ -52,21 +49,28 @@ object Scaffold : Module( category = Category.PLAYER, modulePriority = 500 ) { - private val tower by setting("Tower", true) - private val spoofHotbar by setting("Spoof Hotbar", true) - val safeWalk by setting("Safe Walk", true) - private val sneak by setting("Sneak", true) - private val strictDirection by setting("Strict Direction", false) - private val delay by setting("Delay", 0, 0..10, 1, unit = " ticks") - private val timeout by setting("Timeout", 20, 1..40, 1, unit = " ticks") - private val maxRange by setting("Max Range", 0, 0..3, 1) - private val maxPending by setting("Max Pending", 1, 0..10, 1) - private val below by setting("Max Tower Distance", 0.3, 0.0..5.0, 0.1) - private val filled by setting("Filled", true, description = "Renders surfaces") - private val outline by setting("Outline", true, description = "Renders outline") - private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled }, description = "Alpha for surfaces") - private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline }, description = "Alpha for outline") - private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline }, description = "Changes thickness of the outline") + private val page by setting("Page", Page.GENERAL) + + private val tower by setting("Tower", true, { page == Page.GENERAL }) + private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) + val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) + private val sneak by setting("Sneak", true, { page == Page.GENERAL }) + private val strictDirection by setting("Strict Direction", false, { page == Page.GENERAL }) + private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") + private val timeout by setting("Timeout", 50, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") + private val maxRange by setting("Max Range", 0, 0..3, 1, { page == Page.GENERAL }) + private val maxPending by setting("Max Pending", 1, 0..2, 1, { page == Page.GENERAL }) + private val below by setting("Max Tower Distance", 0.3, 0.0..2.0, 0.01, { page == Page.GENERAL }) + private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") + private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") + private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") + private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") + private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") + private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255)) + + private enum class Page { + GENERAL, RENDER + } private var placeInfo: PlaceInfo? = null private val renderer = ESPRenderer() @@ -77,32 +81,27 @@ object Scaffold : Module( private val pendingBlocks = ConcurrentHashMap() - override fun isActive(): Boolean { - return isEnabled - } - init { onDisable { placeInfo = null pendingBlocks.clear() } - listener { event -> + safeListener { event -> when (val packet = event.packet) { is SPacketPlayerPosLook -> { rubberBandTimer.reset() - runSafe { - pendingBlocks.values.forEach { - world.setBlockState(it.blockPos, Blocks.AIR.defaultState) - } + pendingBlocks.keys.forEach { + world.setBlockState(it, Blocks.AIR.defaultState) } + pendingBlocks.clear() } is SPacketBlockChange -> { pendingBlocks[packet.blockPosition]?.let { pendingBlock -> if (pendingBlock.block == packet.blockState.block) { pendingBlocks.remove(packet.blockPosition) - LambdaMod.LOG.error("Confirmed: $pendingBlock") +// LambdaMod.LOG.error("Confirmed: $pendingBlock") } else { LambdaMod.LOG.error("Other confirm: ${packet.blockPosition} ${packet.blockState.block}") } @@ -134,7 +133,7 @@ object Scaffold : Module( renderer.thickness = thickness pendingBlocks.keys.forEach { - renderer.add(it, ColorHolder(0, 0, 255)) + renderer.add(it, pendingBlockColor) } renderer.render(clear = true) @@ -146,7 +145,6 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround -// && pendingBlocks.isEmpty() && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() init { @@ -158,6 +156,7 @@ object Scaffold : Module( .forEach { pendingBlock -> LambdaMod.LOG.error("Timeout: ${pendingBlock.blockPos}") pendingBlocks.remove(pendingBlock.blockPos) + world.setBlockState(pendingBlock.blockPos, Blocks.AIR.defaultState) } placeInfo?.let { placeInfo -> @@ -168,9 +167,11 @@ object Scaffold : Module( } } - swapAndPlace(placeInfo) - sendPlayerPacket { - rotate(getRotationTo(placeInfo.hitVec)) + if (rubberBandTimer.tick(10, false)) { + swapAndPlace(placeInfo) + sendPlayerPacket { + rotate(getRotationTo(placeInfo.hitVec)) + } } } } @@ -196,7 +197,7 @@ object Scaffold : Module( placeBlock(placeInfo) world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, slot.stack.item.block) - LambdaMod.LOG.error("Placed: ${placeInfo.placedPos} ${slot.stack.item.block.localizedName}") +// LambdaMod.LOG.error("Placed: ${placeInfo.placedPos} ${slot.stack.item.block.localizedName}") if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) } From 97f5ab766590673cecd75ec809a9606342ab7e64 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 23 Jan 2023 04:34:50 +0100 Subject: [PATCH 05/40] Fix previous block state and default settings --- .../client/module/modules/player/Scaffold.kt | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 61afb5a18..9d3b1bde2 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -7,6 +7,7 @@ import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket @@ -26,6 +27,7 @@ import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.placeBlock import com.lambda.mixin.entity.MixinEntity import net.minecraft.block.Block +import net.minecraft.block.state.IBlockState import net.minecraft.init.Blocks import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction @@ -58,8 +60,8 @@ object Scaffold : Module( private val strictDirection by setting("Strict Direction", false, { page == Page.GENERAL }) private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") private val timeout by setting("Timeout", 50, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") - private val maxRange by setting("Max Range", 0, 0..3, 1, { page == Page.GENERAL }) - private val maxPending by setting("Max Pending", 1, 0..2, 1, { page == Page.GENERAL }) + private val maxRange by setting("Max Range", 1, 0..3, 1, { page == Page.GENERAL }) + private val maxPending by setting("Max Pending", 2, 0..5, 1, { page == Page.GENERAL }) private val below by setting("Max Tower Distance", 0.3, 0.0..2.0, 0.01, { page == Page.GENERAL }) private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") @@ -91,8 +93,8 @@ object Scaffold : Module( when (val packet = event.packet) { is SPacketPlayerPosLook -> { rubberBandTimer.reset() - pendingBlocks.keys.forEach { - world.setBlockState(it, Blocks.AIR.defaultState) + pendingBlocks.forEach { + world.setBlockState(it.key, it.value.blockState) } pendingBlocks.clear() } @@ -127,7 +129,7 @@ object Scaffold : Module( } } - safeListener { + listener { renderer.aFilled = if (filled) alphaFilled else 0 renderer.aOutline = if (outline) alphaOutline else 0 renderer.thickness = thickness @@ -156,7 +158,7 @@ object Scaffold : Module( .forEach { pendingBlock -> LambdaMod.LOG.error("Timeout: ${pendingBlock.blockPos}") pendingBlocks.remove(pendingBlock.blockPos) - world.setBlockState(pendingBlock.blockPos, Blocks.AIR.defaultState) + world.setBlockState(pendingBlock.blockPos, pendingBlock.blockState) } placeInfo?.let { placeInfo -> @@ -195,8 +197,9 @@ object Scaffold : Module( if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) placeBlock(placeInfo) + + pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, world.getBlockState(placeInfo.placedPos), slot.stack.item.block) world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) - pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, slot.stack.item.block) // LambdaMod.LOG.error("Placed: ${placeInfo.placedPos} ${slot.stack.item.block.localizedName}") if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) @@ -213,8 +216,13 @@ object Scaffold : Module( } } - private data class PendingBlock(val timestamp: Long, val blockPos: BlockPos, val block: Block) { - constructor(blockPos: BlockPos, block: Block) : this(System.currentTimeMillis(), blockPos, block) + private data class PendingBlock( + val timestamp: Long, + val blockPos: BlockPos, + val blockState: IBlockState, + val block: Block + ) { + constructor(blockPos: BlockPos, blockState: IBlockState, block: Block) : this(System.currentTimeMillis(), blockPos, blockState, block) val age get() = System.currentTimeMillis() - timestamp } From d11dd6ccf44d0128f78fc10d03f09824f650cecb Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 23 Jan 2023 06:32:30 +0100 Subject: [PATCH 06/40] Fix placement selection --- .../client/module/modules/player/Scaffold.kt | 18 +++++++++++---- .../com/lambda/client/util/world/Interact.kt | 23 +++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 9d3b1bde2..415a782ac 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -57,10 +57,11 @@ object Scaffold : Module( private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) private val sneak by setting("Sneak", true, { page == Page.GENERAL }) - private val strictDirection by setting("Strict Direction", false, { page == Page.GENERAL }) + private val visibleSideCheck by setting("Visible side check", true, { page == Page.GENERAL }) + private val sendOnGround by setting("Send onGround", true, { page == Page.GENERAL }) private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") private val timeout by setting("Timeout", 50, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") - private val maxRange by setting("Max Range", 1, 0..3, 1, { page == Page.GENERAL }) + private val attempts by setting("Placement Search Depth", 3, 0..7, 1, { page == Page.GENERAL }) private val maxPending by setting("Max Pending", 2, 0..5, 1, { page == Page.GENERAL }) private val below by setting("Max Tower Distance", 0.3, 0.0..2.0, 0.01, { page == Page.GENERAL }) private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") @@ -98,13 +99,20 @@ object Scaffold : Module( } pendingBlocks.clear() } - is SPacketBlockChange -> { pendingBlocks[packet.blockPosition]?.let { pendingBlock -> if (pendingBlock.block == packet.blockState.block) { pendingBlocks.remove(packet.blockPosition) // LambdaMod.LOG.error("Confirmed: $pendingBlock") } else { + // probably ItemStack emtpy + if (packet.blockState.block == Blocks.AIR) { + rubberBandTimer.reset() + pendingBlocks.forEach { + world.setBlockState(it.key, it.value.blockState) + } + pendingBlocks.clear() + } LambdaMod.LOG.error("Other confirm: ${packet.blockPosition} ${packet.blockState.block}") } } @@ -116,7 +124,7 @@ object Scaffold : Module( if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener if (rubberBandTimer.tick(10, false)) { if (shouldTower) { - if (floor(lastPosVec.y) < floor(player.posY)) { + if (sendOnGround && floor(lastPosVec.y) < floor(player.posY)) { connection.sendPacket(CPacketPlayer(true)) } @@ -181,7 +189,7 @@ object Scaffold : Module( safeListener { event -> if (event.phase != Phase.PRE) return@safeListener - placeInfo = getNeighbour(player.flooredPosition.down(), maxRange, visibleSideCheck = strictDirection) + placeInfo = getNeighbour(player.flooredPosition.down(), attempts, visibleSideCheck = visibleSideCheck) } } diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index c919c46e8..fee93637f 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -83,18 +83,23 @@ private fun SafeClientEvent.getNeighbour( sides: Array, toIgnore: HashSet> ): PlaceInfo? { - for (side in sides) { - val result = checkNeighbour(eyePos, pos, side, range, visibleSideCheck, true, toIgnore) - if (result != null) return result + if (!world.isPlaceable(pos)) return null + + sides.forEach { side -> + checkNeighbour(eyePos, pos, side, range, visibleSideCheck, true, toIgnore)?.let { + return it + } } - if (attempts > 1) { - for (side in sides) { - val newPos = pos.offset(side) - if (!world.isPlaceable(newPos)) continue + if (attempts < 2) return null + + sides.forEach { posSide -> + val newPos = pos.offset(posSide) + if (!world.isPlaceable(newPos)) return@forEach + if (eyePos.distanceTo(newPos.toVec3dCenter()) > range + 1) return@forEach - return getNeighbour(eyePos, newPos, attempts - 1, range, visibleSideCheck, sides, toIgnore) - ?: continue + getNeighbour(eyePos, newPos, attempts - 1, range, visibleSideCheck, sides, toIgnore)?.let { + return it } } From 4105c5cae8dcd2d119634e1a6d35dcea19eb675a Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 16 Jan 2023 01:14:57 -0800 Subject: [PATCH 07/40] Scaffold rewrite Makes tower mode actually work and adds ghost blocks for increased placing speed tested working on 2b2t --- .../mixin/player/MixinEntityPlayerSP.java | 53 ++++++--- .../events/OnUpdateWalkingPlayerEvent.kt | 17 +-- .../client/module/modules/player/Scaffold.kt | 112 +++++++----------- .../com/lambda/client/util/world/Interact.kt | 6 +- 4 files changed, 96 insertions(+), 92 deletions(-) diff --git a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java index 488b10976..32d323d8e 100644 --- a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java @@ -51,6 +51,7 @@ public abstract class MixinEntityPlayerSP extends EntityPlayer { @Shadow private boolean serverSneakState; @Shadow private boolean prevOnGround; @Shadow private boolean autoJumpEnabled; + private OnUpdateWalkingPlayerEvent updateWalkingPlayerEvent = new OnUpdateWalkingPlayerEvent(); public MixinEntityPlayerSP(World worldIn, GameProfile gameProfileIn) { super(worldIn, gameProfileIn); @@ -149,33 +150,41 @@ private void onUpdateInvokeOnUpdateWalkingPlayer(CallbackInfo ci) { this.lastReportedPitch = serverSideRotation.getY(); } - @Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true) - private void onUpdateWalkingPlayerHead(CallbackInfo ci) { - + @Inject( + method = "onUpdate", + at = @At( + // need to do this injection for future compatibility + // what's likely going on is future also is setting the player rotation values based on the event + // but those values are being taken from the updateWalkingPlayer method args rather than the field values + value = "INVOKE", + target = "Lnet/minecraft/client/entity/EntityPlayerSP;onUpdateWalkingPlayer()V", + shift = At.Shift.BEFORE), + cancellable = true) + public void onUpdateWalkingPlayerInvoke(CallbackInfo ci) + { CriticalsUpdateWalkingEvent criticalsEditEvent = new CriticalsUpdateWalkingEvent(); LambdaEventBus.INSTANCE.post(criticalsEditEvent); - // Setup flags Vec3d position = new Vec3d(this.posX, this.getEntityBoundingBox().minY, this.posZ); Vec2f rotation = new Vec2f(this.rotationYaw, this.rotationPitch); boolean moving = isMoving(position); boolean rotating = isRotating(rotation); - OnUpdateWalkingPlayerEvent event = new OnUpdateWalkingPlayerEvent(moving, rotating, position, rotation); - LambdaEventBus.INSTANCE.post(event); + updateWalkingPlayerEvent = new OnUpdateWalkingPlayerEvent(moving, rotating, position, rotation); + LambdaEventBus.INSTANCE.post(updateWalkingPlayerEvent); - event = event.nextPhase(); - LambdaEventBus.INSTANCE.post(event); + updateWalkingPlayerEvent = updateWalkingPlayerEvent.nextPhase(); + LambdaEventBus.INSTANCE.post(updateWalkingPlayerEvent); - if (event.getCancelled()) { + if (updateWalkingPlayerEvent.getCancelled()) { ci.cancel(); - if (!event.getCancelAll()) { + if (!updateWalkingPlayerEvent.getCancelAll()) { // Copy flags from event - moving = event.isMoving(); - rotating = event.isRotating(); - position = event.getPosition(); - rotation = event.getRotation(); + moving = updateWalkingPlayerEvent.isMoving(); + rotating = updateWalkingPlayerEvent.isRotating(); + position = updateWalkingPlayerEvent.getPosition(); + rotation = updateWalkingPlayerEvent.getRotation(); sendSprintPacket(); sendSneakPacket(); @@ -186,10 +195,24 @@ private void onUpdateWalkingPlayerHead(CallbackInfo ci) { ++this.positionUpdateTicks; this.autoJumpEnabled = this.mc.gameSettings.autoJump; + } else { + this.posX = updateWalkingPlayerEvent.getPosition().x; + this.posY = updateWalkingPlayerEvent.getPosition().y; + this.posZ = updateWalkingPlayerEvent.getPosition().z; + this.rotationYaw = updateWalkingPlayerEvent.getRotation().getX(); + this.rotationPitch = updateWalkingPlayerEvent.getRotation().getY(); } + } - event = event.nextPhase(); + @Inject(method = "onUpdateWalkingPlayer", at = @At("TAIL")) + private void onUpdateWalkingPlayerTail(CallbackInfo ci) { + final OnUpdateWalkingPlayerEvent event = updateWalkingPlayerEvent.nextPhase(); LambdaEventBus.INSTANCE.post(event); + this.posX = event.getPosInitial().x; + this.posY = event.getPosInitial().y; + this.posZ = event.getPosInitial().z; + this.rotationYaw = event.getRotInitial().getX(); + this.rotationPitch = event.getRotInitial().getY(); } private void sendSprintPacket() { diff --git a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt index d28ea0d05..489976f41 100644 --- a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt +++ b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt @@ -9,16 +9,16 @@ import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.util.math.Vec2f import net.minecraft.util.math.Vec3d -class OnUpdateWalkingPlayerEvent private constructor( +class OnUpdateWalkingPlayerEvent constructor( moving: Boolean, rotating: Boolean, - position: Vec3d, - rotation: Vec2f, - override val phase: Phase + var position: Vec3d, + var rotation: Vec2f, + override var phase: Phase ) : Event, IMultiPhase, Cancellable() { - var position = position; private set - var rotation = rotation; private set + val posInitial = position + val rotInitial = rotation var moving = moving @JvmName("isMoving") get @@ -30,9 +30,11 @@ class OnUpdateWalkingPlayerEvent private constructor( var cancelAll = false; private set constructor(moving: Boolean, rotating: Boolean, position: Vec3d, rotation: Vec2f) : this(moving, rotating, position, rotation, Phase.PRE) + constructor() : this(false, false, Vec3d.ZERO, Vec2f.ZERO) override fun nextPhase(): OnUpdateWalkingPlayerEvent { - return OnUpdateWalkingPlayerEvent(moving, rotating, position, rotation, phase.next()) + phase = phase.next() + return this } fun apply(packet: PlayerPacketManager.Packet) { @@ -50,5 +52,4 @@ class OnUpdateWalkingPlayerEvent private constructor( this.cancelAll = packet.cancelAll } - } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index f33e6d938..c4992928c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -3,13 +3,9 @@ package com.lambda.client.module.modules.player import com.lambda.client.event.Phase import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent -import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.PlayerTravelEvent -import com.lambda.client.event.listener.listener +import com.lambda.client.event.events.PushOutOfBlocksEvent import com.lambda.client.manager.managers.HotbarManager.resetHotbar -import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar -import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -26,21 +22,14 @@ import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.placeBlock -import com.lambda.mixin.entity.MixinEntity import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction -import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.EnumFacing import net.minecraft.util.math.BlockPos import net.minecraft.util.math.RayTraceResult import net.minecraft.util.math.Vec3d -import kotlin.math.floor import kotlin.math.roundToInt -/** - * @see MixinEntity.moveInvokeIsSneakingPre - * @see MixinEntity.moveInvokeIsSneakingPost - */ object Scaffold : Module( name = "Scaffold", description = "Places blocks under you", @@ -51,17 +40,17 @@ object Scaffold : Module( private val spoofHotbar by setting("Spoof Hotbar", true) val safeWalk by setting("Safe Walk", true) private val sneak by setting("Sneak", true) - private val strictDirection by setting("Strict Direction", false) + private val strictDirection by setting("Strict Direction", true) private val delay by setting("Delay", 2, 1..10, 1, unit = " ticks") private val maxRange by setting("Max Range", 1, 0..3, 1) + private val noGhost by setting("No Ghost Blocks", false) + + private val placeTimer = TickTimer(TimeUnit.TICKS) private var lastHitVec: Vec3d? = null private var placeInfo: PlaceInfo? = null private var inactiveTicks = 69 - private val placeTimer = TickTimer(TimeUnit.TICKS) - private val rubberBandTimer = TickTimer(TimeUnit.TICKS) - override fun isActive(): Boolean { return isEnabled && inactiveTicks <= 5 } @@ -72,51 +61,47 @@ object Scaffold : Module( inactiveTicks = 69 } - listener { - if (it.packet !is SPacketPlayerPosLook) return@listener - rubberBandTimer.reset() - } - - safeListener { - if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || inactiveTicks > 5 || !isHoldingBlock) return@safeListener - if (rubberBandTimer.tick(10, false)) { - if (shouldTower) player.motionY = 0.41999998688697815 - } else if (player.fallDistance <= 2.0f) { - player.motionY = -0.169 - } - } - } - - private val SafeClientEvent.isHoldingBlock: Boolean - get() = player.serverSideItem.item is ItemBlock - - private val SafeClientEvent.shouldTower: Boolean - get() = !player.onGround - && player.posY - floor(player.posY) <= 0.1 - - init { safeListener { event -> - if (event.phase != Phase.PRE) return@safeListener + if (event.phase == Phase.PRE) { + inactiveTicks++ - inactiveTicks++ - placeInfo = calcNextPos()?.let { - getNeighbour(it, 1, visibleSideCheck = strictDirection, sides = arrayOf(EnumFacing.DOWN)) - ?: getNeighbour(it, 3, visibleSideCheck = strictDirection, sides = EnumFacing.HORIZONTALS) - } - - placeInfo?.let { - lastHitVec = it.hitVec - swapAndPlace(it) - } - - if (inactiveTicks > 5) { - resetHotbar() - } else if (isHoldingBlock) { - lastHitVec?.let { - sendPlayerPacket { - rotate(getRotationTo(it)) + placeInfo = calcNextPos()?.let { + getNeighbour(it, 1, visibleSideCheck = strictDirection, sides = arrayOf(EnumFacing.DOWN)) + ?: getNeighbour(it, 3, visibleSideCheck = strictDirection, sides = EnumFacing.HORIZONTALS) + } + placeInfo?.let { + lastHitVec = it.hitVec + val rotation = getRotationTo(it.hitVec) + event.rotation = rotation + } + } else if (event.phase == Phase.POST) { + placeInfo?.let { pi -> + if (swap()) { + if (tower && mc.player.movementInput.jump) { + val shouldSneak = sneak && !player.isSneaking + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) + placeBlock(pi, noGhost = false) // noGhost true usually causes problems and has no real benefit here + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) + mc.player.jump() + } else { + if (placeTimer.tick(delay, true)) { + val shouldSneak = sneak && !player.isSneaking + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) + placeBlock(pi, noGhost = noGhost) + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) + } + } } } + if (inactiveTicks > 5) { + resetHotbar() + } + } + } + + safeListener { + if (tower) { + it.cancel() } } } @@ -147,25 +132,18 @@ object Scaffold : Module( private fun roundToRange(value: Double) = (value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange) - private fun SafeClientEvent.swapAndPlace(placeInfo: PlaceInfo) { + private fun SafeClientEvent.swap(): Boolean { getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) else swapToSlot(slot) - inactiveTicks = 0 - - if (placeTimer.tick(delay.toLong())) { - val shouldSneak = sneak && !player.isSneaking - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) - placeBlock(placeInfo) - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) - } + return true } + return false } private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { playerController.syncCurrentPlayItem() return player.hotbarSlots.firstItem() } - } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index 30d10fe41..7690a895d 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -266,11 +266,12 @@ private suspend fun SafeClientEvent.doPlace( } /** - * Placing block without desync + * Place block with optional desync / ghost block */ fun SafeClientEvent.placeBlock( placeInfo: PlaceInfo, - hand: EnumHand = EnumHand.MAIN_HAND + hand: EnumHand = EnumHand.MAIN_HAND, + noGhost: Boolean = true ) { if (!world.isPlaceable(placeInfo.placedPos)) return @@ -283,6 +284,7 @@ fun SafeClientEvent.placeBlock( val blockState = block.getStateForPlacement(world, placeInfo.pos, placeInfo.side, placeInfo.hitVecOffset.x.toFloat(), placeInfo.hitVecOffset.y.toFloat(), placeInfo.hitVecOffset.z.toFloat(), metaData, player, EnumHand.MAIN_HAND) val soundType = blockState.block.getSoundType(blockState, world, placeInfo.pos, player) world.playSound(player, placeInfo.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) + if (!noGhost) world.setBlockState(placeInfo.placedPos, blockState) } private fun PlaceInfo.toPlacePacket(hand: EnumHand) = From 3605f0f961af2e5f2aee6ee8387f1f878cbf531c Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Thu, 19 Jan 2023 22:03:29 -0800 Subject: [PATCH 08/40] Scaffold: don't swap to block if we already have one equipped --- .../com/lambda/client/module/modules/player/Scaffold.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index c4992928c..8f20ccf25 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -133,6 +133,10 @@ object Scaffold : Module( (value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange) private fun SafeClientEvent.swap(): Boolean { + if (player.heldItemMainhand.item is ItemBlock || player.heldItemOffhand.item is ItemBlock) { + inactiveTicks = 0; + return true; + } getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) else swapToSlot(slot) From 634e2e514ccbba8946724153edfb5914646f0d0d Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Thu, 19 Jan 2023 22:53:45 -0800 Subject: [PATCH 09/40] Scaffold: Whitelist/Blacklist/Any block selection modes --- .../command/commands/ScaffoldCommand.kt | 117 ++++++++++++++++++ .../client/module/modules/player/Scaffold.kt | 60 +++++++-- 2 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt diff --git a/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt new file mode 100644 index 000000000..32713b74e --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt @@ -0,0 +1,117 @@ +package com.lambda.client.command.commands + +import com.lambda.client.command.ClientCommand +import com.lambda.client.module.modules.player.Scaffold +import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.text.formatValue +import net.minecraft.init.Blocks + +object ScaffoldCommand : ClientCommand( + name = "scaffold", + description = "Manage scaffold whitelist/blacklist" +) { + private val allShulkerBoxes = listOf(Blocks.WHITE_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, + Blocks.MAGENTA_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, + Blocks.LIME_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.SILVER_SHULKER_BOX, + Blocks.CYAN_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, + Blocks.GREEN_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.BLACK_SHULKER_BOX) + .map { it.registryName.toString() } + .toList() + + init { + literal("whitelist", "wl") { + literal("add", "+") { + literal("shulker_box") { + execute("Add all shulker box types to whitelist") { + Scaffold.blockSelectionWhitelist.editValue { whitelist -> allShulkerBoxes.forEach { whitelist.add(it) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been added to whitelist") + } + } + block("block") { blockArg -> + execute("Add a block to Scaffold whitelist") { + val blockName = blockArg.value.registryName.toString() + if (Scaffold.blockSelectionWhitelist.contains(blockName)) { + MessageSendHelper.sendErrorMessage("${formatValue(blockName)} is already added to scaffold whitelist") + } else { + Scaffold.blockSelectionWhitelist.editValue { it.add(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been added to scaffold whitelist") + } + } + } + } + literal("del", "-") { + literal("shulker_box") { + execute("Remove all shulker box types from whitelist") { + Scaffold.blockSelectionWhitelist.editValue { whitelist -> allShulkerBoxes.forEach { whitelist.remove(it) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been removed from whitelist") + } + } + block("block") { blockArg -> + execute("Removes a block from the Scaffold whitelist") { + val blockName = blockArg.value.registryName.toString() + Scaffold.blockSelectionWhitelist.editValue { it.remove(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been removed from scaffold whitelist") + } + } + } + literal("clear", "c") { + execute { + Scaffold.blockSelectionWhitelist.editValue { it.clear() } + MessageSendHelper.sendChatMessage("Whitelist has been cleared") + } + } + literal("list") { + execute { + MessageSendHelper.sendChatMessage("Blocks: ${Scaffold.blockSelectionWhitelist.joinToString()}") + } + } + } + literal("blacklist", "bl") { + literal("add", "+") { + literal("shulker_box") { + execute("Add all shulker box types to blacklist") { + Scaffold.blockSelectionBlacklist.editValue { blacklist -> allShulkerBoxes.forEach { blacklist.add(it) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been added to blacklist") + } + } + block("block") { blockArg -> + execute("Add a block to Scaffold blacklist") { + val blockName = blockArg.value.registryName.toString() + if (Scaffold.blockSelectionBlacklist.contains(blockName)) { + MessageSendHelper.sendErrorMessage("${formatValue(blockName)} is already added to scaffold blacklist") + } else { + Scaffold.blockSelectionBlacklist.editValue { it.add(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been added to scaffold blacklist") + } + } + } + } + literal("del", "-") { + literal("shulker_box") { + execute("Remove all shulker box types from blacklist") { + Scaffold.blockSelectionBlacklist.editValue { blacklist -> allShulkerBoxes.forEach { blacklist.remove(it) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been removed from blacklist") + } + } + block("block") { blockArg -> + execute("Removes a block from the Scaffold blacklist") { + val blockName = blockArg.value.registryName.toString() + Scaffold.blockSelectionBlacklist.editValue { it.remove(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been removed from scaffold blacklist") + } + } + } + literal("clear", "c") { + execute { + Scaffold.blockSelectionBlacklist.editValue { it.clear() } + MessageSendHelper.sendChatMessage("Blacklist has been cleared") + } + } + literal("list") { + execute { + MessageSendHelper.sendChatMessage("Blocks: ${Scaffold.blockSelectionBlacklist.joinToString()}") + } + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 8f20ccf25..add3ab33c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -1,5 +1,6 @@ package com.lambda.client.module.modules.player +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.Phase import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent @@ -9,13 +10,11 @@ import com.lambda.client.manager.managers.HotbarManager.spoofHotbar import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.EntityUtils.prevPosVector import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.items.HotbarSlot -import com.lambda.client.util.items.firstItem -import com.lambda.client.util.items.hotbarSlots -import com.lambda.client.util.items.swapToSlot +import com.lambda.client.util.items.* import com.lambda.client.util.math.RotationUtils.getRotationTo import com.lambda.client.util.math.VectorUtils.toBlockPos import com.lambda.client.util.threads.safeListener @@ -36,6 +35,7 @@ object Scaffold : Module( category = Category.PLAYER, modulePriority = 500 ) { + private val blockSelectionMode by setting("Block Selection Mode", ScaffoldBlockSelectionMode.ANY) private val tower by setting("Tower", true) private val spoofHotbar by setting("Spoof Hotbar", true) val safeWalk by setting("Safe Walk", true) @@ -45,12 +45,27 @@ object Scaffold : Module( private val maxRange by setting("Max Range", 1, 0..3, 1) private val noGhost by setting("No Ghost Blocks", false) + val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) + val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", linkedSetOf("minecraft:white_shulker_box", "minecraft:orange_shulker_box", + "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", + "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", + "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", + "minecraft:red_shulker_box", "minecraft:black_shulker_box", "minecraft:crafting_table", "minecraft:dropper", + "minecraft:hopper", "minecraft:dispenser", "minecraft:ender_chest", "minecraft:furnace"), + { false })) + private val placeTimer = TickTimer(TimeUnit.TICKS) private var lastHitVec: Vec3d? = null private var placeInfo: PlaceInfo? = null private var inactiveTicks = 69 + private enum class ScaffoldBlockSelectionMode(override val displayName: String): DisplayEnum { + ANY("Any"), + WHITELIST("Whitelist"), + BLACKLIST("Blacklist") + } + override fun isActive(): Boolean { return isEnabled && inactiveTicks <= 5 } @@ -133,9 +148,28 @@ object Scaffold : Module( (value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange) private fun SafeClientEvent.swap(): Boolean { - if (player.heldItemMainhand.item is ItemBlock || player.heldItemOffhand.item is ItemBlock) { - inactiveTicks = 0; - return true; + // todo: refactor this into a function? + when (blockSelectionMode) { + ScaffoldBlockSelectionMode.ANY -> { + if (player.heldItemMainhand.item is ItemBlock || player.heldItemOffhand.item is ItemBlock) { + inactiveTicks = 0; + return true; + } + } + ScaffoldBlockSelectionMode.BLACKLIST -> { + if ((player.heldItemMainhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemMainhand.item.block.registryName.toString())) + || player.heldItemOffhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemOffhand.item.block.registryName.toString())) { + inactiveTicks = 0 + return true + } + } + ScaffoldBlockSelectionMode.WHITELIST -> { + if ((player.heldItemMainhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemMainhand.item.block.registryName.toString())) + || player.heldItemOffhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemOffhand.item.block.registryName.toString())) { + inactiveTicks = 0 + return true + } + } } getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) @@ -148,6 +182,16 @@ object Scaffold : Module( private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { playerController.syncCurrentPlayItem() - return player.hotbarSlots.firstItem() + return player.hotbarSlots.firstItem { + when (blockSelectionMode) { + ScaffoldBlockSelectionMode.BLACKLIST -> { + return@firstItem !blockSelectionBlacklist.contains(it.item.block.registryName.toString()) + } + ScaffoldBlockSelectionMode.WHITELIST -> { + return@firstItem blockSelectionWhitelist.contains(it.item.block.registryName.toString()) + } + else -> return@firstItem true + } + } } } \ No newline at end of file From 119fa9bc299995b076805ef699a4c1ac7e6f8a12 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 22 Jan 2023 20:57:18 -0800 Subject: [PATCH 10/40] Fix tower teleports by moving back onto top block --- .../lambda/client/module/modules/player/Scaffold.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index add3ab33c..25e4505a4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -59,6 +59,7 @@ object Scaffold : Module( private var lastHitVec: Vec3d? = null private var placeInfo: PlaceInfo? = null private var inactiveTicks = 69 + private var towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) private enum class ScaffoldBlockSelectionMode(override val displayName: String): DisplayEnum { ANY("Any"), @@ -71,6 +72,11 @@ object Scaffold : Module( } init { + + onEnable { + towerTimer.reset() + } + onDisable { placeInfo = null inactiveTicks = 69 @@ -98,7 +104,12 @@ object Scaffold : Module( placeBlock(pi, noGhost = false) // noGhost true usually causes problems and has no real benefit here if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) mc.player.jump() + if (towerTimer.tick(30)) { + // reset pos back onto top block + mc.player.motionY = -0.3 + } } else { + towerTimer.reset() if (placeTimer.tick(delay, true)) { val shouldSneak = sneak && !player.isSneaking if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) From c575fa45e3eec27e8d5c1137ab8eb885a6a30b63 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 22 Jan 2023 23:21:32 -0800 Subject: [PATCH 11/40] merge rfresh+constructor scaffolds --- .../mixin/player/MixinEntityPlayerSP.java | 53 ++----- .../events/OnUpdateWalkingPlayerEvent.kt | 17 ++- .../client/module/modules/player/Scaffold.kt | 134 ++++++++++++------ 3 files changed, 112 insertions(+), 92 deletions(-) diff --git a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java index 32d323d8e..488b10976 100644 --- a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java @@ -51,7 +51,6 @@ public abstract class MixinEntityPlayerSP extends EntityPlayer { @Shadow private boolean serverSneakState; @Shadow private boolean prevOnGround; @Shadow private boolean autoJumpEnabled; - private OnUpdateWalkingPlayerEvent updateWalkingPlayerEvent = new OnUpdateWalkingPlayerEvent(); public MixinEntityPlayerSP(World worldIn, GameProfile gameProfileIn) { super(worldIn, gameProfileIn); @@ -150,41 +149,33 @@ private void onUpdateInvokeOnUpdateWalkingPlayer(CallbackInfo ci) { this.lastReportedPitch = serverSideRotation.getY(); } - @Inject( - method = "onUpdate", - at = @At( - // need to do this injection for future compatibility - // what's likely going on is future also is setting the player rotation values based on the event - // but those values are being taken from the updateWalkingPlayer method args rather than the field values - value = "INVOKE", - target = "Lnet/minecraft/client/entity/EntityPlayerSP;onUpdateWalkingPlayer()V", - shift = At.Shift.BEFORE), - cancellable = true) - public void onUpdateWalkingPlayerInvoke(CallbackInfo ci) - { + @Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true) + private void onUpdateWalkingPlayerHead(CallbackInfo ci) { + CriticalsUpdateWalkingEvent criticalsEditEvent = new CriticalsUpdateWalkingEvent(); LambdaEventBus.INSTANCE.post(criticalsEditEvent); + // Setup flags Vec3d position = new Vec3d(this.posX, this.getEntityBoundingBox().minY, this.posZ); Vec2f rotation = new Vec2f(this.rotationYaw, this.rotationPitch); boolean moving = isMoving(position); boolean rotating = isRotating(rotation); - updateWalkingPlayerEvent = new OnUpdateWalkingPlayerEvent(moving, rotating, position, rotation); - LambdaEventBus.INSTANCE.post(updateWalkingPlayerEvent); + OnUpdateWalkingPlayerEvent event = new OnUpdateWalkingPlayerEvent(moving, rotating, position, rotation); + LambdaEventBus.INSTANCE.post(event); - updateWalkingPlayerEvent = updateWalkingPlayerEvent.nextPhase(); - LambdaEventBus.INSTANCE.post(updateWalkingPlayerEvent); + event = event.nextPhase(); + LambdaEventBus.INSTANCE.post(event); - if (updateWalkingPlayerEvent.getCancelled()) { + if (event.getCancelled()) { ci.cancel(); - if (!updateWalkingPlayerEvent.getCancelAll()) { + if (!event.getCancelAll()) { // Copy flags from event - moving = updateWalkingPlayerEvent.isMoving(); - rotating = updateWalkingPlayerEvent.isRotating(); - position = updateWalkingPlayerEvent.getPosition(); - rotation = updateWalkingPlayerEvent.getRotation(); + moving = event.isMoving(); + rotating = event.isRotating(); + position = event.getPosition(); + rotation = event.getRotation(); sendSprintPacket(); sendSneakPacket(); @@ -195,24 +186,10 @@ public void onUpdateWalkingPlayerInvoke(CallbackInfo ci) ++this.positionUpdateTicks; this.autoJumpEnabled = this.mc.gameSettings.autoJump; - } else { - this.posX = updateWalkingPlayerEvent.getPosition().x; - this.posY = updateWalkingPlayerEvent.getPosition().y; - this.posZ = updateWalkingPlayerEvent.getPosition().z; - this.rotationYaw = updateWalkingPlayerEvent.getRotation().getX(); - this.rotationPitch = updateWalkingPlayerEvent.getRotation().getY(); } - } - @Inject(method = "onUpdateWalkingPlayer", at = @At("TAIL")) - private void onUpdateWalkingPlayerTail(CallbackInfo ci) { - final OnUpdateWalkingPlayerEvent event = updateWalkingPlayerEvent.nextPhase(); + event = event.nextPhase(); LambdaEventBus.INSTANCE.post(event); - this.posX = event.getPosInitial().x; - this.posY = event.getPosInitial().y; - this.posZ = event.getPosInitial().z; - this.rotationYaw = event.getRotInitial().getX(); - this.rotationPitch = event.getRotInitial().getY(); } private void sendSprintPacket() { diff --git a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt index 489976f41..d28ea0d05 100644 --- a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt +++ b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt @@ -9,16 +9,16 @@ import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.util.math.Vec2f import net.minecraft.util.math.Vec3d -class OnUpdateWalkingPlayerEvent constructor( +class OnUpdateWalkingPlayerEvent private constructor( moving: Boolean, rotating: Boolean, - var position: Vec3d, - var rotation: Vec2f, - override var phase: Phase + position: Vec3d, + rotation: Vec2f, + override val phase: Phase ) : Event, IMultiPhase, Cancellable() { - val posInitial = position - val rotInitial = rotation + var position = position; private set + var rotation = rotation; private set var moving = moving @JvmName("isMoving") get @@ -30,11 +30,9 @@ class OnUpdateWalkingPlayerEvent constructor( var cancelAll = false; private set constructor(moving: Boolean, rotating: Boolean, position: Vec3d, rotation: Vec2f) : this(moving, rotating, position, rotation, Phase.PRE) - constructor() : this(false, false, Vec3d.ZERO, Vec2f.ZERO) override fun nextPhase(): OnUpdateWalkingPlayerEvent { - phase = phase.next() - return this + return OnUpdateWalkingPlayerEvent(moving, rotating, position, rotation, phase.next()) } fun apply(packet: PlayerPacketManager.Packet) { @@ -52,4 +50,5 @@ class OnUpdateWalkingPlayerEvent constructor( this.cancelAll = packet.cancelAll } + } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 415a782ac..bd8a2ba73 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -1,12 +1,10 @@ package com.lambda.client.module.modules.player import com.lambda.client.LambdaMod +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.Phase import com.lambda.client.event.SafeClientEvent -import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent -import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.PlayerTravelEvent -import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.events.* import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar @@ -14,6 +12,7 @@ import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit @@ -31,15 +30,12 @@ import net.minecraft.block.state.IBlockState import net.minecraft.init.Blocks import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction -import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.network.play.server.SPacketBlockChange import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Vec3d import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import java.util.concurrent.ConcurrentHashMap -import kotlin.math.floor /** * @see MixinEntity.moveInvokeIsSneakingPre @@ -53,12 +49,12 @@ object Scaffold : Module( ) { private val page by setting("Page", Page.GENERAL) + private val blockSelectionMode by setting("Block Selection Mode", ScaffoldBlockSelectionMode.ANY) private val tower by setting("Tower", true, { page == Page.GENERAL }) private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) private val sneak by setting("Sneak", true, { page == Page.GENERAL }) private val visibleSideCheck by setting("Visible side check", true, { page == Page.GENERAL }) - private val sendOnGround by setting("Send onGround", true, { page == Page.GENERAL }) private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") private val timeout by setting("Timeout", 50, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") private val attempts by setting("Placement Search Depth", 3, 0..7, 1, { page == Page.GENERAL }) @@ -71,20 +67,39 @@ object Scaffold : Module( private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255)) + val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) + val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", linkedSetOf("minecraft:white_shulker_box", "minecraft:orange_shulker_box", + "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", + "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", + "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", + "minecraft:red_shulker_box", "minecraft:black_shulker_box", "minecraft:crafting_table", "minecraft:dropper", + "minecraft:hopper", "minecraft:dispenser", "minecraft:ender_chest", "minecraft:furnace"), + { false })) + private enum class Page { GENERAL, RENDER } + private enum class ScaffoldBlockSelectionMode(override val displayName: String): DisplayEnum { + ANY("Any"), + WHITELIST("Whitelist"), + BLACKLIST("Blacklist") + } + private var placeInfo: PlaceInfo? = null private val renderer = ESPRenderer() private val placeTimer = TickTimer(TimeUnit.TICKS) - private val rubberBandTimer = TickTimer(TimeUnit.TICKS) - private var lastPosVec = Vec3d.ZERO + private var towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) private val pendingBlocks = ConcurrentHashMap() init { + + onEnable { + towerTimer.reset() + } + onDisable { placeInfo = null pendingBlocks.clear() @@ -93,7 +108,6 @@ object Scaffold : Module( safeListener { event -> when (val packet = event.packet) { is SPacketPlayerPosLook -> { - rubberBandTimer.reset() pendingBlocks.forEach { world.setBlockState(it.key, it.value.blockState) } @@ -103,11 +117,9 @@ object Scaffold : Module( pendingBlocks[packet.blockPosition]?.let { pendingBlock -> if (pendingBlock.block == packet.blockState.block) { pendingBlocks.remove(packet.blockPosition) -// LambdaMod.LOG.error("Confirmed: $pendingBlock") } else { // probably ItemStack emtpy if (packet.blockState.block == Blocks.AIR) { - rubberBandTimer.reset() pendingBlocks.forEach { world.setBlockState(it.key, it.value.blockState) } @@ -122,18 +134,12 @@ object Scaffold : Module( safeListener { if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener - if (rubberBandTimer.tick(10, false)) { - if (shouldTower) { - if (sendOnGround && floor(lastPosVec.y) < floor(player.posY)) { - connection.sendPacket(CPacketPlayer(true)) - } - - player.motionY = 0.41999998688697815 - - lastPosVec = player.positionVector + if (shouldTower) { + mc.player.jump() + if (towerTimer.tick(30)) { + // reset pos back onto top block + mc.player.motionY = -0.3 } - } else if (player.fallDistance <= 2.0f) { - player.motionY = -0.169 } } @@ -148,6 +154,12 @@ object Scaffold : Module( renderer.render(clear = true) } + + safeListener { + if (tower) { + it.cancel() + } + } } private val SafeClientEvent.isHoldingBlock: Boolean @@ -176,9 +188,8 @@ object Scaffold : Module( return@safeListener } } - - if (rubberBandTimer.tick(10, false)) { - swapAndPlace(placeInfo) + swap()?.let { block -> + place(placeInfo, block) sendPlayerPacket { rotate(getRotationTo(placeInfo.hitVec)) } @@ -193,34 +204,69 @@ object Scaffold : Module( } } - private fun SafeClientEvent.swapAndPlace(placeInfo: PlaceInfo) { + private fun SafeClientEvent.swap(): Block? { + when (blockSelectionMode) { + ScaffoldBlockSelectionMode.ANY -> { + if (player.heldItemMainhand.item is ItemBlock) { + return player.heldItemMainhand.item.block + } + if (player.heldItemOffhand.item is ItemBlock) { + return player.heldItemOffhand.item.block + } + } + ScaffoldBlockSelectionMode.BLACKLIST -> { + if (player.heldItemMainhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemMainhand.item.block.registryName.toString())) { + return player.heldItemMainhand.item.block + } + if (player.heldItemOffhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemOffhand.item.block.registryName.toString())) { + return player.heldItemOffhand.item.block + } + } + ScaffoldBlockSelectionMode.WHITELIST -> { + if (player.heldItemMainhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemMainhand.item.block.registryName.toString())) { + return player.heldItemMainhand.item.block + } + if (player.heldItemOffhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemOffhand.item.block.registryName.toString())) { + return player.heldItemOffhand.item.block + } + } + } getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) else swapToSlot(slot) + return slot.stack.item.block + } + return null + } - if (placeTimer.tick(delay.toLong()) - && pendingBlocks.size < maxPending - ) { - val shouldSneak = sneak && !player.isSneaking - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) + private fun SafeClientEvent.place(placeInfo: PlaceInfo, blockToPlace: Block) { + if (placeTimer.tick(delay.toLong()) + && pendingBlocks.size < maxPending + ) { + val shouldSneak = sneak && !player.isSneaking + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) - placeBlock(placeInfo) + placeBlock(placeInfo) - pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, world.getBlockState(placeInfo.placedPos), slot.stack.item.block) - world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) -// LambdaMod.LOG.error("Placed: ${placeInfo.placedPos} ${slot.stack.item.block.localizedName}") + pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, world.getBlockState(placeInfo.placedPos), blockToPlace) + world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) - } + if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) } } private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { playerController.syncCurrentPlayItem() - return if (isUsableBlock(player.heldItemMainhand.item.block)) { - player.hotbarSlots[player.inventory.currentItem] - } else { - player.hotbarSlots.firstOrNull { isUsableBlock(it.stack.item.block) } + return player.hotbarSlots.firstItem { + when (blockSelectionMode) { + ScaffoldBlockSelectionMode.BLACKLIST -> { + return@firstItem !blockSelectionBlacklist.contains(it.item.block.registryName.toString()) + } + ScaffoldBlockSelectionMode.WHITELIST -> { + return@firstItem blockSelectionWhitelist.contains(it.item.block.registryName.toString()) + } + else -> return@firstItem true + } } } @@ -234,6 +280,4 @@ object Scaffold : Module( val age get() = System.currentTimeMillis() - timestamp } - - private fun isUsableBlock(block: Block) = InventoryManager.ejectList.contains(block.item.registryName.toString()) } \ No newline at end of file From e47fad86ca586afe0d863f20462d9d7e700b4eeb Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 23 Jan 2023 08:48:51 +0100 Subject: [PATCH 12/40] Small changes --- .../client/module/modules/player/Scaffold.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index bd8a2ba73..faf38f254 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -95,7 +95,6 @@ object Scaffold : Module( private val pendingBlocks = ConcurrentHashMap() init { - onEnable { towerTimer.reset() } @@ -125,7 +124,7 @@ object Scaffold : Module( } pendingBlocks.clear() } - LambdaMod.LOG.error("Other confirm: ${packet.blockPosition} ${packet.blockState.block}") + LambdaMod.LOG.warn("[$chatName] Other confirm: ${packet.blockPosition} ${packet.blockState.block}") } } } @@ -135,10 +134,10 @@ object Scaffold : Module( safeListener { if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener if (shouldTower) { - mc.player.jump() + player.jump() if (towerTimer.tick(30)) { // reset pos back onto top block - mc.player.motionY = -0.3 + player.motionY = -0.3 } } } @@ -176,7 +175,7 @@ object Scaffold : Module( pendingBlocks.values .filter { it.age > timeout * 50L } .forEach { pendingBlock -> - LambdaMod.LOG.error("Timeout: ${pendingBlock.blockPos}") + LambdaMod.LOG.warn("[$chatName] Timeout: ${pendingBlock.blockPos}") pendingBlocks.remove(pendingBlock.blockPos) world.setBlockState(pendingBlock.blockPos, pendingBlock.blockState) } @@ -184,7 +183,7 @@ object Scaffold : Module( placeInfo?.let { placeInfo -> pendingBlocks[placeInfo.placedPos]?.let { if (it.age < timeout * 50L) { - LambdaMod.LOG.error("Age: ${it.age}") +// LambdaMod.LOG.error("Age: ${it.age}") return@safeListener } } @@ -271,13 +270,11 @@ object Scaffold : Module( } private data class PendingBlock( - val timestamp: Long, val blockPos: BlockPos, val blockState: IBlockState, - val block: Block + val block: Block, + val timestamp: Long = System.currentTimeMillis() ) { - constructor(blockPos: BlockPos, blockState: IBlockState, block: Block) : this(System.currentTimeMillis(), blockPos, blockState, block) - val age get() = System.currentTimeMillis() - timestamp } } \ No newline at end of file From c1f83ec81ee89b3c549cd00a0a4c1e03f4cf9379 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 00:29:21 -0800 Subject: [PATCH 13/40] only tower when player is not moving --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index faf38f254..670d9f010 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -14,6 +14,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.EntityUtils.flooredPosition +import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.color.ColorHolder @@ -167,6 +168,7 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() + && mc.player.speed < 0.1 init { safeListener { event -> From 63706501cb725dfc440247be98e80a125e0c9478 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 19:18:36 -0800 Subject: [PATCH 14/40] refactor block selection --- .../client/module/modules/player/Scaffold.kt | 63 +++++++------------ 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 670d9f010..eaddd6707 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -29,6 +29,7 @@ import com.lambda.mixin.entity.MixinEntity import net.minecraft.block.Block import net.minecraft.block.state.IBlockState import net.minecraft.init.Blocks +import net.minecraft.item.Item import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction import net.minecraft.network.play.server.SPacketBlockChange @@ -81,10 +82,12 @@ object Scaffold : Module( GENERAL, RENDER } - private enum class ScaffoldBlockSelectionMode(override val displayName: String): DisplayEnum { - ANY("Any"), - WHITELIST("Whitelist"), - BLACKLIST("Blacklist") + private enum class ScaffoldBlockSelectionMode( + override val displayName: String, + val filter: (Item) -> Boolean): DisplayEnum { + ANY("Any", { it is ItemBlock }), + WHITELIST("Whitelist", { it is ItemBlock && blockSelectionWhitelist.contains(it.registryName.toString()) }), + BLACKLIST("Blacklist", { it is ItemBlock && !blockSelectionBlacklist.contains(it.registryName.toString()) }) } private var placeInfo: PlaceInfo? = null @@ -169,6 +172,7 @@ object Scaffold : Module( get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() && mc.player.speed < 0.1 + && getHeldScaffoldBlock() != null init { safeListener { event -> @@ -185,7 +189,6 @@ object Scaffold : Module( placeInfo?.let { placeInfo -> pendingBlocks[placeInfo.placedPos]?.let { if (it.age < timeout * 50L) { -// LambdaMod.LOG.error("Age: ${it.age}") return@safeListener } } @@ -206,32 +209,7 @@ object Scaffold : Module( } private fun SafeClientEvent.swap(): Block? { - when (blockSelectionMode) { - ScaffoldBlockSelectionMode.ANY -> { - if (player.heldItemMainhand.item is ItemBlock) { - return player.heldItemMainhand.item.block - } - if (player.heldItemOffhand.item is ItemBlock) { - return player.heldItemOffhand.item.block - } - } - ScaffoldBlockSelectionMode.BLACKLIST -> { - if (player.heldItemMainhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemMainhand.item.block.registryName.toString())) { - return player.heldItemMainhand.item.block - } - if (player.heldItemOffhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemOffhand.item.block.registryName.toString())) { - return player.heldItemOffhand.item.block - } - } - ScaffoldBlockSelectionMode.WHITELIST -> { - if (player.heldItemMainhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemMainhand.item.block.registryName.toString())) { - return player.heldItemMainhand.item.block - } - if (player.heldItemOffhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemOffhand.item.block.registryName.toString())) { - return player.heldItemOffhand.item.block - } - } - } + getHeldScaffoldBlock()?.let { return it } getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) else swapToSlot(slot) @@ -256,19 +234,20 @@ object Scaffold : Module( } } - private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { + private fun SafeClientEvent.getHeldScaffoldBlock(): Block? { playerController.syncCurrentPlayItem() - return player.hotbarSlots.firstItem { - when (blockSelectionMode) { - ScaffoldBlockSelectionMode.BLACKLIST -> { - return@firstItem !blockSelectionBlacklist.contains(it.item.block.registryName.toString()) - } - ScaffoldBlockSelectionMode.WHITELIST -> { - return@firstItem blockSelectionWhitelist.contains(it.item.block.registryName.toString()) - } - else -> return@firstItem true - } + if (blockSelectionMode.filter(player.heldItemMainhand.item)) { + return player.heldItemMainhand.item.block + } + if (blockSelectionMode.filter(player.heldItemOffhand.item)) { + return player.heldItemOffhand.item.block } + return null + } + + private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { + playerController.syncCurrentPlayItem() + return player.hotbarSlots.firstItem { blockSelectionMode.filter(it.item) } } private data class PendingBlock( From 1a272222a84b696a447982fe370eafe1da21b21b Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 24 Jan 2023 04:52:37 +0100 Subject: [PATCH 15/40] Little cleanup --- .../client/module/modules/player/Scaffold.kt | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index eaddd6707..457c90521 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -121,14 +121,14 @@ object Scaffold : Module( if (pendingBlock.block == packet.blockState.block) { pendingBlocks.remove(packet.blockPosition) } else { - // probably ItemStack emtpy + // probably ItemStack empty if (packet.blockState.block == Blocks.AIR) { pendingBlocks.forEach { world.setBlockState(it.key, it.value.blockState) } pendingBlocks.clear() } - LambdaMod.LOG.warn("[$chatName] Other confirm: ${packet.blockPosition} ${packet.blockState.block}") + LambdaMod.LOG.warn("$chatName Other confirm: ${packet.blockPosition} ${packet.blockState.block}") } } } @@ -136,13 +136,12 @@ object Scaffold : Module( } safeListener { - if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener - if (shouldTower) { - player.jump() - if (towerTimer.tick(30)) { - // reset pos back onto top block - player.motionY = -0.3 - } + if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock || !shouldTower) return@safeListener + + player.jump() + if (towerTimer.tick(30)) { + // reset pos back onto top block + player.motionY = -0.3 } } @@ -159,9 +158,7 @@ object Scaffold : Module( } safeListener { - if (tower) { - it.cancel() - } + if (tower) it.cancel() } } @@ -181,7 +178,7 @@ object Scaffold : Module( pendingBlocks.values .filter { it.age > timeout * 50L } .forEach { pendingBlock -> - LambdaMod.LOG.warn("[$chatName] Timeout: ${pendingBlock.blockPos}") + LambdaMod.LOG.warn("$chatName Timeout: ${pendingBlock.blockPos}") pendingBlocks.remove(pendingBlock.blockPos) world.setBlockState(pendingBlock.blockPos, pendingBlock.blockState) } From 36aa8db5a83df1b71d68ded1d8841b3e447d6f3f Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 20:50:21 -0800 Subject: [PATCH 16/40] tower check hotbarspoof compat --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 457c90521..e7b3123c8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -169,7 +169,7 @@ object Scaffold : Module( get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() && mc.player.speed < 0.1 - && getHeldScaffoldBlock() != null + && (getHeldScaffoldBlock() != null || getBlockSlot() != null) init { safeListener { event -> From 6452966a0adec2eb2aa527ff17c6e58d1eb21356 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 22:05:53 -0800 Subject: [PATCH 17/40] in water tower check --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index e7b3123c8..0c9604a73 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -167,6 +167,7 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround + && !player.isInWater && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() && mc.player.speed < 0.1 && (getHeldScaffoldBlock() != null || getBlockSlot() != null) From 21cb97c4497d1c8acc9d4733194f5b38fc7bfb38 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 22:49:18 -0800 Subject: [PATCH 18/40] water tower scaffold and place on water surface --- .../client/module/modules/player/Scaffold.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 0c9604a73..75973b2cb 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -136,12 +136,17 @@ object Scaffold : Module( } safeListener { - if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock || !shouldTower) return@safeListener - - player.jump() - if (towerTimer.tick(30)) { - // reset pos back onto top block - player.motionY = -0.3 + if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener + if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { + mc.player.motionY = .11 + return@safeListener + } + if (shouldTower) { + player.jump() + if (towerTimer.tick(30)) { + // reset pos back onto top block + player.motionY = -0.3 + } } } @@ -167,7 +172,6 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround - && !player.isInWater && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() && mc.player.speed < 0.1 && (getHeldScaffoldBlock() != null || getBlockSlot() != null) From daee9d6573df1eb945a4d1d18dd9cd670c811db3 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 22:53:47 -0800 Subject: [PATCH 19/40] small style --- .../com/lambda/client/module/modules/player/Scaffold.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 75973b2cb..e7947ab06 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -138,10 +138,8 @@ object Scaffold : Module( safeListener { if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { - mc.player.motionY = .11 - return@safeListener - } - if (shouldTower) { + player.motionY = .11 + } else if (shouldTower) { player.jump() if (towerTimer.tick(30)) { // reset pos back onto top block From 36633177a77c9dbdeb0bfb9851961f9380d6d520 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 23:24:18 -0800 Subject: [PATCH 20/40] swap in blocks from inventory when not in hotbar --- .../com/lambda/client/module/modules/player/Scaffold.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index e7947ab06..c5f8542bc 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -215,6 +215,13 @@ object Scaffold : Module( else swapToSlot(slot) return slot.stack.item.block } + if (swapToBlockOrMove(this@Scaffold, { blockSelectionMode.filter(it.item) } )) { + getBlockSlot()?.let { slot -> + if (spoofHotbar) spoofHotbar(slot) + else swapToSlot(slot) + return slot.stack.item.block + } + } return null } From a1d56c16fad8b3effa6524760aadce54e2b49df6 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 23 Jan 2023 23:30:31 -0800 Subject: [PATCH 21/40] assign all settings to a page --- .../com/lambda/client/module/modules/player/Scaffold.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index c5f8542bc..fe7a5f0e8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -51,7 +51,7 @@ object Scaffold : Module( ) { private val page by setting("Page", Page.GENERAL) - private val blockSelectionMode by setting("Block Selection Mode", ScaffoldBlockSelectionMode.ANY) + private val blockSelectionMode by setting("Block Selection Mode", ScaffoldBlockSelectionMode.ANY, { page == Page.GENERAL }) private val tower by setting("Tower", true, { page == Page.GENERAL }) private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) @@ -67,7 +67,7 @@ object Scaffold : Module( private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") - private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255)) + private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255), visibility = { page == Page.RENDER }) val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", linkedSetOf("minecraft:white_shulker_box", "minecraft:orange_shulker_box", From 59ac10cc2513a1bec5baf3c881bf7c6d2976b9fc Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 02:16:53 +0100 Subject: [PATCH 22/40] Added NoFall enabler and boundary checks for placements --- .../client/module/modules/player/NoFall.kt | 4 +- .../client/module/modules/player/Scaffold.kt | 41 +++++++++++-------- .../com/lambda/client/util/world/Check.kt | 4 +- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt b/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt index d2debd413..13db8316a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt @@ -27,12 +27,12 @@ object NoFall : Module( category = Category.PLAYER ) { private val distance by setting("Distance", 3, 1..10, 1) - private val mode by setting("Mode", Mode.CATCH) + var mode by setting("Mode", Mode.CATCH) private val fallModeSetting by setting("Fall", FallMode.PACKET, { mode == Mode.FALL }) private val catchModeSetting by setting("Catch", CatchMode.MOTION, { mode == Mode.CATCH }) private val voidOnly by setting("Void Only", false, { mode == Mode.CATCH }) - private enum class Mode { + enum class Mode { FALL, CATCH } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index fe7a5f0e8..bf7e54912 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -95,17 +95,31 @@ object Scaffold : Module( private val placeTimer = TickTimer(TimeUnit.TICKS) private var towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private var noFall = false + private var fallMode = NoFall.Mode.CATCH private val pendingBlocks = ConcurrentHashMap() init { onEnable { towerTimer.reset() + noFall = NoFall.isEnabled + fallMode = NoFall.mode + + NoFall.mode = NoFall.Mode.CATCH + NoFall.enable() } onDisable { placeInfo = null pendingBlocks.clear() + + if (!noFall) { + NoFall.disable() + } + if (fallMode != NoFall.mode) { + NoFall.mode = fallMode + } } safeListener { event -> @@ -117,27 +131,14 @@ object Scaffold : Module( pendingBlocks.clear() } is SPacketBlockChange -> { - pendingBlocks[packet.blockPosition]?.let { pendingBlock -> - if (pendingBlock.block == packet.blockState.block) { - pendingBlocks.remove(packet.blockPosition) - } else { - // probably ItemStack empty - if (packet.blockState.block == Blocks.AIR) { - pendingBlocks.forEach { - world.setBlockState(it.key, it.value.blockState) - } - pendingBlocks.clear() - } - LambdaMod.LOG.warn("$chatName Other confirm: ${packet.blockPosition} ${packet.blockState.block}") - } - } + pendingBlocks.remove(packet.blockPosition) } } } safeListener { if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener - if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { + if (player.isInWater || player.isInLava) { player.motionY = .11 } else if (shouldTower) { player.jump() @@ -171,7 +172,7 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() - && mc.player.speed < 0.1 + && player.speed < 0.1 && (getHeldScaffoldBlock() != null || getBlockSlot() != null) init { @@ -204,7 +205,13 @@ object Scaffold : Module( safeListener { event -> if (event.phase != Phase.PRE) return@safeListener - placeInfo = getNeighbour(player.flooredPosition.down(), attempts, visibleSideCheck = visibleSideCheck) + val placePos = if (player.flooredPosition.y > 256) { + BlockPos(player.flooredPosition.x, 256, player.flooredPosition.z) + } else { + player.flooredPosition.down() + } + + placeInfo = getNeighbour(placePos, attempts, visibleSideCheck = visibleSideCheck) } } diff --git a/src/main/kotlin/com/lambda/client/util/world/Check.kt b/src/main/kotlin/com/lambda/client/util/world/Check.kt index 6225435fb..9e25de3d2 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Check.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Check.kt @@ -107,4 +107,6 @@ fun SafeClientEvent.hasNeighbour(pos: BlockPos): Boolean { */ fun World.isPlaceable(pos: BlockPos, ignoreSelfCollide: Boolean = false) = this.getBlockState(pos).isReplaceable - && this.checkNoEntityCollision(AxisAlignedBB(pos), if (ignoreSelfCollide) Wrapper.player else null) \ No newline at end of file + && checkNoEntityCollision(AxisAlignedBB(pos), if (ignoreSelfCollide) Wrapper.player else null) + && worldBorder.contains(pos) + && !isOutsideBuildHeight(pos) \ No newline at end of file From ef7f33c0eece3ef867b06de0e386cc7eff3e549b Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 03:05:03 +0100 Subject: [PATCH 23/40] Build down mode --- .../client/module/modules/player/Scaffold.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index bf7e54912..b103ac945 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -35,6 +35,7 @@ import net.minecraft.network.play.client.CPacketEntityAction import net.minecraft.network.play.server.SPacketBlockChange import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.math.BlockPos +import net.minecraftforge.client.event.InputUpdateEvent import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import java.util.concurrent.ConcurrentHashMap @@ -97,6 +98,7 @@ object Scaffold : Module( private var towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) private var noFall = false private var fallMode = NoFall.Mode.CATCH + private var down = false private val pendingBlocks = ConcurrentHashMap() @@ -205,14 +207,28 @@ object Scaffold : Module( safeListener { event -> if (event.phase != Phase.PRE) return@safeListener - val placePos = if (player.flooredPosition.y > 256) { - BlockPos(player.flooredPosition.x, 256, player.flooredPosition.z) + val origin = if (down) { + down = false + player.flooredPosition.down(2) } else { player.flooredPosition.down() } + val placePos = if (origin.y > 256) { + BlockPos(origin.x, 256, player.flooredPosition.z) + } else { + origin + } + placeInfo = getNeighbour(placePos, attempts, visibleSideCheck = visibleSideCheck) } + + safeListener { + if (it.movementInput.sneak) { + down = true + it.movementInput.sneak = false + } + } } private fun SafeClientEvent.swap(): Block? { From 635d32f41d7552b04a1edec89428579f2aeae4ef Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 03:11:33 +0100 Subject: [PATCH 24/40] Missed this --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index b103ac945..774e47868 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -215,7 +215,7 @@ object Scaffold : Module( } val placePos = if (origin.y > 256) { - BlockPos(origin.x, 256, player.flooredPosition.z) + BlockPos(origin.x, 256, origin.z) } else { origin } From 21a1b29278c3edd6b51f9ccb2eecb9435eebe48e Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:49:02 -0800 Subject: [PATCH 25/40] tower: burrow check --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 774e47868..b7fab5010 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -174,7 +174,8 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() - && player.speed < 0.1 + && world.getCollisionBoxes(player, player.entityBoundingBox).isEmpty() + && mc.player.speed < 0.1 && (getHeldScaffoldBlock() != null || getBlockSlot() != null) init { From 871a98d041bc395e53cb776b63c0452b065f8712 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:07:14 -0800 Subject: [PATCH 26/40] improve water tower reliability --- .../client/module/modules/player/Scaffold.kt | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index b7fab5010..e6cb1626c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -56,6 +56,7 @@ object Scaffold : Module( private val tower by setting("Tower", true, { page == Page.GENERAL }) private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) + private val useNoFall by setting("No Fall", false, { page == Page.GENERAL }) private val sneak by setting("Sneak", true, { page == Page.GENERAL }) private val visibleSideCheck by setting("Visible side check", true, { page == Page.GENERAL }) private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") @@ -95,7 +96,9 @@ object Scaffold : Module( private val renderer = ESPRenderer() private val placeTimer = TickTimer(TimeUnit.TICKS) - private var towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private val towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private val waterTowerTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private val posLookTimer: TickTimer = TickTimer(TimeUnit.TICKS) private var noFall = false private var fallMode = NoFall.Mode.CATCH private var down = false @@ -105,22 +108,26 @@ object Scaffold : Module( init { onEnable { towerTimer.reset() - noFall = NoFall.isEnabled - fallMode = NoFall.mode + if (useNoFall) { + noFall = NoFall.isEnabled + fallMode = NoFall.mode - NoFall.mode = NoFall.Mode.CATCH - NoFall.enable() + NoFall.mode = NoFall.Mode.CATCH + NoFall.enable() + } } onDisable { placeInfo = null pendingBlocks.clear() - if (!noFall) { - NoFall.disable() - } - if (fallMode != NoFall.mode) { - NoFall.mode = fallMode + if (useNoFall) { + if (!noFall) { + NoFall.disable() + } + if (fallMode != NoFall.mode) { + NoFall.mode = fallMode + } } } @@ -131,6 +138,7 @@ object Scaffold : Module( world.setBlockState(it.key, it.value.blockState) } pendingBlocks.clear() + posLookTimer.reset() } is SPacketBlockChange -> { pendingBlocks.remove(packet.blockPosition) @@ -139,14 +147,23 @@ object Scaffold : Module( } safeListener { - if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock) return@safeListener - if (player.isInWater || player.isInLava) { + if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock || !posLookTimer.tick(15, false)) { + towerTimer.reset() + return@safeListener + } + if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { player.motionY = .11 + towerTimer.reset() + waterTowerTimer.reset() } else if (shouldTower) { - player.jump() - if (towerTimer.tick(30)) { - // reset pos back onto top block - player.motionY = -0.3 + if (waterTowerTimer.tick(5, false)) { + player.jump() + if (towerTimer.tick(30)) { + // reset pos back onto top block + player.motionY = -0.3 + } + } else { + towerTimer.reset() } } } From 8d33f612db55a8e26a59db90de59a66d117d1c94 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:14:14 -0800 Subject: [PATCH 27/40] reset movement speed to slightly slower than normal during down scaffold --- .../com/lambda/client/module/modules/player/Scaffold.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index e6cb1626c..360c6dc4b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -245,6 +245,13 @@ object Scaffold : Module( if (it.movementInput.sneak) { down = true it.movementInput.sneak = false + // reset to original speed + it.movementInput.moveForward /= 0.3f + it.movementInput.moveStrafe /= 0.3f + + // reduce our speed a bit to help with placements + it.movementInput.moveForward *= 0.6f + it.movementInput.moveStrafe *= 0.6f } } } From 89a9bbcc6eb2b8ea1c33a3e1d8a475e9b2748fa0 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 24 Jan 2023 21:02:49 -0800 Subject: [PATCH 28/40] mc bingbong --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 360c6dc4b..a3c91b966 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -192,7 +192,7 @@ object Scaffold : Module( get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() && world.getCollisionBoxes(player, player.entityBoundingBox).isEmpty() - && mc.player.speed < 0.1 + && player.speed < 0.1 && (getHeldScaffoldBlock() != null || getBlockSlot() != null) init { From 099e2b0df74c40bd36cd280ccc3075e620acd121 Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 06:27:45 +0100 Subject: [PATCH 29/40] Cleanup --- .../client/module/modules/player/Scaffold.kt | 76 +++++++++---------- .../com/lambda/client/util/world/Interact.kt | 4 +- 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index a3c91b966..7f84f9cb7 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -57,7 +57,7 @@ object Scaffold : Module( private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) private val useNoFall by setting("No Fall", false, { page == Page.GENERAL }) - private val sneak by setting("Sneak", true, { page == Page.GENERAL }) + private val descendOnSneak by setting("Descend on sneak", true, { page == Page.GENERAL }) private val visibleSideCheck by setting("Visible side check", true, { page == Page.GENERAL }) private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") private val timeout by setting("Timeout", 50, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") @@ -99,36 +99,34 @@ object Scaffold : Module( private val towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) private val waterTowerTimer: TickTimer = TickTimer(TimeUnit.TICKS) private val posLookTimer: TickTimer = TickTimer(TimeUnit.TICKS) - private var noFall = false - private var fallMode = NoFall.Mode.CATCH - private var down = false + private var oldNoFall = false + private var oldFallMode = NoFall.Mode.CATCH + private var goDown = false private val pendingBlocks = ConcurrentHashMap() init { onEnable { towerTimer.reset() - if (useNoFall) { - noFall = NoFall.isEnabled - fallMode = NoFall.mode - NoFall.mode = NoFall.Mode.CATCH - NoFall.enable() - } + if (!useNoFall) return@onEnable + + oldNoFall = NoFall.isEnabled + oldFallMode = NoFall.mode + + NoFall.mode = NoFall.Mode.CATCH + NoFall.enable() } onDisable { placeInfo = null pendingBlocks.clear() - if (useNoFall) { - if (!noFall) { - NoFall.disable() - } - if (fallMode != NoFall.mode) { - NoFall.mode = fallMode - } - } + if (!useNoFall) return@onDisable + if (!oldNoFall) NoFall.disable() + + NoFall.mode = oldFallMode + oldNoFall = false } safeListener { event -> @@ -225,34 +223,27 @@ object Scaffold : Module( safeListener { event -> if (event.phase != Phase.PRE) return@safeListener - val origin = if (down) { - down = false + val origin = if (goDown && descendOnSneak) { + goDown = false player.flooredPosition.down(2) } else { player.flooredPosition.down() } - val placePos = if (origin.y > 256) { - BlockPos(origin.x, 256, origin.z) - } else { - origin - } - - placeInfo = getNeighbour(placePos, attempts, visibleSideCheck = visibleSideCheck) + placeInfo = getNeighbour( + BlockPos(origin.x, origin.y.coerceIn(0..256), origin.z), + attempts, + visibleSideCheck = visibleSideCheck + ) } safeListener { - if (it.movementInput.sneak) { - down = true - it.movementInput.sneak = false - // reset to original speed - it.movementInput.moveForward /= 0.3f - it.movementInput.moveStrafe /= 0.3f - - // reduce our speed a bit to help with placements - it.movementInput.moveForward *= 0.6f - it.movementInput.moveStrafe *= 0.6f - } + if (!descendOnSneak || !it.movementInput.sneak) return@safeListener + + goDown = true + it.movementInput.sneak = false + it.movementInput.moveStrafe *= 5f + it.movementInput.moveForward *= 5f } } @@ -277,15 +268,16 @@ object Scaffold : Module( if (placeTimer.tick(delay.toLong()) && pendingBlocks.size < maxPending ) { - val shouldSneak = sneak && !player.isSneaking - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) + val isBlacklisted = world.getBlockState(placeInfo.pos).block in blockBlacklist + + if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) placeBlock(placeInfo) + if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) + pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, world.getBlockState(placeInfo.placedPos), blockToPlace) world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) - - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) } } diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index d241d0a6d..cddd9c15a 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -275,8 +275,7 @@ private suspend fun SafeClientEvent.doPlace( */ fun SafeClientEvent.placeBlock( placeInfo: PlaceInfo, - hand: EnumHand = EnumHand.MAIN_HAND, - noGhost: Boolean = true + hand: EnumHand = EnumHand.MAIN_HAND ) { if (!world.isPlaceable(placeInfo.placedPos)) return @@ -289,7 +288,6 @@ fun SafeClientEvent.placeBlock( val blockState = block.getStateForPlacement(world, placeInfo.pos, placeInfo.side, placeInfo.hitVecOffset.x.toFloat(), placeInfo.hitVecOffset.y.toFloat(), placeInfo.hitVecOffset.z.toFloat(), metaData, player, EnumHand.MAIN_HAND) val soundType = blockState.block.getSoundType(blockState, world, placeInfo.pos, player) world.playSound(player, placeInfo.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) - if (!noGhost) world.setBlockState(placeInfo.placedPos, blockState) } fun PlaceInfo.toPlacePacket(hand: EnumHand) = From fd7cba6a3c58993c2b81b8c61ae5beb6b233236e Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 25 Jan 2023 00:52:48 -0800 Subject: [PATCH 30/40] prevent sneak place opening blacklisted blocks --- .../lambda/client/module/modules/player/Scaffold.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 7f84f9cb7..d093d55d5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -268,7 +268,7 @@ object Scaffold : Module( if (placeTimer.tick(delay.toLong()) && pendingBlocks.size < maxPending ) { - val isBlacklisted = world.getBlockState(placeInfo.pos).block in blockBlacklist + val isBlacklisted = isPlaceBlockBlacklisted(placeInfo) if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) @@ -281,6 +281,14 @@ object Scaffold : Module( } } + private fun SafeClientEvent.isPlaceBlockBlacklisted(placeInfo: PlaceInfo): Boolean { + pendingBlocks[placeInfo.placedPos]?.let { + return it.block in blockBlacklist + } + val worldBlockState = world.getBlockState(placeInfo.pos).block + return worldBlockState in blockBlacklist || worldBlockState == Blocks.BARRIER + } + private fun SafeClientEvent.getHeldScaffoldBlock(): Block? { playerController.syncCurrentPlayItem() if (blockSelectionMode.filter(player.heldItemMainhand.item)) { From 036434ff25e056bc37c5f75e59a57d4ad41cde1a Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 25 Jan 2023 00:58:28 -0800 Subject: [PATCH 31/40] barrier = undefined, prefer not sneaking ig --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index d093d55d5..65995258f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -286,7 +286,7 @@ object Scaffold : Module( return it.block in blockBlacklist } val worldBlockState = world.getBlockState(placeInfo.pos).block - return worldBlockState in blockBlacklist || worldBlockState == Blocks.BARRIER + return worldBlockState in blockBlacklist } private fun SafeClientEvent.getHeldScaffoldBlock(): Block? { From e7199100c33d73dd33d3cc6ca042fa9bef81f69e Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 25 Jan 2023 01:00:39 -0800 Subject: [PATCH 32/40] oneliner --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 65995258f..c70cc598a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -285,8 +285,7 @@ object Scaffold : Module( pendingBlocks[placeInfo.placedPos]?.let { return it.block in blockBlacklist } - val worldBlockState = world.getBlockState(placeInfo.pos).block - return worldBlockState in blockBlacklist + return world.getBlockState(placeInfo.pos).block in blockBlacklist } private fun SafeClientEvent.getHeldScaffoldBlock(): Block? { From cf5ecf6317ee5e31e4c797101799c4f18c9aba66 Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 19:11:24 +0100 Subject: [PATCH 33/40] Other defaults and prevent action on flight --- .../lambda/client/module/modules/player/Scaffold.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index c70cc598a..fd0aeb038 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -60,9 +60,9 @@ object Scaffold : Module( private val descendOnSneak by setting("Descend on sneak", true, { page == Page.GENERAL }) private val visibleSideCheck by setting("Visible side check", true, { page == Page.GENERAL }) private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") - private val timeout by setting("Timeout", 50, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") + private val timeout by setting("Timeout", 15, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") private val attempts by setting("Placement Search Depth", 3, 0..7, 1, { page == Page.GENERAL }) - private val maxPending by setting("Max Pending", 2, 0..5, 1, { page == Page.GENERAL }) + private val maxPending by setting("Max Pending", 3, 0..10, 1, { page == Page.GENERAL }) private val below by setting("Max Tower Distance", 0.3, 0.0..2.0, 0.01, { page == Page.GENERAL }) private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") @@ -190,6 +190,7 @@ object Scaffold : Module( get() = !player.onGround && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() && world.getCollisionBoxes(player, player.entityBoundingBox).isEmpty() + && !player.capabilities.isFlying && player.speed < 0.1 && (getHeldScaffoldBlock() != null || getBlockSlot() != null) @@ -238,7 +239,10 @@ object Scaffold : Module( } safeListener { - if (!descendOnSneak || !it.movementInput.sneak) return@safeListener + if (!descendOnSneak + || !it.movementInput.sneak + || player.capabilities.isFlying + ) return@safeListener goDown = true it.movementInput.sneak = false From 5eb32f18b2afe124311bee6998a9369b227aebed Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 19:22:05 +0100 Subject: [PATCH 34/40] Check for correct item --- .../lambda/client/module/modules/player/Scaffold.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index fd0aeb038..475938b57 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -12,6 +12,7 @@ import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.module.modules.player.Scaffold.isUsableItem import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.MovementUtils.speed @@ -24,6 +25,7 @@ import com.lambda.client.util.math.RotationUtils.getRotationTo import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour +import com.lambda.client.util.world.isFullBox import com.lambda.client.util.world.placeBlock import com.lambda.mixin.entity.MixinEntity import net.minecraft.block.Block @@ -87,9 +89,9 @@ object Scaffold : Module( private enum class ScaffoldBlockSelectionMode( override val displayName: String, val filter: (Item) -> Boolean): DisplayEnum { - ANY("Any", { it is ItemBlock }), - WHITELIST("Whitelist", { it is ItemBlock && blockSelectionWhitelist.contains(it.registryName.toString()) }), - BLACKLIST("Blacklist", { it is ItemBlock && !blockSelectionBlacklist.contains(it.registryName.toString()) }) + ANY("Any", { it.isUsableItem() }), + WHITELIST("Whitelist", { blockSelectionWhitelist.contains(it.registryName.toString()) && it.isUsableItem() }), + BLACKLIST("Blacklist", { !blockSelectionBlacklist.contains(it.registryName.toString()) && it.isUsableItem() }) } private var placeInfo: PlaceInfo? = null @@ -316,4 +318,6 @@ object Scaffold : Module( ) { val age get() = System.currentTimeMillis() - timestamp } + + private fun Item.isUsableItem() = this is ItemBlock && block.defaultState.isFullBox } \ No newline at end of file From 7cbba79e661c5c228cd80d2bbe2d5e3281385f7f Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 19:27:06 +0100 Subject: [PATCH 35/40] Use shulkerList --- .../com/lambda/client/module/modules/player/Scaffold.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 475938b57..9502c6e1b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -74,13 +74,7 @@ object Scaffold : Module( private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255), visibility = { page == Page.RENDER }) val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) - val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", linkedSetOf("minecraft:white_shulker_box", "minecraft:orange_shulker_box", - "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", - "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", - "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", - "minecraft:red_shulker_box", "minecraft:black_shulker_box", "minecraft:crafting_table", "minecraft:dropper", - "minecraft:hopper", "minecraft:dispenser", "minecraft:ender_chest", "minecraft:furnace"), - { false })) + val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", shulkerList.map { it.registryName.toString() }.toMutableSet(), { false })) private enum class Page { GENERAL, RENDER From 296772b26b54e4257c9022b2e7a49f01fff67ac3 Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 19:27:55 +0100 Subject: [PATCH 36/40] Ops i mean blacklist --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 9502c6e1b..9678b8897 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -74,7 +74,7 @@ object Scaffold : Module( private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255), visibility = { page == Page.RENDER }) val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) - val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", shulkerList.map { it.registryName.toString() }.toMutableSet(), { false })) + val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", blockBlacklist.map { it.registryName.toString() }.toMutableSet(), { false })) private enum class Page { GENERAL, RENDER From 9e4ebb99a54b5635869456955c5fd1ebd0b9e4a1 Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 19:55:35 +0100 Subject: [PATCH 37/40] Fix blockBlacklist --- .../client/module/modules/player/Scaffold.kt | 9 +--- .../com/lambda/client/util/items/Block.kt | 50 ++++++++++++++++--- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 9678b8897..494f29f5c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -268,7 +268,7 @@ object Scaffold : Module( if (placeTimer.tick(delay.toLong()) && pendingBlocks.size < maxPending ) { - val isBlacklisted = isPlaceBlockBlacklisted(placeInfo) + val isBlacklisted = blockToPlace in blockBlacklist if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) @@ -281,13 +281,6 @@ object Scaffold : Module( } } - private fun SafeClientEvent.isPlaceBlockBlacklisted(placeInfo: PlaceInfo): Boolean { - pendingBlocks[placeInfo.placedPos]?.let { - return it.block in blockBlacklist - } - return world.getBlockState(placeInfo.pos).block in blockBlacklist - } - private fun SafeClientEvent.getHeldScaffoldBlock(): Block? { playerController.syncCurrentPlayItem() if (blockSelectionMode.filter(player.heldItemMainhand.item)) { diff --git a/src/main/kotlin/com/lambda/client/util/items/Block.kt b/src/main/kotlin/com/lambda/client/util/items/Block.kt index b67e3ad22..cd9184b88 100644 --- a/src/main/kotlin/com/lambda/client/util/items/Block.kt +++ b/src/main/kotlin/com/lambda/client/util/items/Block.kt @@ -24,19 +24,53 @@ val shulkerList: Set = hashSetOf( ) val blockBlacklist: Set = hashSetOf( - Blocks.ENDER_CHEST, - Blocks.CHEST, - Blocks.TRAPPED_CHEST, - Blocks.CRAFTING_TABLE, Blocks.ANVIL, + Blocks.BEACON, + Blocks.BED, Blocks.BREWING_STAND, - Blocks.HOPPER, - Blocks.DROPPER, + Blocks.STONE_BUTTON, + Blocks.WOODEN_BUTTON, + Blocks.CAKE, + Blocks.CAULDRON, + Blocks.CHEST, + Blocks.TRAPPED_CHEST, + Blocks.COMMAND_BLOCK, + Blocks.CHAIN_COMMAND_BLOCK, + Blocks.REPEATING_COMMAND_BLOCK, + Blocks.DAYLIGHT_DETECTOR, + Blocks.DAYLIGHT_DETECTOR_INVERTED, Blocks.DISPENSER, - Blocks.TRAPDOOR, + Blocks.DROPPER, + Blocks.OAK_DOOR, + Blocks.DARK_OAK_DOOR, + Blocks.ACACIA_DOOR, + Blocks.BIRCH_DOOR, + Blocks.JUNGLE_DOOR, + Blocks.SPRUCE_DOOR, Blocks.ENCHANTING_TABLE, + Blocks.ENDER_CHEST, + Blocks.OAK_FENCE_GATE, + Blocks.ACACIA_FENCE_GATE, + Blocks.BIRCH_FENCE_GATE, + Blocks.DARK_OAK_FENCE_GATE, + Blocks.JUNGLE_FENCE_GATE, + Blocks.SPRUCE_FENCE_GATE, + Blocks.FLOWER_POT, + Blocks.FURNACE, + Blocks.HOPPER, + Blocks.JUKEBOX, + Blocks.LEVER, + Blocks.NOTEBLOCK, + Blocks.POWERED_COMPARATOR, + Blocks.UNPOWERED_COMPARATOR, + Blocks.REDSTONE_ORE, + Blocks.POWERED_REPEATER, + Blocks.UNPOWERED_REPEATER, Blocks.STANDING_SIGN, - Blocks.WALL_SIGN + Blocks.WALL_SIGN, + Blocks.STRUCTURE_BLOCK, + Blocks.TRAPDOOR, + Blocks.CRAFTING_TABLE, ).apply { addAll(shulkerList) } From 6b8a87d20172bfb17c8344e5e11f04c898ddc548 Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 20:01:35 +0100 Subject: [PATCH 38/40] Seems to need both --- .../kotlin/com/lambda/client/module/modules/player/Scaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 494f29f5c..979610a49 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -268,7 +268,7 @@ object Scaffold : Module( if (placeTimer.tick(delay.toLong()) && pendingBlocks.size < maxPending ) { - val isBlacklisted = blockToPlace in blockBlacklist + val isBlacklisted = world.getBlockState(placeInfo.pos).block in blockBlacklist || blockToPlace in blockBlacklist if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) From 7ae32f44bf5a244d5e09c6bfe83f252ef9fb4de6 Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 20:15:19 +0100 Subject: [PATCH 39/40] Use utils --- .../client/command/commands/ScaffoldCommand.kt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt index 32713b74e..e4239b762 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt @@ -2,28 +2,20 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand import com.lambda.client.module.modules.player.Scaffold +import com.lambda.client.util.items.shulkerList import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import net.minecraft.init.Blocks object ScaffoldCommand : ClientCommand( name = "scaffold", description = "Manage scaffold whitelist/blacklist" ) { - private val allShulkerBoxes = listOf(Blocks.WHITE_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, - Blocks.MAGENTA_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, - Blocks.LIME_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.SILVER_SHULKER_BOX, - Blocks.CYAN_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, - Blocks.GREEN_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.BLACK_SHULKER_BOX) - .map { it.registryName.toString() } - .toList() - init { literal("whitelist", "wl") { literal("add", "+") { literal("shulker_box") { execute("Add all shulker box types to whitelist") { - Scaffold.blockSelectionWhitelist.editValue { whitelist -> allShulkerBoxes.forEach { whitelist.add(it) } } + Scaffold.blockSelectionWhitelist.editValue { whitelist -> shulkerList.forEach { whitelist.add(it.localizedName) } } MessageSendHelper.sendChatMessage("All shulker boxes have been added to whitelist") } } @@ -42,7 +34,7 @@ object ScaffoldCommand : ClientCommand( literal("del", "-") { literal("shulker_box") { execute("Remove all shulker box types from whitelist") { - Scaffold.blockSelectionWhitelist.editValue { whitelist -> allShulkerBoxes.forEach { whitelist.remove(it) } } + Scaffold.blockSelectionWhitelist.editValue { whitelist -> shulkerList.forEach { whitelist.remove(it.localizedName) } } MessageSendHelper.sendChatMessage("All shulker boxes have been removed from whitelist") } } @@ -70,7 +62,7 @@ object ScaffoldCommand : ClientCommand( literal("add", "+") { literal("shulker_box") { execute("Add all shulker box types to blacklist") { - Scaffold.blockSelectionBlacklist.editValue { blacklist -> allShulkerBoxes.forEach { blacklist.add(it) } } + Scaffold.blockSelectionBlacklist.editValue { blacklist -> shulkerList.forEach { blacklist.add(it.localizedName) } } MessageSendHelper.sendChatMessage("All shulker boxes have been added to blacklist") } } @@ -89,7 +81,7 @@ object ScaffoldCommand : ClientCommand( literal("del", "-") { literal("shulker_box") { execute("Remove all shulker box types from blacklist") { - Scaffold.blockSelectionBlacklist.editValue { blacklist -> allShulkerBoxes.forEach { blacklist.remove(it) } } + Scaffold.blockSelectionBlacklist.editValue { blacklist -> shulkerList.forEach { blacklist.remove(it.localizedName) } } MessageSendHelper.sendChatMessage("All shulker boxes have been removed from blacklist") } } From 15f0fb078717e40480a5eb357eea6be7b5b8858c Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 25 Jan 2023 20:49:48 +0100 Subject: [PATCH 40/40] Revert unneeded code --- src/main/kotlin/com/lambda/client/util/world/Interact.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index cddd9c15a..1b09e15ed 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -271,7 +271,7 @@ private suspend fun SafeClientEvent.doPlace( } /** - * Place block with optional desync / ghost block + * Placing block without desync */ fun SafeClientEvent.placeBlock( placeInfo: PlaceInfo, @@ -290,5 +290,5 @@ fun SafeClientEvent.placeBlock( world.playSound(player, placeInfo.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) } -fun PlaceInfo.toPlacePacket(hand: EnumHand) = - CPacketPlayerTryUseItemOnBlock(this.pos, this.side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file +private fun PlaceInfo.toPlacePacket(hand: EnumHand) = + CPacketPlayerTryUseItemOnBlock(pos, side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file