Skip to content

Commit cd191db

Browse files
committed
Scaffold: Whitelist/Blacklist/Any block selection modes
1 parent 31b0487 commit cd191db

File tree

2 files changed

+169
-8
lines changed

2 files changed

+169
-8
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.lambda.client.command.commands
2+
3+
import com.lambda.client.command.ClientCommand
4+
import com.lambda.client.module.modules.player.Scaffold
5+
import com.lambda.client.util.text.MessageSendHelper
6+
import com.lambda.client.util.text.formatValue
7+
import net.minecraft.init.Blocks
8+
9+
object ScaffoldCommand : ClientCommand(
10+
name = "scaffold",
11+
description = "Manage scaffold whitelist/blacklist"
12+
) {
13+
private val allShulkerBoxes = listOf(Blocks.WHITE_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX,
14+
Blocks.MAGENTA_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX,
15+
Blocks.LIME_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.SILVER_SHULKER_BOX,
16+
Blocks.CYAN_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX,
17+
Blocks.GREEN_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.BLACK_SHULKER_BOX)
18+
.map { it.registryName.toString() }
19+
.toList()
20+
21+
init {
22+
literal("whitelist", "wl") {
23+
literal("add", "+") {
24+
literal("shulker_box") {
25+
execute("Add all shulker box types to whitelist") {
26+
Scaffold.blockSelectionWhitelist.editValue { whitelist -> allShulkerBoxes.forEach { whitelist.add(it) } }
27+
MessageSendHelper.sendChatMessage("All shulker boxes have been added to whitelist")
28+
}
29+
}
30+
block("block") { blockArg ->
31+
execute("Add a block to Scaffold whitelist") {
32+
val blockName = blockArg.value.registryName.toString()
33+
if (Scaffold.blockSelectionWhitelist.contains(blockName)) {
34+
MessageSendHelper.sendErrorMessage("${formatValue(blockName)} is already added to scaffold whitelist")
35+
} else {
36+
Scaffold.blockSelectionWhitelist.editValue { it.add(blockName) }
37+
MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been added to scaffold whitelist")
38+
}
39+
}
40+
}
41+
}
42+
literal("del", "-") {
43+
literal("shulker_box") {
44+
execute("Remove all shulker box types from whitelist") {
45+
Scaffold.blockSelectionWhitelist.editValue { whitelist -> allShulkerBoxes.forEach { whitelist.remove(it) } }
46+
MessageSendHelper.sendChatMessage("All shulker boxes have been removed from whitelist")
47+
}
48+
}
49+
block("block") { blockArg ->
50+
execute("Removes a block from the Scaffold whitelist") {
51+
val blockName = blockArg.value.registryName.toString()
52+
Scaffold.blockSelectionWhitelist.editValue { it.remove(blockName) }
53+
MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been removed from scaffold whitelist")
54+
}
55+
}
56+
}
57+
literal("clear", "c") {
58+
execute {
59+
Scaffold.blockSelectionWhitelist.editValue { it.clear() }
60+
MessageSendHelper.sendChatMessage("Whitelist has been cleared")
61+
}
62+
}
63+
literal("list") {
64+
execute {
65+
MessageSendHelper.sendChatMessage("Blocks: ${Scaffold.blockSelectionWhitelist.joinToString()}")
66+
}
67+
}
68+
}
69+
literal("blacklist", "bl") {
70+
literal("add", "+") {
71+
literal("shulker_box") {
72+
execute("Add all shulker box types to blacklist") {
73+
Scaffold.blockSelectionBlacklist.editValue { blacklist -> allShulkerBoxes.forEach { blacklist.add(it) } }
74+
MessageSendHelper.sendChatMessage("All shulker boxes have been added to blacklist")
75+
}
76+
}
77+
block("block") { blockArg ->
78+
execute("Add a block to Scaffold blacklist") {
79+
val blockName = blockArg.value.registryName.toString()
80+
if (Scaffold.blockSelectionBlacklist.contains(blockName)) {
81+
MessageSendHelper.sendErrorMessage("${formatValue(blockName)} is already added to scaffold blacklist")
82+
} else {
83+
Scaffold.blockSelectionBlacklist.editValue { it.add(blockName) }
84+
MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been added to scaffold blacklist")
85+
}
86+
}
87+
}
88+
}
89+
literal("del", "-") {
90+
literal("shulker_box") {
91+
execute("Remove all shulker box types from blacklist") {
92+
Scaffold.blockSelectionBlacklist.editValue { blacklist -> allShulkerBoxes.forEach { blacklist.remove(it) } }
93+
MessageSendHelper.sendChatMessage("All shulker boxes have been removed from blacklist")
94+
}
95+
}
96+
block("block") { blockArg ->
97+
execute("Removes a block from the Scaffold blacklist") {
98+
val blockName = blockArg.value.registryName.toString()
99+
Scaffold.blockSelectionBlacklist.editValue { it.remove(blockName) }
100+
MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been removed from scaffold blacklist")
101+
}
102+
}
103+
}
104+
literal("clear", "c") {
105+
execute {
106+
Scaffold.blockSelectionBlacklist.editValue { it.clear() }
107+
MessageSendHelper.sendChatMessage("Blacklist has been cleared")
108+
}
109+
}
110+
literal("list") {
111+
execute {
112+
MessageSendHelper.sendChatMessage("Blocks: ${Scaffold.blockSelectionBlacklist.joinToString()}")
113+
}
114+
}
115+
}
116+
}
117+
}

src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lambda.client.module.modules.player
22

3+
import com.lambda.client.commons.interfaces.DisplayEnum
34
import com.lambda.client.event.Phase
45
import com.lambda.client.event.SafeClientEvent
56
import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent
@@ -9,13 +10,11 @@ import com.lambda.client.manager.managers.HotbarManager.spoofHotbar
910
import com.lambda.client.mixin.extension.syncCurrentPlayItem
1011
import com.lambda.client.module.Category
1112
import com.lambda.client.module.Module
13+
import com.lambda.client.setting.settings.impl.collection.CollectionSetting
1214
import com.lambda.client.util.EntityUtils.prevPosVector
1315
import com.lambda.client.util.TickTimer
1416
import com.lambda.client.util.TimeUnit
15-
import com.lambda.client.util.items.HotbarSlot
16-
import com.lambda.client.util.items.firstItem
17-
import com.lambda.client.util.items.hotbarSlots
18-
import com.lambda.client.util.items.swapToSlot
17+
import com.lambda.client.util.items.*
1918
import com.lambda.client.util.math.RotationUtils.getRotationTo
2019
import com.lambda.client.util.math.VectorUtils.toBlockPos
2120
import com.lambda.client.util.threads.safeListener
@@ -36,6 +35,7 @@ object Scaffold : Module(
3635
category = Category.PLAYER,
3736
modulePriority = 500
3837
) {
38+
private val blockSelectionMode by setting("Block Selection Mode", ScaffoldBlockSelectionMode.ANY)
3939
private val tower by setting("Tower", true)
4040
private val spoofHotbar by setting("Spoof Hotbar", true)
4141
val safeWalk by setting("Safe Walk", true)
@@ -45,12 +45,27 @@ object Scaffold : Module(
4545
private val maxRange by setting("Max Range", 1, 0..3, 1)
4646
private val noGhost by setting("No Ghost Blocks", false)
4747

48+
val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false }))
49+
val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", linkedSetOf("minecraft:white_shulker_box", "minecraft:orange_shulker_box",
50+
"minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box",
51+
"minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box",
52+
"minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box",
53+
"minecraft:red_shulker_box", "minecraft:black_shulker_box", "minecraft:crafting_table", "minecraft:dropper",
54+
"minecraft:hopper", "minecraft:dispenser", "minecraft:ender_chest", "minecraft:furnace"),
55+
{ false }))
56+
4857
private val placeTimer = TickTimer(TimeUnit.TICKS)
4958

5059
private var lastHitVec: Vec3d? = null
5160
private var placeInfo: PlaceInfo? = null
5261
private var inactiveTicks = 69
5362

63+
private enum class ScaffoldBlockSelectionMode(override val displayName: String): DisplayEnum {
64+
ANY("Any"),
65+
WHITELIST("Whitelist"),
66+
BLACKLIST("Blacklist")
67+
}
68+
5469
override fun isActive(): Boolean {
5570
return isEnabled && inactiveTicks <= 5
5671
}
@@ -133,9 +148,28 @@ object Scaffold : Module(
133148
(value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange)
134149

135150
private fun SafeClientEvent.swap(): Boolean {
136-
if (player.heldItemMainhand.item is ItemBlock || player.heldItemOffhand.item is ItemBlock) {
137-
inactiveTicks = 0;
138-
return true;
151+
// todo: refactor this into a function?
152+
when (blockSelectionMode) {
153+
ScaffoldBlockSelectionMode.ANY -> {
154+
if (player.heldItemMainhand.item is ItemBlock || player.heldItemOffhand.item is ItemBlock) {
155+
inactiveTicks = 0;
156+
return true;
157+
}
158+
}
159+
ScaffoldBlockSelectionMode.BLACKLIST -> {
160+
if ((player.heldItemMainhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemMainhand.item.block.registryName.toString()))
161+
|| player.heldItemOffhand.item is ItemBlock && !blockSelectionBlacklist.contains(player.heldItemOffhand.item.block.registryName.toString())) {
162+
inactiveTicks = 0
163+
return true
164+
}
165+
}
166+
ScaffoldBlockSelectionMode.WHITELIST -> {
167+
if ((player.heldItemMainhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemMainhand.item.block.registryName.toString()))
168+
|| player.heldItemOffhand.item is ItemBlock && blockSelectionWhitelist.contains(player.heldItemOffhand.item.block.registryName.toString())) {
169+
inactiveTicks = 0
170+
return true
171+
}
172+
}
139173
}
140174
getBlockSlot()?.let { slot ->
141175
if (spoofHotbar) spoofHotbar(slot)
@@ -148,6 +182,16 @@ object Scaffold : Module(
148182

149183
private fun SafeClientEvent.getBlockSlot(): HotbarSlot? {
150184
playerController.syncCurrentPlayItem()
151-
return player.hotbarSlots.firstItem<ItemBlock, HotbarSlot>()
185+
return player.hotbarSlots.firstItem<ItemBlock, HotbarSlot> {
186+
when (blockSelectionMode) {
187+
ScaffoldBlockSelectionMode.BLACKLIST -> {
188+
return@firstItem !blockSelectionBlacklist.contains(it.item.block.registryName.toString())
189+
}
190+
ScaffoldBlockSelectionMode.WHITELIST -> {
191+
return@firstItem blockSelectionWhitelist.contains(it.item.block.registryName.toString())
192+
}
193+
else -> return@firstItem true
194+
}
195+
}
152196
}
153197
}

0 commit comments

Comments
 (0)