forked from CCBlueX/LiquidBounce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
251 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
...in/kotlin/net/ccbluex/liquidbounce/features/command/commands/client/CommandAutoDisable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2015 - 2023 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.features.command.commands.client | ||
|
||
import net.ccbluex.liquidbounce.features.command.Command | ||
import net.ccbluex.liquidbounce.features.command.CommandException | ||
import net.ccbluex.liquidbounce.features.command.builder.CommandBuilder | ||
import net.ccbluex.liquidbounce.features.command.builder.ParameterBuilder | ||
import net.ccbluex.liquidbounce.features.module.ModuleManager | ||
import net.ccbluex.liquidbounce.features.module.modules.world.ModuleAutoDisable | ||
import net.ccbluex.liquidbounce.utils.client.* | ||
import net.minecraft.util.Formatting | ||
import kotlin.math.ceil | ||
import kotlin.math.roundToInt | ||
|
||
object CommandAutoDisable { | ||
|
||
fun createCommand(): Command { | ||
return CommandBuilder | ||
.begin("AutoDisable") | ||
.hub() | ||
.subcommand( | ||
CommandBuilder | ||
.begin("add") | ||
.parameter( | ||
ParameterBuilder | ||
.begin<String>("name") | ||
.verifiedBy(ParameterBuilder.STRING_VALIDATOR) | ||
.autocompletedWith(ModuleManager::autoComplete) | ||
.required() | ||
.build() | ||
) | ||
.handler { command, args -> | ||
val name = args[0] as String | ||
val module = ModuleManager.find { it.name.equals(name, true) } | ||
?: throw CommandException(command.result("moduleNotFound", name)) | ||
|
||
if (!ModuleAutoDisable.listOfModules.add(module)) { | ||
throw CommandException(command.result("ModuleIsPresent", name)) | ||
} | ||
|
||
chat(regular(command.result("moduleAdded", variable(module.name)))) | ||
} | ||
.build() | ||
) | ||
.subcommand( | ||
CommandBuilder | ||
.begin("remove") | ||
.parameter( | ||
ParameterBuilder | ||
.begin<String>("name") | ||
.verifiedBy(ParameterBuilder.STRING_VALIDATOR) | ||
.autocompletedWith { ModuleManager.autoComplete(it) { mod -> mod.bind != -1 } } | ||
.required() | ||
.build() | ||
) | ||
.handler { command, args -> | ||
val name = args[0] as String | ||
val module = ModuleManager.find { it.name.equals(name, true) } | ||
?: throw CommandException(command.result("moduleNotFound", name)) | ||
|
||
if (!ModuleAutoDisable.listOfModules.remove(module)) { | ||
throw CommandException(command.result("ModuleIsMissing", name)) | ||
} | ||
|
||
chat( | ||
regular( | ||
command.result( | ||
"moduleRemoved", | ||
variable(module.name) | ||
) | ||
) | ||
) | ||
} | ||
.build() | ||
) | ||
.subcommand( | ||
CommandBuilder | ||
.begin("list") | ||
.parameter( | ||
ParameterBuilder | ||
.begin<Int>("page") | ||
.verifiedBy(ParameterBuilder.INTEGER_VALIDATOR) | ||
.optional() | ||
.build() | ||
) | ||
.handler { command, args -> | ||
val page = if (args.size > 1) { | ||
args[0] as Int | ||
} else { | ||
1 | ||
}.coerceAtLeast(1) | ||
|
||
val modules = ModuleAutoDisable.listOfModules.sortedBy { it.name } | ||
|
||
if (modules.isEmpty()) { | ||
throw CommandException(command.result("noBindings")) | ||
} | ||
|
||
// Max page | ||
val maxPage = ceil(modules.size / 8.0).roundToInt() | ||
if (page > maxPage) { | ||
throw CommandException(command.result("pageNumberTooLarge", maxPage)) | ||
} | ||
|
||
// Print out bindings | ||
chat(command.result("bindings").styled { it.withColor(Formatting.RED).withBold(true) }) | ||
chat(regular(command.result("page", variable("$page / $maxPage")))) | ||
|
||
val iterPage = 8 * page | ||
for (module in modules.subList(iterPage - 8, iterPage.coerceAtMost(modules.size))) { | ||
chat( | ||
"> ".asText() | ||
.styled { it.withColor(Formatting.GOLD) } | ||
.append(module.name + " (") | ||
.styled { it.withColor(Formatting.GRAY) } | ||
.append( | ||
keyName(module.bind).asText() | ||
.styled { it.withColor(Formatting.DARK_GRAY).withBold(true) } | ||
) | ||
.append(")") | ||
.styled { it.withColor(Formatting.GRAY) } | ||
) | ||
} | ||
} | ||
.build() | ||
) | ||
.subcommand( | ||
CommandBuilder | ||
.begin("clear") | ||
.handler { command, _ -> | ||
ModuleAutoDisable.listOfModules.let { list -> | ||
list.forEach { | ||
list.remove(it) | ||
} | ||
} | ||
chat(command.result("modulesCleared")) | ||
} | ||
.build() | ||
) | ||
.build() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleAutoDisable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2015 - 2023 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.features.module.modules.world | ||
|
||
import net.ccbluex.liquidbounce.event.* | ||
import net.ccbluex.liquidbounce.features.module.Category | ||
import net.ccbluex.liquidbounce.features.module.Module | ||
import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleKillAura | ||
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleFly | ||
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleNoClip | ||
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleSpeed | ||
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleBlink | ||
import net.ccbluex.liquidbounce.utils.aiming.RotationManager | ||
import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable | ||
import net.ccbluex.liquidbounce.utils.block.* | ||
import net.ccbluex.liquidbounce.utils.client.notification | ||
import net.ccbluex.liquidbounce.utils.entity.eyes | ||
import net.ccbluex.liquidbounce.utils.entity.getNearestPoint | ||
import net.minecraft.block.* | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen | ||
import net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket | ||
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket | ||
import net.minecraft.util.Hand | ||
import net.minecraft.util.hit.HitResult | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.util.math.Box | ||
import net.minecraft.util.math.Vec3d | ||
import net.minecraft.world.RaycastContext | ||
|
||
/** | ||
* AutoFarm module | ||
* | ||
* Automatically farms stuff for you. | ||
*/ | ||
object ModuleAutoDisable : Module("AutoDisable", Category.WORLD) { | ||
val listOfModules = arrayListOf<Module>(ModuleFly, ModuleSpeed, ModuleNoClip, ModuleKillAura) | ||
val onFlag by boolean("OnFlag", false) | ||
val onDeath by boolean("OnDeath", false) | ||
|
||
val worldChangesHandler = handler<PacketEvent> { | ||
if (it.packet is PlayerPositionLookS2CPacket && onFlag) { | ||
autoDisabled("flag") | ||
} | ||
} | ||
|
||
val deathHandler = handler<DeathEvent> { | ||
if (onDeath) | ||
autoDisabled("your death") | ||
} | ||
|
||
fun autoDisabled(reason: String) { | ||
listOfModules.forEach { | ||
it.enabled = false | ||
} | ||
notification("Notifier", "Disabled modules due to $reason", NotificationEvent.Severity.INFO) | ||
} | ||
} |