Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(AntiBot): Armor Material #5659

Open
wants to merge 6 commits into
base: nextgen
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import net.ccbluex.liquidbounce.utils.math.sq
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ArmorItem
import net.minecraft.item.Item
import net.minecraft.item.equipment.ArmorMaterial
import net.minecraft.item.equipment.ArmorMaterials
import net.minecraft.item.equipment.EquipmentType
import net.minecraft.network.packet.s2c.play.EntitiesDestroyS2CPacket
Expand Down Expand Up @@ -74,37 +73,25 @@ object CustomAntiBotMode : Choice("Custom"), ModuleAntiBot.IAntiBotMode {
val minimum by int("Minimum", 20, 0..120, "ticks")
}

private object Armor : ToggleableConfigurable(ModuleAntiBot, "Armor", false) {

@Suppress("unused")
private enum class ArmorMaterialChoice(
override val choiceName: String,
val material: ArmorMaterial,
) : NamedChoice {
LEATHER("Leather", ArmorMaterials.LEATHER),
GOLD("Gold", ArmorMaterials.GOLD),
CHAIN("Chain", ArmorMaterials.CHAIN),
IRON("Iron", ArmorMaterials.IRON),
DIAMOND("Diamond", ArmorMaterials.DIAMOND),
NETHERITE("Netherite", ArmorMaterials.NETHERITE)
}
private object Armor : ToggleableConfigurable(ModuleAntiBot, "ArmorMaterial", false) {

private class ArmorConfigurable(
name: String, val equipmentType: EquipmentType
) : ToggleableConfigurable(this, name, false) {

val mode by enumChoice("Mode", Filter.BLACKLIST)

// TODO: replace with multiple choice
val materialChoice by enumChoice("Material", ArmorMaterialChoice.LEATHER)
private val materialValues = mapOf(
null to boolean("Nothing", true),
ArmorMaterials.LEATHER to boolean("Leather", true),
ArmorMaterials.GOLD to boolean("Gold", true),
ArmorMaterials.CHAIN to boolean("Chain", true),
ArmorMaterials.IRON to boolean("Iron", true),
ArmorMaterials.DIAMOND to boolean("Diamond", true),
ArmorMaterials.NETHERITE to boolean("Netherite", true)
)

fun isValid(item: Item): Boolean {
with((item as? ArmorItem)?.material() == materialChoice.material) {
return when (mode) {
Filter.WHITELIST -> this
Filter.BLACKLIST -> !this
}
}
// TURTLE_SCUTE or ARMADILLO_SCUTE -> valid
return materialValues[(item as? ArmorItem)?.material()]?.get() ?: true
}
}

Expand Down
Loading