Skip to content

Commit 377a42b

Browse files
committed
copy epic nukers blacklist / whitelist / none setup
1 parent b04d974 commit 377a42b

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.lambda.interaction.managers.breaking.BreakConfig.AnimationMode
2727
import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode
2828
import com.lambda.interaction.managers.breaking.BreakConfig.BreakMode
2929
import com.lambda.interaction.managers.breaking.BreakConfig.SwingMode
30+
import com.lambda.interaction.managers.breaking.BreakConfig.WhitelistMode
3031
import com.lambda.util.NamedEnum
3132
import net.minecraft.registry.Registries
3233
import java.awt.Color
@@ -77,7 +78,9 @@ open class BreakSettings(
7778
override val breaksPerTick by c.setting("${prefix}Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick", visibility = visibility).group(*baseGroup, Group.General).index()
7879

7980
// Block
80-
override val blocks by c.setting("${prefix}Blocks", Registries.BLOCK.toList(), description = "Blocks that are allowed to be broken", visibility = visibility).group(*baseGroup, Group.General).index()
81+
override val whitelistMode by c.setting("${prefix}Whitelist Mode", WhitelistMode.None, "The type of block selection used", visibility = visibility).group(*baseGroup, Group.General).index()
82+
override val whitelist by c.setting("${prefix}Whitelist", mutableSetOf(), Registries.BLOCK.toMutableSet(), "Only these selected blocks are allowed to be broken") { visibility() && whitelistMode == WhitelistMode.Whitelist }.group(*baseGroup, Group.General).index()
83+
override val blacklist by c.setting("${prefix}Blacklist", mutableSetOf(), Registries.BLOCK.toMutableSet(), "These selected blocks are not allowed to be broken") { visibility() && whitelistMode == WhitelistMode.Blacklist }.group(*baseGroup, Group.General).index()
8184
override val avoidFluids by c.setting("${prefix}Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill", visibility = visibility).group(*baseGroup, Group.General).index()
8285
override val avoidSupporting by c.setting("${prefix}Avoid Supporting", true, "Avoids breaking the block supporting the player", visibility = visibility).group(*baseGroup, Group.General).index()
8386
override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { visibility() && avoidFluids }.group(*baseGroup, Group.General).index()

src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.lambda.interaction.construction.simulation.SimDsl
2424
import com.lambda.interaction.construction.simulation.SimInfo
2525
import com.lambda.interaction.construction.simulation.result.results.GenericResult
2626
import com.lambda.interaction.construction.simulation.result.results.PreSimResult
27+
import com.lambda.interaction.managers.breaking.BreakConfig.WhitelistMode
2728
import com.lambda.util.player.gamemode
2829
import com.lambda.util.world.WorldUtils.isLoaded
2930
import net.minecraft.block.OperatorBlock
@@ -48,9 +49,14 @@ object BasicChecker : Results<PreSimResult> {
4849
}
4950

5051
// block should be ignored
51-
if (this@hasBasicRequirements is BreakSimInfo && state.block !in breakConfig.blocks) {
52-
result(GenericResult.Ignored(pos))
53-
return false
52+
if (this@hasBasicRequirements is BreakSimInfo) {
53+
val mode = breakConfig.whitelistMode
54+
if ((mode == WhitelistMode.Whitelist && state.block !in breakConfig.whitelist) ||
55+
(mode == WhitelistMode.Blacklist && state.block in breakConfig.blacklist)
56+
) {
57+
result(GenericResult.Ignored(pos))
58+
return false
59+
}
5460
}
5561

5662
// the player is in the wrong game mode to alter the block state

src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ interface BreakConfig : ActionConfig, ISettingGroup {
5353
val avoidFluids: Boolean
5454
val fillFluids: Boolean
5555
val avoidSupporting: Boolean
56-
val blocks: Collection<Block>
56+
val whitelistMode: WhitelistMode
57+
val whitelist: Collection<Block>
58+
val blacklist: Collection<Block>
5759

5860
val efficientOnly: Boolean
5961
val suitableToolsOnly: Boolean
@@ -134,4 +136,13 @@ interface BreakConfig : ActionConfig, ISettingGroup {
134136
OutIn("Out In", "Renders a growing and shrinking animation"),
135137
InOut("In Out", "Renders a shrinking and growing animation")
136138
}
139+
140+
enum class WhitelistMode(
141+
override val displayName: String,
142+
override val description: String
143+
) : NamedEnum, Describable {
144+
Whitelist("Whitelist", "Only break blocks in the whitelist"),
145+
Blacklist("Blacklist", "Only break blocks not in the blacklist"),
146+
None("None", "Breaks all blocks")
147+
}
137148
}

0 commit comments

Comments
 (0)