[cleanup] Module base (#1818)

This commit is contained in:
Xiaro 2021-01-07 14:10:55 -05:00 committed by GitHub
parent f49ca78ded
commit cbaee402d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
79 changed files with 1297 additions and 1248 deletions

View File

@ -1,10 +1,7 @@
package me.zeroeightsix.kami;
import me.zeroeightsix.kami.event.ForgeEventProcessor;
import me.zeroeightsix.kami.event.KamiEventBus;
import me.zeroeightsix.kami.gui.mc.KamiGuiUpdateNotification;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.ModuleManager;
import me.zeroeightsix.kami.util.ConfigUtils;
import me.zeroeightsix.kami.util.threads.BackgroundScope;
import net.minecraftforge.common.MinecraftForge;
@ -68,12 +65,6 @@ public class KamiMod {
ConfigUtils.INSTANCE.loadAll();
// After settings loaded, we want to let the enabled modules know they've been enabled (since the setting is done through reflection)
for (Module module : ModuleManager.INSTANCE.getModules()) {
if (module.getAlwaysListening()) KamiEventBus.INSTANCE.subscribe(module);
if (module.isEnabled()) module.enable();
}
BackgroundScope.INSTANCE.start();
LOG.info(NAME + " Mod initialized!");

View File

@ -13,7 +13,7 @@ import me.zeroeightsix.kami.util.threads.defaultScope
import net.minecraft.client.gui.GuiChat
import org.kamiblue.command.AbstractArg
import org.kamiblue.command.AutoComplete
import org.kamiblue.commons.extension.stream
import org.kamiblue.command.GreedyStringArg
import org.lwjgl.input.Keyboard
import kotlin.math.min
@ -89,7 +89,7 @@ class KamiGuiChat(
private suspend fun autoComplete() {
val string = inputField.text.removePrefix(CommandManager.prefix)
val parsedArgs = runCatching { CommandManager.parseArguments(string) }.getOrNull() ?: return
var argCount = parsedArgs.size
var argCount = parsedArgs.size - 1
val inputName = parsedArgs[0]
// If the string ends with only one space (typing the next arg), adds 1 to the arg count
@ -98,20 +98,31 @@ class KamiGuiChat(
}
// Run commandAutoComplete() and return if there are only one arg
if (argCount == 1) {
if (argCount == 0) {
commandAutoComplete(inputName)
return
}
val ignoredStringArg = getArgTypeForAtIndex(parsedArgs, argCount, true)
val withStringArg = getArgTypeForAtIndex(parsedArgs, argCount, false)
// Get available arg types for current arg index
val args = getArgTypeForAtIndex(parsedArgs, argCount - 1) ?: return
val args = ignoredStringArg
?: withStringArg
?: return
val both = if (ignoredStringArg != null && withStringArg != null) {
ignoredStringArg + withStringArg
} else {
args
}
// Get the current input string
val inputString = parsedArgs.getOrNull(argCount - 1)
val inputString = parsedArgs.getOrNull(argCount)
if (inputString.isNullOrEmpty()) {
// If we haven't input anything yet, prints list of available arg types
if (args.isNotEmpty()) cachePredict = args.toSet().joinToString("/")
if (args.isNotEmpty()) cachePredict = both.distinct().joinToString("/")
return
}
@ -131,22 +142,26 @@ class KamiGuiChat(
private fun commandAutoComplete(inputName: String) {
// Since we are doing multiple operation in a chain
// It would worth the payoff of using Stream
CommandManager.getCommands().stream()
.flatMap { it.allNames.stream() }
CommandManager.getCommands()
.flatMap { it.allNames.toList() }
.filter { it.length >= inputName.length && it.startsWith(inputName) }
.sorted()
.findFirst()
.orElse(null)
.minOrNull()
?.let {
cachePredict = it.substring(min(inputName.length, it.length))
canAutoComplete = true
}
}
private suspend fun getArgTypeForAtIndex(parsedArgs: Array<String>, argIndex: Int): List<AbstractArg<*>>? {
private suspend fun getArgTypeForAtIndex(parsedArgs: Array<String>, argIndex: Int, ignoreStringArg: Boolean): List<AbstractArg<*>>? {
// Get the command for input name, map the arg trees to the count of match args
val command = CommandManager.getCommandOrNull(parsedArgs[0]) ?: return null
val treeMatchedCounts = command.finalArgs.map { it.countArgs(parsedArgs) to it }
val treeMatchedCounts = command.finalArgs.mapNotNull {
if (ignoreStringArg && it.getArgTree().getOrNull(argIndex) is GreedyStringArg) {
null
} else {
it.countArgs(parsedArgs) to it
}
}
// Get the max matched number of args, filter all trees that has less matched args
// And map to the current arg in the tree if exists

View File

@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinElytraSound {
@Inject(method = "update", at = @At("HEAD"), cancellable = true)
public void update(CallbackInfo ci) {
if (ElytraFlight.INSTANCE.isEnabled() && !ElytraFlight.INSTANCE.getElytraSounds().getValue()) {
if (ElytraFlight.INSTANCE.isEnabled() && !ElytraFlight.INSTANCE.getElytraSounds()) {
ci.cancel();
}
}

View File

@ -35,7 +35,7 @@ public class MixinEntity {
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isSneaking()Z", ordinal = 0))
public boolean isSneaking(Entity entity) {
return SafeWalk.INSTANCE.shouldSafewalk()
|| (Scaffold.INSTANCE.isEnabled() && Scaffold.INSTANCE.getSafeWalk().getValue())
|| (Scaffold.INSTANCE.isEnabled() && Scaffold.INSTANCE.getSafeWalk())
|| entity.isSneaking();
}

View File

@ -17,7 +17,7 @@ public class MixinBlockSoulSand {
@Inject(method = "onEntityCollision", at = @At("HEAD"), cancellable = true)
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn, CallbackInfo info) {
// If noslowdown is on, just don't do anything else in this method (slow the player)
if (NoSlowDown.INSTANCE.isEnabled() && NoSlowDown.INSTANCE.getSoulSand().getValue()) info.cancel();
if (NoSlowDown.INSTANCE.isEnabled() && NoSlowDown.INSTANCE.getSoulSand()) info.cancel();
}
}

View File

@ -17,7 +17,7 @@ public class MixinBlockWeb {
@Inject(method = "onEntityCollision", at = @At("HEAD"), cancellable = true)
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn, CallbackInfo info) {
// If noslowdown is on, just don't do anything else in this method (slow the player)
if (NoSlowDown.INSTANCE.isEnabled() && NoSlowDown.INSTANCE.getCobweb().getValue()) info.cancel();
if (NoSlowDown.INSTANCE.isEnabled() && NoSlowDown.INSTANCE.getCobweb()) info.cancel();
}
}

View File

@ -8,6 +8,7 @@ import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.setting.settings.AbstractSetting
import me.zeroeightsix.kami.util.Bind
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.runSafe
import net.minecraft.client.Minecraft
import org.kamiblue.commons.interfaces.Alias
import org.kamiblue.commons.interfaces.DisplayEnum
@ -30,7 +31,7 @@ open class Module(
val settingList: List<AbstractSetting<*>> get() = fullSettingList.filter { it != bind && it != enabled && it != visible && it != default }
val bind = setting("Bind", Bind(), { !alwaysEnabled })
private val enabled = setting("Enabled", enabledByDefault || alwaysEnabled, { false })
private val enabled = setting("Enabled", false, { false })
private val visible = setting("Visible", showOnArray)
private val default = setting("Default", false, { settingList.isNotEmpty() })
/* End of settings */
@ -42,55 +43,31 @@ open class Module(
val isVisible: Boolean get() = visible.value
/* End of properties */
fun resetSettings() {
for (setting in settingList) {
setting.resetValue()
}
internal fun postInit() {
enabled.value = enabledByDefault || alwaysEnabled
if (alwaysListening) KamiEventBus.subscribe(this)
}
fun toggle() {
setEnabled(!isEnabled)
}
fun setEnabled(state: Boolean) {
if (isEnabled != state) if (state) enable() else disable()
enabled.value = !enabled.value
}
fun enable() {
if (!enabled.value) sendToggleMessage()
enabled.value = true
onEnable()
onToggle()
if (!alwaysListening) {
KamiEventBus.subscribe(this)
}
}
fun disable() {
if (alwaysEnabled) return
if (enabled.value) sendToggleMessage()
enabled.value = false
onDisable()
onToggle()
if (!alwaysListening) {
KamiEventBus.unsubscribe(this)
}
}
private fun sendToggleMessage() {
if (this !is ClickGUI && CommandConfig.toggleMessages.value) {
MessageSendHelper.sendChatMessage(name + if (enabled.value) " &cdisabled" else " &aenabled")
runSafe {
if (this@Module !is ClickGUI && CommandConfig.toggleMessages.value) {
MessageSendHelper.sendChatMessage(name + if (enabled.value) " &cdisabled" else " &aenabled")
}
}
}
open fun destroy() {
// Cleanup method in case this module wants to do something when the client closes down
}
open fun isActive(): Boolean {
return isEnabled || alwaysListening
}
@ -99,19 +76,45 @@ open class Module(
return ""
}
protected open fun onEnable() {
// override to run code when the module is enabled
protected fun onEnable(block: (Boolean) -> Unit) {
enabled.valueListeners.add { _, input ->
if (input) {
block(input)
}
}
}
protected open fun onDisable() {
// override to run code when the module is disabled
protected fun onDisable(block: (Boolean) -> Unit) {
enabled.valueListeners.add { _, input ->
if (!input) {
block(input)
}
}
}
protected open fun onToggle() {
// override to run code when the module is enabled or disabled
protected fun onToggle(block: (Boolean) -> Unit) {
enabled.valueListeners.add { _, input ->
block(input)
}
}
init {
enabled.consumers.add { prev, input ->
val enabled = alwaysEnabled || input
if (prev != input && !alwaysEnabled) {
sendToggleMessage()
}
if (enabled || alwaysListening) {
KamiEventBus.subscribe(this)
} else {
KamiEventBus.unsubscribe(this)
}
enabled
}
default.valueListeners.add { _, it ->
if (it) {
settingList.forEach { it.resetValue() }

View File

@ -32,7 +32,7 @@ object ModuleManager : AsyncLoader<List<Class<out Module>>> {
val stopTimer = StopTimer()
for (clazz in input) {
moduleSet.add(ClassUtils.getInstance(clazz))
moduleSet.add(ClassUtils.getInstance(clazz).apply { postInit() })
}
val time = stopTimer.stop()

View File

@ -76,6 +76,10 @@ object AntiSpam : Module(
)
init {
onDisable {
messageHistory.clear()
}
listener<ClientChatReceivedEvent> { event ->
if (mc.player == null) return@listener
@ -104,10 +108,6 @@ object AntiSpam : Module(
}
}
override fun onDisable() {
messageHistory.clear()
}
private fun sanitize(toClean: String, matcher: String, replacement: String): String {
return if (!aggressiveFiltering.value) {
toClean.replace("\\b$matcher|$matcher\\b".toRegex(), replacement) // only check for start or end of a word

View File

@ -8,8 +8,8 @@ import me.zeroeightsix.kami.util.TickTimer
import me.zeroeightsix.kami.util.TimeUnit
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.text.MessageSendHelper.sendServerMessage
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.network.play.server.SPacketUpdateHealth
import org.kamiblue.event.listener.listener
import java.io.File
object AutoExcuse : Module(
@ -18,7 +18,7 @@ object AutoExcuse : Module(
category = Category.CHAT,
modulePriority = 500
) {
private val mode = setting("Mode", Mode.INTERNAL)
private val mode by setting("Mode", Mode.INTERNAL)
private enum class Mode {
INTERNAL, EXTERNAL
@ -64,33 +64,33 @@ object AutoExcuse : Module(
private val timer = TickTimer(TimeUnit.SECONDS)
init {
listener<PacketEvent.Receive> {
if (mc.player == null || loadedExcuses.isEmpty() || it.packet !is SPacketUpdateHealth) return@listener
safeListener<PacketEvent.Receive> {
if (loadedExcuses.isEmpty() || it.packet !is SPacketUpdateHealth) return@safeListener
if (it.packet.health <= 0f && timer.tick(3L)) {
sendServerMessage(getExcuse())
}
}
}
override fun onEnable() {
loadedExcuses = if (mode.value == Mode.EXTERNAL) {
if (file.exists()) {
val cacheList = ArrayList<String>()
try {
file.forEachLine { if (it.isNotBlank()) cacheList.add(it.trim()) }
MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!")
} catch (e: Exception) {
KamiMod.LOG.error("Failed loading excuses", e)
onEnable {
loadedExcuses = if (mode == Mode.EXTERNAL) {
if (file.exists()) {
val cacheList = ArrayList<String>()
try {
file.forEachLine { if (it.isNotBlank()) cacheList.add(it.trim()) }
MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!")
} catch (e: Exception) {
KamiMod.LOG.error("Failed loading excuses", e)
}
cacheList.toTypedArray()
} else {
file.createNewFile()
MessageSendHelper.sendErrorMessage("$chatName Excuses file is empty!" +
", please add them in the &7excuses.txt&f under the &7.minecraft/kamiblue&f directory.")
defaultExcuses
}
cacheList.toTypedArray()
} else {
file.createNewFile()
MessageSendHelper.sendErrorMessage("$chatName Excuses file is empty!" +
", please add them in the &7excuses.txt&f under the &7.minecraft/kamiblue&f directory.")
defaultExcuses
}
} else {
defaultExcuses
}
}

View File

@ -27,10 +27,10 @@ object ChatEncryption : Module(
category = Category.CHAT,
modulePriority = -69420
) {
private val commands = setting("Commands", false)
private val self = setting("DecryptOwn", true)
private val keySetting = setting("KeySetting", "DefaultKey")
val delimiter = setting("Delimiter", "%", consumer = { prev: String, value: String ->
private val commands by setting("Commands", false)
private val self by setting("DecryptOwn", true)
private var keySetting by setting("KeySetting", "DefaultKey")
val delimiter by setting("Delimiter", "%", consumer = { prev: String, value: String ->
if (value.length == 1 && !chars.contains(value.first())) value else prev
})
@ -63,7 +63,7 @@ object ChatEncryption : Module(
private val modifier = newMessageModifier(
filter = {
(commands.value || MessageDetection.Command.ANY_EXCEPT_DELIMITER detectNot it.packet.message)
(commands || MessageDetection.Command.ANY_EXCEPT_DELIMITER detectNot it.packet.message)
},
modifier = {
it.encrypt() ?: it.packet.message
@ -72,21 +72,23 @@ object ChatEncryption : Module(
private var previousMessage = ""
override fun onEnable() {
getOrGenKey()
modifier.enable()
}
init {
onEnable {
getOrGenKey()
modifier.enable()
}
override fun onDisable() {
modifier.disable()
onDisable {
modifier.disable()
}
}
private fun getOrGenKey(): String {
var key = keySetting.value
var key = keySetting
if (key == "DefaultKey") {
key = randomChars()
keySetting.value = key
keySetting = key
MessageSendHelper.sendChatMessage("$chatName Your encryption key was set to ${formatValue(key)}, and copied to your clipboard.")
@ -113,7 +115,7 @@ object ChatEncryption : Module(
if (!fullMessage.contains(personFrowning)) return@safeListener
val playerName = MessageDetection.Message.ANY.playerName(fullMessage) ?: "Unknown User"
if (!self.value && playerName == player.name) return@safeListener
if (!self && playerName == player.name) return@safeListener
val message = MessageDetection.Message.ANY.removedOrNull(fullMessage) ?: return@safeListener
val splitString = message.split(personFrowning)
@ -144,7 +146,7 @@ object ChatEncryption : Module(
return null
}
val splitString = message.split(delimiter.value)
val splitString = message.split(delimiter)
val encrypted = StringBuilder().run {
for ((index, string) in splitString.withIndex()) {

View File

@ -15,57 +15,57 @@ object ChatFilter : Module(
description = "Filters custom words or phrases from the chat",
category = Category.CHAT
) {
private val filterOwn = setting("FilterOwn", false)
private val filterDMs = setting("FilterDMs", false)
private val hasRunInfo = setting("Info", false, { false })
private val filterOwn by setting("FilterOwn", false)
private val filterDMs by setting("FilterDMs", false)
private var hasRunInfo by setting("Info", false, { false })
private val chatFilter = ArrayList<Regex>()
init {
onEnable {
try {
MessageSendHelper.sendChatMessage("$chatName Trying to find '&7chat_filter.txt&f'")
chatFilter.clear()
File("chat_filter.txt").bufferedReader().forEachLine {
val string = it.trim()
if (string.isEmpty()) return@forEachLine
try {
val regex = "\\b$string\\b".toRegex(RegexOption.IGNORE_CASE)
chatFilter.add(regex)
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed to compile line ${formatValue(it)}, ${e.message}")
}
}
MessageSendHelper.sendChatMessage("$chatName Loaded '&7chat_filter.txt&f'!")
} catch (exception: FileNotFoundException) {
MessageSendHelper.sendErrorMessage("$chatName Couldn't find a file called '&7chat_filter.txt&f' inside your '&7.minecraft&f' folder, disabling")
disable()
} catch (exception: Exception) {
MessageSendHelper.sendErrorMessage(exception.toString())
}
if (!hasRunInfo) {
MessageSendHelper.sendChatMessage("$chatName Tip: this supports &lregex&r if you know how to use those. " +
"This also uses &lword boundaries&r meaning it will match whole words, not part of a word. " +
"Eg if your filter has 'hell' then 'hello' will not be filtered.")
hasRunInfo = true
}
}
listener<ClientChatReceivedEvent> {
if (isDetected(it.message.unformattedText)) it.isCanceled = true
}
}
private fun isDetected(message: String): Boolean {
return if (!filterOwn.value && MessageDetection.Message.SELF detect message
|| !filterDMs.value && MessageDetection.Direct.ANY detect message) {
return if (!filterOwn && MessageDetection.Message.SELF detect message
|| !filterDMs && MessageDetection.Direct.ANY detect message) {
false
} else {
chatFilter.all { it.containsMatchIn(message) }
}
}
override fun onEnable() {
try {
MessageSendHelper.sendChatMessage("$chatName Trying to find '&7chat_filter.txt&f'")
chatFilter.clear()
File("chat_filter.txt").bufferedReader().forEachLine {
val string = it.trim()
if (string.isEmpty()) return@forEachLine
try {
val regex = "\\b$string\\b".toRegex(RegexOption.IGNORE_CASE)
chatFilter.add(regex)
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed to compile line ${formatValue(it)}, ${e.message}")
}
}
MessageSendHelper.sendChatMessage("$chatName Loaded '&7chat_filter.txt&f'!")
} catch (exception: FileNotFoundException) {
MessageSendHelper.sendErrorMessage("$chatName Couldn't find a file called '&7chat_filter.txt&f' inside your '&7.minecraft&f' folder, disabling")
disable()
} catch (exception: Exception) {
MessageSendHelper.sendErrorMessage(exception.toString())
}
if (!hasRunInfo.value) {
MessageSendHelper.sendChatMessage("$chatName Tip: this supports &lregex&r if you know how to use those. " +
"This also uses &lword boundaries&r meaning it will match whole words, not part of a word. " +
"Eg if your filter has 'hell' then 'hello' will not be filtered.")
hasRunInfo.value = true
}
}
}

View File

@ -18,11 +18,11 @@ object CustomChat : Module(
showOnArray = false,
modulePriority = 200
) {
private val textMode = setting("Message", TextMode.JAPANESE)
private val decoMode = setting("Separator", DecoMode.NONE)
private val commands = setting("Commands", false)
private val spammer = setting("Spammer", false)
private val customText = setting("CustomText", "unchanged")
private val textMode by setting("Message", TextMode.JAPANESE)
private val decoMode by setting("Separator", DecoMode.NONE)
private val commands by setting("Commands", false)
private val spammer by setting("Spammer", false)
private val customText by setting("CustomText", "Default")
private enum class DecoMode {
SEPARATOR, CLASSIC, NONE
@ -35,8 +35,8 @@ object CustomChat : Module(
private val timer = TickTimer(TimeUnit.SECONDS)
private val modifier = newMessageModifier(
filter = {
(commands.value || MessageDetection.Command.ANY detectNot it.packet.message)
&& (spammer.value || it.source !is Spammer)
(commands || MessageDetection.Command.ANY detectNot it.packet.message)
&& (spammer || it.source !is Spammer)
},
modifier = {
val message = it.packet.message + getFull()
@ -44,23 +44,25 @@ object CustomChat : Module(
}
)
override fun onEnable() {
modifier.enable()
init {
onEnable {
modifier.enable()
}
onDisable {
modifier.disable()
}
}
override fun onDisable() {
modifier.disable()
}
private fun getText() = when (textMode.value) {
private fun getText() = when (textMode) {
TextMode.NAME -> "ᴋᴀᴍɪ ʙʟᴜᴇ"
TextMode.ON_TOP -> "ᴋᴀᴍɪ ʙʟᴜᴇ ᴏɴ ᴛᴏᴘ"
TextMode.WEBSITE -> ""
TextMode.JAPANESE -> "上にカミブルー"
TextMode.CUSTOM -> customText.value
TextMode.CUSTOM -> customText
}
private fun getFull() = when (decoMode.value) {
private fun getFull() = when (decoMode) {
DecoMode.NONE -> " " + getText()
DecoMode.CLASSIC -> " \u00ab " + getText() + " \u00bb"
DecoMode.SEPARATOR -> " | " + getText()
@ -68,7 +70,7 @@ object CustomChat : Module(
init {
safeListener<TickEvent.ClientTickEvent> {
if (timer.tick(5L) && textMode.value == TextMode.CUSTOM && customText.value.equals("unchanged", ignoreCase = true)) {
if (timer.tick(5L) && textMode == TextMode.CUSTOM && customText.equals("Default", ignoreCase = true)) {
MessageSendHelper.sendWarningMessage("$chatName Warning: In order to use the custom $name, please change the CustomText setting in ClickGUI")
}
}

View File

@ -34,12 +34,14 @@ object FancyChat : Module(
}
)
override fun onEnable() {
modifier.enable()
}
init {
onEnable {
modifier.enable()
}
override fun onDisable() {
modifier.disable()
onDisable {
modifier.disable()
}
}
private fun getText(s: String): String {

View File

@ -16,17 +16,19 @@ object FormatChat : Module(
.replace("#n", "\n")
}
override fun onEnable() {
if (mc.currentServerData == null) {
MessageSendHelper.sendWarningMessage("$chatName &6&lWarning: &r&6This does not work in singleplayer")
disable()
} else {
MessageSendHelper.sendWarningMessage("$chatName &6&lWarning: &r&6This will kick you on most servers!")
init {
onEnable {
if (mc.currentServerData == null) {
MessageSendHelper.sendWarningMessage("$chatName &6&lWarning: &r&6This does not work in singleplayer")
disable()
} else {
MessageSendHelper.sendWarningMessage("$chatName &6&lWarning: &r&6This will kick you on most servers!")
modifier.enable()
}
}
onDisable {
modifier.enable()
}
}
override fun onDisable() {
modifier.enable()
}
}

View File

@ -25,11 +25,11 @@ object FriendHighlight : Module(
private val regex1 = "<(.*?)>".toRegex()
private val regex2 = "[<>]".toRegex()
override fun onEnable() {
noFriendsCheck()
}
init {
onEnable {
noFriendsCheck()
}
listener<ClientChatReceivedEvent>(0) {
if (noFriendsCheck() || !FriendManager.enabled) return@listener

View File

@ -21,7 +21,7 @@ object LoginMessage : Module(
showOnArray = false,
modulePriority = 150
) {
private val sendAfterMoving = setting("SendAfterMoving", false)
private val sendAfterMoving by setting("SendAfterMoving", false)
private val file = File(KamiMod.DIRECTORY + "loginmsg.txt")
private var loginMessage: String? = null
@ -29,6 +29,27 @@ object LoginMessage : Module(
private var moved = false
init {
onEnable {
if (file.exists()) {
val fileReader = FileReader(file)
try {
fileReader.readLines().getOrNull(0)?.let {
if (it.isNotBlank()) loginMessage = it.trim()
}
MessageSendHelper.sendChatMessage("$chatName Loaded login message!")
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed loading login message, $e")
disable()
}
fileReader.close()
} else {
file.createNewFile()
MessageSendHelper.sendErrorMessage("$chatName Login Message file is empty!" +
", please add them in the &7loginmsg.txt&f under the &7.minecraft/kamiblue&f directory.")
disable()
}
}
listener<ConnectionEvent.Disconnect> {
sent = false
moved = false
@ -37,7 +58,7 @@ object LoginMessage : Module(
safeListener<TickEvent.ClientTickEvent> { event ->
if (event.phase != TickEvent.Phase.END) return@safeListener
if (!sent && (!sendAfterMoving.value || moved)) {
if (!sent && (!sendAfterMoving || moved)) {
loginMessage?.let {
if (MessageDetection.Command.KAMI_BLUE detect it) {
MessageSendHelper.sendKamiCommand(it)
@ -51,26 +72,4 @@ object LoginMessage : Module(
if (!moved) moved = player.isMoving
}
}
override fun onEnable() {
if (file.exists()) {
val fileReader = FileReader(file)
try {
fileReader.readLines().getOrNull(0)?.let {
if (it.isNotBlank()) loginMessage = it.trim()
}
MessageSendHelper.sendChatMessage("$chatName Loaded login message!")
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed loading login message, $e")
disable()
}
fileReader.close()
} else {
file.createNewFile()
MessageSendHelper.sendErrorMessage("$chatName Login Message file is empty!" +
", please add them in the &7loginmsg.txt&f under the &7.minecraft/kamiblue&f directory.")
disable()
}
}
}

View File

@ -47,43 +47,45 @@ object Spammer : Module(
null
}
override fun onEnable() {
spammer.clear()
init {
onEnable {
spammer.clear()
if (loadRemote.value) {
val url = urlValue ?: return
if (loadRemote.value) {
val url = urlValue ?: return@onEnable
defaultScope.launch(Dispatchers.IO) {
try {
val text = URL(url).readText()
spammer.addAll(text.split("\n"))
defaultScope.launch(Dispatchers.IO) {
try {
val text = URL(url).readText()
spammer.addAll(text.split("\n"))
MessageSendHelper.sendChatMessage("$chatName Loaded remote spammer messages!")
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed loading remote spammer, $e")
disable()
MessageSendHelper.sendChatMessage("$chatName Loaded remote spammer messages!")
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed loading remote spammer, $e")
disable()
}
}
}
} else {
if (file.exists()) {
try {
file.forEachLine { if (it.isNotBlank()) spammer.add(it.trim()) }
MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!")
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed loading spammer, $e")
disable()
}
} else {
file.createNewFile()
MessageSendHelper.sendErrorMessage("$chatName Spammer file is empty!" +
", please add them in the &7spammer.txt&f under the &7.minecraft/kamiblue&f directory.")
disable()
defaultScope.launch(Dispatchers.IO) {
if (file.exists()) {
try {
file.forEachLine { if (it.isNotBlank()) spammer.add(it.trim()) }
MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!")
} catch (e: Exception) {
MessageSendHelper.sendErrorMessage("$chatName Failed loading spammer, $e")
disable()
}
} else {
file.createNewFile()
MessageSendHelper.sendErrorMessage("$chatName Spammer file is empty!" +
", please add them in the &7spammer.txt&f under the &7.minecraft/kamiblue&f directory.")
disable()
}
}
}
}
}
init {
safeListener<TickEvent.ClientTickEvent> {
if (it.phase != TickEvent.Phase.START || spammer.isEmpty() || !timer.tick(delay.value.toLong())) return@safeListener
val message = if (modeSetting.value == Mode.IN_ORDER) getOrdered() else getRandom()

View File

@ -60,21 +60,21 @@ object ClickGUI : Module(
return round((scaleSetting.value / 100.0f) / 0.1f) * 0.1f
}
override fun onEnable() {
if (mc.currentScreen !is KamiClickGui) {
HudEditor.disable()
mc.displayGuiScreen(KamiClickGui)
KamiClickGui.onDisplayed()
}
}
override fun onDisable() {
if (mc.currentScreen is KamiClickGui) {
mc.displayGuiScreen(null)
}
}
init {
onEnable {
if (mc.currentScreen !is KamiClickGui) {
HudEditor.disable()
mc.displayGuiScreen(KamiClickGui)
KamiClickGui.onDisplayed()
}
}
onDisable {
if (mc.currentScreen is KamiClickGui) {
mc.displayGuiScreen(null)
}
}
bind.value.setBind(Keyboard.KEY_Y)
scaleSetting.listeners.add {
settingTimer.reset()

View File

@ -11,21 +11,21 @@ object HudEditor : Module(
category = Category.CLIENT,
showOnArray = false
) {
override fun onEnable() {
if (mc.currentScreen !is KamiHudGui) {
ClickGUI.disable()
mc.displayGuiScreen(KamiHudGui)
KamiHudGui.onDisplayed()
}
}
override fun onDisable() {
if (mc.currentScreen is KamiHudGui) {
mc.displayGuiScreen(null)
}
}
init {
onEnable {
if (mc.currentScreen !is KamiHudGui) {
ClickGUI.disable()
mc.displayGuiScreen(KamiHudGui)
KamiHudGui.onDisplayed()
}
}
onDisable {
if (mc.currentScreen is KamiHudGui) {
mc.displayGuiScreen(null)
}
}
listener<ShutdownEvent> {
disable()
}

View File

@ -27,7 +27,7 @@ object AntiBot : Module(
private val hoverOnTop = setting("HoverOnTop", true)
private val ticksExists = setting("TicksExists", 200, 0..500, 10)
val botSet = HashSet<EntityPlayer>()
private val botSet = HashSet<EntityPlayer>()
init {
listener<ConnectionEvent.Disconnect> {
@ -54,7 +54,7 @@ object AntiBot : Module(
fun isBot(entity: Entity) = isEnabled && entity is EntityPlayer && botSet.contains(entity)
private fun SafeClientEvent.isBot(entity: EntityPlayer) = entity.name == player.name
|| entity.name == FakePlayer.playerName.value
|| entity.name == FakePlayer.playerName
|| tabList.value && connection.getPlayerInfo(entity.name) == null
|| ping.value && connection.getPlayerInfo(entity.name)?.responseTime ?: -1 <= 0
|| hp.value && entity.health !in 0f..20f

View File

@ -7,14 +7,13 @@ import me.zeroeightsix.kami.util.InventoryUtils
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.network.play.server.SPacketEntityStatus
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener
object AntiChainPop : Module(
name = "AntiChainPop",
description = "Enables Surround when popping a totem",
category = Category.COMBAT
) {
private val mode = setting("Mode", Mode.PACKET)
private val mode by setting("Mode", Mode.PACKET)
private enum class Mode {
ITEMS, PACKET
@ -23,25 +22,23 @@ object AntiChainPop : Module(
private var totems = 0
init {
listener<PacketEvent.Receive> { event ->
if (mode.value != Mode.PACKET || event.packet !is SPacketEntityStatus || event.packet.opCode.toInt() != 35) return@listener
mc.world?.let {
if (event.packet.getEntity(it) == mc.player) {
Surround.enable()
}
safeListener<PacketEvent.Receive> { event ->
if (mode != Mode.PACKET || event.packet !is SPacketEntityStatus || event.packet.opCode.toInt() != 35) return@safeListener
if (event.packet.getEntity(world) == mc.player) {
Surround.enable()
}
}
safeListener<TickEvent.ClientTickEvent> {
if (mode.value == Mode.ITEMS) return@safeListener
if (mode == Mode.ITEMS) return@safeListener
val old = totems
val new = InventoryUtils.countItemAll(449)
if (new < old) Surround.enable()
totems = new
}
}
override fun onToggle() {
totems = 0
onDisable {
totems = 0
}
}
}

View File

@ -77,7 +77,7 @@ object AutoLog : Module(
private fun SafeClientEvent.checkPlayers(): Boolean {
for (entity in world.loadedEntityList) {
if (entity !is EntityPlayer) continue
if (AntiBot.botSet.contains(entity)) continue
if (AntiBot.isBot(entity)) continue
if (entity == player) continue
if (player.getDistance(entity) > playerDistance.value) continue
if (!friends.value && FriendManager.isFriend(entity.name)) continue

View File

@ -5,6 +5,7 @@ import me.zeroeightsix.kami.event.events.GuiEvent
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.init.Items
import net.minecraft.util.EnumHand
@ -17,16 +18,34 @@ object AutoMend : Module(
category = Category.COMBAT,
description = "Automatically mends armour"
) {
private val autoThrow = setting("AutoThrow", true)
private val autoSwitch = setting("AutoSwitch", true)
private val autoDisable = setting("AutoDisable", false, { autoSwitch.value })
private val threshold = setting("Repair%", 75, 1..100, 1)
private val gui = setting("RunInGUIs", false)
private val autoThrow by setting("AutoThrow", true)
private val autoSwitch by setting("AutoSwitch", true)
private val autoDisable by setting("AutoDisable", false, { autoSwitch })
private val threshold by setting("Repair%", 75, 1..100, 1)
private val gui by setting("RunInGUIs", false)
private var initHotbarSlot = -1
private var isGuiOpened = false
init {
onEnable {
if (autoSwitch) {
runSafe {
initHotbarSlot = player.inventory.currentItem
}
}
}
onDisable {
if (autoSwitch) {
runSafe {
if (initHotbarSlot != -1 && initHotbarSlot != player.inventory.currentItem) {
player.inventory.currentItem = initHotbarSlot
}
}
}
}
listener<GuiEvent.Displayed> {
isGuiOpened = it.screen != null
}
@ -36,14 +55,14 @@ object AutoMend : Module(
}
safeListener<TickEvent.ClientTickEvent> {
if (isGuiOpened && !gui.value) return@safeListener
if (isGuiOpened && !gui) return@safeListener
if (shouldMend(0) || shouldMend(1) || shouldMend(2) || shouldMend(3)) {
if (autoSwitch.value && player.heldItemMainhand.item !== Items.EXPERIENCE_BOTTLE) {
if (autoSwitch && player.heldItemMainhand.item !== Items.EXPERIENCE_BOTTLE) {
val xpSlot = findXpPots()
if (xpSlot == -1) {
if (autoDisable.value) {
if (autoDisable) {
MessageSendHelper.sendWarningMessage("$chatName No XP in hotbar, disabling")
disable()
}
@ -51,31 +70,17 @@ object AutoMend : Module(
}
player.inventory.currentItem = xpSlot
}
if (autoThrow.value && player.heldItemMainhand.item === Items.EXPERIENCE_BOTTLE) {
if (autoThrow && player.heldItemMainhand.item === Items.EXPERIENCE_BOTTLE) {
playerController.processRightClick(player, world, EnumHand.MAIN_HAND)
}
}
}
}
override fun onEnable() {
if (mc.player == null) return
if (autoSwitch.value) {
initHotbarSlot = mc.player.inventory.currentItem
}
}
override fun onDisable() {
if (mc.player == null) return
if (autoSwitch.value && initHotbarSlot != -1 && initHotbarSlot != mc.player.inventory.currentItem) {
mc.player.inventory.currentItem = initHotbarSlot
}
}
private fun findXpPots(): Int {
private fun SafeClientEvent.findXpPots(): Int {
var slot = -1
for (i in 0..8) {
if (mc.player.inventory.getStackInSlot(i).item === Items.EXPERIENCE_BOTTLE) {
if (player.inventory.getStackInSlot(i).item === Items.EXPERIENCE_BOTTLE) {
slot = i
break
}
@ -85,6 +90,6 @@ object AutoMend : Module(
private fun SafeClientEvent.shouldMend(i: Int): Boolean { // (100 * damage / max damage) >= (100 - 70)
val stack = player.inventory.armorInventory[i]
return stack.isItemDamaged && 100 * stack.itemDamage / stack.maxDamage > reverseNumber(threshold.value, 1, 100)
return stack.isItemDamaged && 100 * stack.itemDamage / stack.maxDamage > reverseNumber(threshold, 1, 100)
}
}

View File

@ -40,11 +40,11 @@ object AutoTrap : Module(
return isEnabled && job.isActiveOrFalse
}
override fun onDisable() {
PlayerPacketManager.resetHotbar()
}
init {
onDisable {
PlayerPacketManager.resetHotbar()
}
safeListener<TickEvent.ClientTickEvent> {
if (!job.isActiveOrFalse && isPlaceable()) job = runAutoTrap()

View File

@ -61,13 +61,12 @@ object BedAura : Module(
return isEnabled && inactiveTicks <= 5
}
override fun onDisable() {
state = State.NONE
inactiveTicks = 6
}
init {
onDisable {
state = State.NONE
inactiveTicks = 6
}
listener<PacketEvent.PostSend> {
if (!CombatManager.isOnTopPriority(this) || it.packet !is CPacketPlayer || state == State.NONE || CombatSetting.pause) return@listener
val hand = getBedHand() ?: EnumHand.MAIN_HAND

View File

@ -31,6 +31,10 @@ object Criticals : Module(
private var swingPacket = CPacketAnimation()
init {
onDisable {
delayTick = 0
}
listener<PacketEvent.Send> {
if (mc.player == null || !(it.packet is CPacketAnimation || it.packet is CPacketUseEntity)) return@listener
if (mc.player.isInWater || mc.player.isInLava || !mc.player.onGround) return@listener /* Don't run if player is sprinting or weapon is still in cooldown */
@ -105,8 +109,4 @@ object Criticals : Module(
}
}
}
override fun onDisable() {
delayTick = 0
}
}

View File

@ -22,6 +22,7 @@ import me.zeroeightsix.kami.util.math.VectorUtils.toVec3d
import me.zeroeightsix.kami.util.math.VectorUtils.toVec3dCenter
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.defaultScope
import me.zeroeightsix.kami.util.threads.runSafeR
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.entity.item.EntityEnderCrystal
import net.minecraft.init.Items
@ -143,22 +144,23 @@ object CrystalAura : Module(
override fun isActive() = isEnabled && InventoryUtils.countItemAll(426) > 0 && inactiveTicks <= 20
override fun onEnable() {
if (mc.player == null) disable()
else resetRotation()
}
override fun onDisable() {
lastCrystal = null
forcePlacing = false
placeTimer = 0
hitTimer = 0
hitCount = 0
inactiveTicks = 10
PlayerPacketManager.resetHotbar()
}
init {
onEnable {
runSafeR {
resetRotation()
} ?: disable()
}
onDisable {
lastCrystal = null
forcePlacing = false
placeTimer = 0
hitTimer = 0
hitCount = 0
inactiveTicks = 10
PlayerPacketManager.resetHotbar()
}
listener<InputEvent.KeyInputEvent> {
if (bindForcePlace.isDown(Keyboard.getEventKey())) {
forcePlacing = !forcePlacing

View File

@ -48,17 +48,17 @@ object CrystalBasePlace : Module(
private var rotationTo: Vec3d? = null
private var placePacket: CPacketPlayerTryUseItemOnBlock? = null
override fun onDisable() {
inactiveTicks = 0
placePacket = null
PlayerPacketManager.resetHotbar()
}
override fun isActive(): Boolean {
return isEnabled && inactiveTicks <= 3
}
init {
onDisable {
inactiveTicks = 0
placePacket = null
PlayerPacketManager.resetHotbar()
}
listener<RenderWorldEvent> {
val clear = inactiveTicks >= 30
renderer.render(clear)

View File

@ -12,6 +12,7 @@ import me.zeroeightsix.kami.util.math.VectorUtils.distanceTo
import me.zeroeightsix.kami.util.math.VectorUtils.toBlockPos
import me.zeroeightsix.kami.util.math.VectorUtils.toVec3dCenter
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.runSafeR
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.entity.Entity
import net.minecraft.init.Blocks
@ -29,38 +30,36 @@ object HoleMiner : Module(
description = "Mines your opponent's hole",
modulePriority = 100
) {
private val range = setting("Range", 5.0f, 1.0f..8.0f, 0.25f)
private val range by setting("Range", 5.0f, 1.0f..8.0f, 0.25f)
private var miningPos: BlockPos? = null
private var start = true
override fun getHudInfo() = CombatManager.target?.name ?: ""
override fun onDisable() {
miningPos = null
start = true
}
override fun onEnable() {
if (mc.player == null) {
disable()
return
}
val target = CombatManager.target
if (target != null) {
if (SurroundUtils.checkHole(target) != SurroundUtils.HoleType.OBBY) {
MessageSendHelper.sendChatMessage("$chatName Target is not in a valid hole, disabling")
disable()
} else {
miningPos = findHoleBlock(target)
}
} else {
MessageSendHelper.sendChatMessage("$chatName No target found, disabling")
disable()
}
}
init {
onEnable {
runSafeR {
val target = CombatManager.target
if (target != null) {
if (SurroundUtils.checkHole(target) != SurroundUtils.HoleType.OBBY) {
MessageSendHelper.sendChatMessage("$chatName Target is not in a valid hole, disabling")
disable()
} else {
miningPos = findHoleBlock(target)
}
} else {
MessageSendHelper.sendChatMessage("$chatName No target found, disabling")
disable()
}
} ?: disable()
}
onDisable {
miningPos = null
start = true
}
safeListener<TickEvent.ClientTickEvent> {
if (!CombatManager.isOnTopPriority(HoleMiner)) return@safeListener
if (player.heldItemMainhand.item != Items.DIAMOND_PICKAXE) {
@ -102,7 +101,7 @@ object HoleMiner : Module(
for (facing in EnumFacing.HORIZONTALS) {
val offsetPos = pos.offset(facing)
val dist = mc.player.distanceTo(offsetPos)
if (dist > range.value || dist > closestPos.first) continue
if (dist > range || dist > closestPos.first) continue
if (mc.world.getBlockState(offsetPos).block == Blocks.BEDROCK) continue
if (!checkPos(offsetPos, facing)) continue
closestPos = dist to offsetPos

View File

@ -22,12 +22,8 @@ object HoleSnap : Module(
description = "Move you into the hole nearby",
category = Category.COMBAT
) {
private val disableStrafe = setting("DisableStrafe", true)
private val range = setting("Range", 2.5f, 0.5f..4.0f, 0.25f)
override fun onEnable() {
if (mc.player == null) disable()
}
private val disableStrafe by setting("DisableStrafe", true)
private val range by setting("Range", 2.5f, 0.5f..4.0f, 0.25f)
init {
safeListener<TickEvent.ClientTickEvent> {
@ -36,7 +32,7 @@ object HoleSnap : Module(
return@safeListener
}
findHole()?.toVec3dCenter()?.let {
if (disableStrafe.value) Strafe.disable()
if (disableStrafe) Strafe.disable()
if (player.onGround) {
val yawRad = RotationUtils.getRotationTo(player.positionVector, it).x.toDouble().toRadian()
val speed = min(0.25, player.positionVector.distanceTo(it) / 4.0)
@ -50,11 +46,11 @@ object HoleSnap : Module(
private fun SafeClientEvent.findHole(): BlockPos? {
var closestHole = Pair(69.69, BlockPos.ORIGIN)
val playerPos = player.positionVector.toBlockPos()
val ceilRange = (range.value).ceilToInt()
val ceilRange = (range).ceilToInt()
val posList = VectorUtils.getBlockPositionsInArea(playerPos.add(ceilRange, -1, ceilRange), playerPos.add(-ceilRange, -1, -ceilRange))
for (posXZ in posList) {
val dist = player.distanceTo(posXZ)
if (dist > range.value || dist > closestHole.first) continue
if (dist > range || dist > closestHole.first) continue
for (posY in 0..5) {
val pos = posXZ.add(0, -posY, 0)
if (!world.isAirBlock(pos.up())) break

View File

@ -45,21 +45,22 @@ object Surround : Module(
private var toggleTimer = StopTimer(TimeUnit.TICKS)
private var job: Job? = null
override fun onEnable() {
toggleTimer.reset()
}
override fun onDisable() {
PlayerPacketManager.resetHotbar()
toggleTimer.reset()
holePos = null
}
override fun isActive(): Boolean {
return isEnabled && job.isActiveOrFalse
}
init {
onEnable {
toggleTimer.reset()
}
onDisable {
PlayerPacketManager.resetHotbar()
toggleTimer.reset()
holePos = null
}
safeListener<TickEvent.ClientTickEvent> {
if (getObby() == -1) return@safeListener
if (isDisabled) {

View File

@ -35,13 +35,17 @@ object TotemPopCounter : Module(
CLIENT, EVERYONE
}
private val playerList = HashMap<EntityPlayer, Int>()
private val playerList = Collections.synchronizedMap(HashMap<EntityPlayer, Int>())
private var wasDead = false
init {
listener<PacketEvent.Receive> {
if (it.packet !is SPacketEntityStatus || it.packet.opCode.toInt() != 35 || mc.player == null || mc.player.isDead) return@listener
val player = (it.packet.getEntity(mc.world) as? EntityPlayer) ?: return@listener
onDisable {
playerList.clear()
}
safeListener<PacketEvent.Receive> {
if (it.packet !is SPacketEntityStatus || it.packet.opCode.toInt() != 35 || player.isDead) return@safeListener
val player = (it.packet.getEntity(world) as? EntityPlayer) ?: return@safeListener
if (friendCheck(player) || selfCheck(player)) {
val count = playerList.getOrDefault(player, 0) + 1
@ -77,10 +81,6 @@ object TotemPopCounter : Module(
}
}
override fun onDisable() {
playerList.clear()
}
private fun friendCheck(player: EntityPlayer) = FriendManager.isFriend(player.name) && countFriends.value
private fun selfCheck(player: EntityPlayer) = player == mc.player && countSelf.value

View File

@ -30,15 +30,15 @@ object AntiAFK : Module(
category = Category.MISC,
description = "Prevents being kicked for AFK"
) {
private val delay = setting("ActionDelay", 50, 5..100, 5)
private val variation = setting("Variation", 25, 0..50, 5)
private val autoReply = setting("AutoReply", true)
private val delay by setting("ActionDelay", 50, 5..100, 5)
private val variation by setting("Variation", 25, 0..50, 5)
private val autoReply by setting("AutoReply", true)
private val swing = setting("Swing", true)
private val jump = setting("Jump", true)
private val turn = setting("Turn", true)
private val walk = setting("Walk", true)
private val radius = setting("Radius", 64, 8..128, 8)
private val inputTimeout = setting("InputTimeout(m)", 0, 0..15, 1)
private val radius by setting("Radius", 64, 8..128, 8)
private val inputTimeout by setting("InputTimeout(m)", 0, 0..15, 1)
private var startPos: BlockPos? = null
private var squareStep = 0
@ -48,22 +48,22 @@ object AntiAFK : Module(
private var nextActionDelay = 0
override fun getHudInfo(): String {
return if (inputTimeout.value == 0) ""
return if (inputTimeout == 0) ""
else ((System.currentTimeMillis() - inputTimer.time) / 1000L).toString()
}
override fun onDisable() {
startPos = null
BaritoneUtils.settings?.disconnectOnArrival?.value = baritoneDisconnectOnArrival
BaritoneUtils.cancelEverything()
}
override fun onEnable() {
inputTimer.reset()
baritoneDisconnectOnArrival()
}
init {
onEnable {
inputTimer.reset()
baritoneDisconnectOnArrival()
}
onDisable {
startPos = null
BaritoneUtils.settings?.disconnectOnArrival?.value = baritoneDisconnectOnArrival
BaritoneUtils.cancelEverything()
}
listener<BaritoneSettingsInitEvent> {
baritoneDisconnectOnArrival()
}
@ -78,20 +78,20 @@ object AntiAFK : Module(
init {
listener<PacketEvent.Receive> {
if (!autoReply.value || it.packet !is SPacketChat) return@listener
if (!autoReply || it.packet !is SPacketChat) return@listener
if (MessageDetection.Direct.RECEIVE detect it.packet.chatComponent.unformattedText) {
sendServerMessage("/r I am currently AFK and using KAMI Blue!")
}
}
listener<InputEvent.MouseInputEvent> {
if (inputTimeout.value != 0 && isInputting()) {
if (inputTimeout != 0 && isInputting()) {
inputTimer.reset()
}
}
listener<InputEvent.KeyInputEvent> {
if (inputTimeout.value != 0 && isInputting()) {
if (inputTimeout != 0 && isInputting()) {
inputTimer.reset()
}
}
@ -109,18 +109,18 @@ object AntiAFK : Module(
init {
safeListener<TickEvent.ClientTickEvent> {
if (inputTimeout.value != 0) {
if (inputTimeout != 0) {
if (BaritoneUtils.isActive) {
inputTimer.reset()
} else if (!inputTimer.tick(inputTimeout.value.toLong(), false)) {
} else if (!inputTimer.tick(inputTimeout.toLong(), false)) {
startPos = null
return@safeListener
}
}
if (actionTimer.tick(nextActionDelay.toLong())) {
val random = if (variation.value > 0) (0..variation.value).random() else 0
nextActionDelay = delay.value + random
val random = if (variation > 0) (0..variation).random() else 0
nextActionDelay = delay + random
when ((getAction())) {
Action.SWING -> player.swingArm(EnumHand.MAIN_HAND)
@ -146,9 +146,9 @@ object AntiAFK : Module(
startPos?.let {
when (squareStep) {
0 -> baritoneGotoXZ(it.x, it.z + radius.value)
1 -> baritoneGotoXZ(it.x + radius.value, it.z + radius.value)
2 -> baritoneGotoXZ(it.x + radius.value, it.z)
0 -> baritoneGotoXZ(it.x, it.z + radius)
1 -> baritoneGotoXZ(it.x + radius, it.z + radius)
2 -> baritoneGotoXZ(it.x + radius, it.z)
3 -> baritoneGotoXZ(it.x, it.z)
}
}

View File

@ -1,5 +1,6 @@
package me.zeroeightsix.kami.module.modules.misc
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.mixin.extension.rightClickMouse
import me.zeroeightsix.kami.module.Module
@ -10,7 +11,6 @@ import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.init.Items
import net.minecraft.network.play.server.SPacketSoundEffect
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener
import java.lang.Math.random
import kotlin.math.abs
@ -42,9 +42,9 @@ object AutoFish : Module(
private val timer = TickTimer()
init {
listener<PacketEvent.Receive> {
if (mc.player == null || mc.player.fishEntity == null || !isStabled()) return@listener
if (mode.value == Mode.BOUNCE || it.packet !is SPacketSoundEffect) return@listener
safeListener<PacketEvent.Receive> {
if (player.fishEntity == null || !isStabled()) return@safeListener
if (mode.value == Mode.BOUNCE || it.packet !is SPacketSoundEffect) return@safeListener
if (isSplash(it.packet)) catch()
}
@ -80,25 +80,25 @@ object AutoFish : Module(
reset()
}
}
onToggle {
reset()
}
}
override fun onToggle() {
reset()
private fun SafeClientEvent.isStabled(): Boolean {
if (player.fishEntity?.isAirBorne != false || recasting) return false
return abs(player.fishEntity!!.motionX) + abs(player.fishEntity!!.motionZ) < 0.01
}
private fun isStabled(): Boolean {
if (mc.player.fishEntity == null || mc.player.fishEntity!!.isAirBorne || recasting) return false
return abs(mc.player.fishEntity!!.motionX) + abs(mc.player.fishEntity!!.motionZ) < 0.01
}
private fun isOnWater(): Boolean {
if (mc.player.fishEntity == null || mc.player.fishEntity!!.isAirBorne) return false
val pos = mc.player.fishEntity!!.position
private fun SafeClientEvent.isOnWater(): Boolean {
if (player.fishEntity?.isAirBorne != false) return false
val pos = player.fishEntity!!.position
return isWater(pos) || isWater(pos.down())
}
private fun isSplash(packet: SPacketSoundEffect): Boolean {
if (mode.value == Mode.SPLASH && mc.player.fishEntity!!.getDistance(packet.x, packet.y, packet.z) > 2) return false
private fun SafeClientEvent.isSplash(packet: SPacketSoundEffect): Boolean {
if (mode.value == Mode.SPLASH && (player.fishEntity?.getDistance(packet.x, packet.y, packet.z) ?: 69420.0) > 2) return false
val soundName = packet.sound.soundName.toString().toLowerCase()
return (mode.value != Mode.SPLASH && isAnySplash(soundName)) || soundName.contains("entity.bobber.splash")
}
@ -109,9 +109,9 @@ object AutoFish : Module(
|| soundName.contains("entity.player.splash")
}
private fun isBouncing(): Boolean {
if (mc.player.fishEntity == null || !isOnWater()) return false
return mc.player.fishEntity!!.motionY !in -0.05..0.05
private fun SafeClientEvent.isBouncing(): Boolean {
if (player.fishEntity == null || !isOnWater()) return false
return (player.fishEntity?.motionY ?: 911.0)!in -0.05..0.05
}
private fun catch() {

View File

@ -1,6 +1,7 @@
package me.zeroeightsix.kami.module.modules.misc
import me.zeroeightsix.kami.command.CommandManager
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.BaritoneCommandEvent
import me.zeroeightsix.kami.event.events.ConnectionEvent
import me.zeroeightsix.kami.mixin.extension.sendClickBlockToController
@ -9,6 +10,8 @@ import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.BaritoneUtils
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.text.formatValue
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.runSafeR
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener
@ -19,27 +22,27 @@ object AutoMine : Module(
category = Category.MISC
) {
private val manual = setting("Manual", false)
private val manual by setting("Manual", false)
private val iron = setting("Iron", false)
private val diamond = setting("Diamond", false)
private val gold = setting("Gold", false)
private val coal = setting("Coal", false)
private val log = setting("Logs", false)
override fun onEnable() {
if (mc.player == null) {
disable()
} else {
run()
init {
onEnable {
runSafeR {
run()
} ?: disable()
}
onDisable {
BaritoneUtils.cancelEverything()
}
}
override fun onDisable() {
BaritoneUtils.cancelEverything()
}
private fun run() {
if (mc.player == null || isDisabled || manual.value) return
private fun SafeClientEvent.run() {
if (isDisabled || manual) return
val blocks = ArrayList<String>()
@ -64,7 +67,7 @@ object AutoMine : Module(
init {
safeListener<TickEvent.ClientTickEvent> {
if (manual.value) {
if (manual) {
mc.sendClickBlockToController(true)
}
}
@ -79,7 +82,7 @@ object AutoMine : Module(
}
}
with({ run() }) {
with({ runSafe { run() } }) {
iron.listeners.add(this)
diamond.listeners.add(this)
gold.listeners.add(this)

View File

@ -109,15 +109,15 @@ object AutoObsidian : Module(
return isEnabled && active
}
override fun onEnable() {
state = State.SEARCHING
}
override fun onDisable() {
reset()
}
init {
onEnable {
state = State.SEARCHING
}
onDisable {
reset()
}
safeListener<TickEvent.ClientTickEvent> {
if (it.phase != TickEvent.Phase.START) return@safeListener

View File

@ -29,14 +29,14 @@ object AutoSpawner : Module(
category = Category.MISC,
description = "Automatically spawns Withers, Iron Golems and Snowmen"
) {
private val useMode = setting("UseMode", UseMode.SPAM)
private val party = setting("Party", false)
private val partyWithers = setting("Withers", false, { party.value })
private val entityMode = setting("EntityMode", EntityMode.SNOW, { !party.value })
private val placeRange = setting("PlaceRange", 3.5f, 2f..10f, 0.5f)
private val delay = setting("Delay", 20, 10..100, 5, { useMode.value == UseMode.SPAM })
private val rotate = setting("Rotate", true)
private val debug = setting("Info", true)
private val useMode by setting("UseMode", UseMode.SPAM)
private val party by setting("Party", false)
private val partyWithers by setting("Withers", false, { party })
private var entityMode by setting("EntityMode", EntityMode.SNOW, { !party })
private val placeRange by setting("PlaceRange", 3.5f, 2f..10f, 0.5f)
private val delay by setting("Delay", 20, 10..100, 5, { useMode == UseMode.SPAM })
private val rotate by setting("Rotate", true)
private val debug by setting("Info", true)
private enum class UseMode {
SINGLE, SPAM
@ -60,26 +60,26 @@ object AutoSpawner : Module(
}
override fun getHudInfo(): String {
return if (party.value) {
if (partyWithers.value) "PARTY WITHER"
return if (party) {
if (partyWithers) "PARTY WITHER"
else "PARTY"
} else entityMode.value.toString()
}
override fun onEnable() {
if (mc.player == null) disable()
}
override fun onDisable() {
placeTarget = null
rotationPlaceableX = false
rotationPlaceableZ = false
bodySlot = -1
isSneaking = false
buildStage = Stage.PRE
} else entityMode.toString()
}
init {
onEnable {
if (mc.player == null) disable()
}
onDisable {
placeTarget = null
rotationPlaceableX = false
rotationPlaceableZ = false
bodySlot = -1
isSneaking = false
buildStage = Stage.PRE
}
safeListener<TickEvent.ClientTickEvent> {
when (buildStage) {
Stage.PRE -> {
@ -87,16 +87,16 @@ object AutoSpawner : Module(
rotationPlaceableX = false
rotationPlaceableZ = false
if (party.value) randomizeEntity()
if (party) randomizeEntity()
if (!checkBlocksInHotbar()) {
if (!party.value) {
if (debug.value) sendChatMessage("$chatName &c Blocks missing for: &c${entityMode.value}, disabling.")
if (!party) {
if (debug) sendChatMessage("$chatName &c Blocks missing for: &c${entityMode}, disabling.")
disable()
}
return@safeListener
}
val blockPosList = VectorUtils.getBlockPosInSphere(player.positionVector, placeRange.value)
val blockPosList = VectorUtils.getBlockPosInSphere(player.positionVector, placeRange)
var noPositionInArea = true
for (pos in blockPosList) {
@ -108,8 +108,8 @@ object AutoSpawner : Module(
}
if (noPositionInArea) {
if (useMode.value == UseMode.SINGLE) {
if (debug.value) sendChatMessage("$chatName No valid position, disabling.")
if (useMode == UseMode.SINGLE) {
if (debug) sendChatMessage("$chatName No valid position, disabling.")
disable()
return@safeListener
}
@ -120,7 +120,7 @@ object AutoSpawner : Module(
Stage.BODY -> {
InventoryUtils.swapSlot(bodySlot)
for (pos in BodyParts.bodyBase) placeBlock(placeTarget!!.add(pos))
if (entityMode.value == EntityMode.WITHER || entityMode.value == EntityMode.IRON) {
if (entityMode == EntityMode.WITHER || entityMode == EntityMode.IRON) {
if (rotationPlaceableX) {
for (pos in BodyParts.ArmsX) {
placeBlock(placeTarget!!.add(pos))
@ -137,11 +137,11 @@ object AutoSpawner : Module(
Stage.HEAD -> {
InventoryUtils.swapSlot(headSlot)
if (entityMode.value == EntityMode.IRON || entityMode.value == EntityMode.SNOW) {
if (entityMode == EntityMode.IRON || entityMode == EntityMode.SNOW) {
for (pos in BodyParts.head) placeBlock(placeTarget!!.add(pos))
}
if (entityMode.value == EntityMode.WITHER) {
if (entityMode == EntityMode.WITHER) {
if (rotationPlaceableX) {
for (pos in BodyParts.headsX) {
placeBlock(placeTarget!!.add(pos))
@ -158,21 +158,21 @@ object AutoSpawner : Module(
isSneaking = false
}
if (useMode.value == UseMode.SINGLE) disable()
if (useMode == UseMode.SINGLE) disable()
buildStage = Stage.DELAY
timer.reset()
}
Stage.DELAY -> {
if (timer.tick(delay.value.toLong())) buildStage = Stage.PRE
if (timer.tick(delay.toLong())) buildStage = Stage.PRE
}
}
}
}
private fun randomizeEntity() {
entityMode.value = EntityMode.values().random()
if (!partyWithers.value && entityMode.value == EntityMode.WITHER) randomizeEntity()
entityMode = EntityMode.values().random()
if (!partyWithers && entityMode == EntityMode.WITHER) randomizeEntity()
}
private fun checkBlocksInHotbar(): Boolean {
@ -182,7 +182,7 @@ object AutoSpawner : Module(
val stack = mc.player.inventory.getStackInSlot(slotIndex) ?: continue
if (stack.isEmpty) continue
when (entityMode.value) {
when (entityMode) {
EntityMode.SNOW -> {
if (stack.item is ItemBlock) {
val block = (stack.item as ItemBlock).block
@ -238,13 +238,13 @@ object AutoSpawner : Module(
if (placingIsBlocked(it.add(pos))) return false
}
if (entityMode.value == EntityMode.SNOW || entityMode.value == EntityMode.IRON) {
if (entityMode == EntityMode.SNOW || entityMode == EntityMode.IRON) {
for (pos in BodyParts.head) {
if (placingIsBlocked(it.add(pos))) return false
}
}
if (entityMode.value == EntityMode.IRON || entityMode.value == EntityMode.WITHER) {
if (entityMode == EntityMode.IRON || entityMode == EntityMode.WITHER) {
for (pos in BodyParts.ArmsX) {
if (placingIsBlocked(it.add(pos))) rotationPlaceableX = false
}
@ -253,7 +253,7 @@ object AutoSpawner : Module(
}
}
if (entityMode.value == EntityMode.WITHER) {
if (entityMode == EntityMode.WITHER) {
for (pos in BodyParts.headsX) {
if (placingIsBlocked(it.add(pos))) rotationPlaceableX = false
}

View File

@ -32,11 +32,11 @@ object AutoTunnel : Module(
|| BaritoneUtils.primary?.builderProcess?.isActive == true)
}
override fun onDisable() {
if (mc.player != null) BaritoneUtils.cancelEverything()
}
init {
onDisable {
BaritoneUtils.cancelEverything()
}
safeListener<TickEvent.ClientTickEvent> {
if (!isActive()) sendTunnel()
}

View File

@ -13,12 +13,12 @@ object ConsoleSpam : Module(
description = "Spams Spigot consoles by sending invalid UpdateSign packets",
category = Category.MISC
) {
override fun onEnable() {
MessageSendHelper.sendChatMessage("$chatName Every time you right click a sign, a warning will appear in console.")
MessageSendHelper.sendChatMessage("$chatName Use an auto clicker to automate this process.")
}
init {
onEnable {
MessageSendHelper.sendChatMessage("$chatName Every time you right click a sign, a warning will appear in console.")
MessageSendHelper.sendChatMessage("$chatName Use an auto clicker to automate this process.")
}
listener<PacketEvent.Send> {
if (it.packet !is CPacketPlayerTryUseItemOnBlock) return@listener
mc.player.connection.sendPacket(CPacketUpdateSign(it.packet.pos, TileEntitySign().signText))

View File

@ -28,11 +28,11 @@ object DiscordRPC : Module(
description = "Discord Rich Presence",
enabledByDefault = true
) {
private val line1Left = setting("Line1Left", LineInfo.VERSION) // details left
private val line1Right = setting("Line1Right", LineInfo.USERNAME) // details right
private val line2Left = setting("Line2Left", LineInfo.SERVER_IP) // state left
private val line2Right = setting("Line2Right", LineInfo.HEALTH) // state right
private val coordsConfirm = setting("CoordsConfirm", false, { showCoordsConfirm() })
private val line1Left by setting("Line1Left", LineInfo.VERSION) // details left
private val line1Right by setting("Line1Right", LineInfo.USERNAME) // details right
private val line2Left by setting("Line2Left", LineInfo.SERVER_IP) // state left
private val line2Right by setting("Line2Right", LineInfo.HEALTH) // state right
private val coordsConfirm by setting("CoordsConfirm", false, { showCoordsConfirm() })
private enum class LineInfo {
VERSION, WORLD, DIMENSION, USERNAME, HEALTH, HUNGER, SERVER_IP, COORDS, SPEED, HELD_ITEM, FPS, TPS, NONE
@ -44,17 +44,17 @@ object DiscordRPC : Module(
private val timer = TickTimer(TimeUnit.SECONDS)
private val job = BackgroundJob("Discord RPC", 5000L) { updateRPC() }
override fun onEnable() {
start()
}
override fun onDisable() {
end()
}
init {
onEnable {
start()
}
onDisable {
end()
}
safeListener<TickEvent.ClientTickEvent> {
if (showCoordsConfirm() && !coordsConfirm.value && timer.tick(10L)) {
if (showCoordsConfirm() && !coordsConfirm && timer.tick(10L)) {
MessageSendHelper.sendWarningMessage("$chatName Warning: In order to use the coords option please enable the coords confirmation option. " +
"This will display your coords on the discord rpc. " +
"Do NOT use this if you do not want your coords displayed")
@ -89,15 +89,15 @@ object DiscordRPC : Module(
}
private fun showCoordsConfirm(): Boolean {
return line1Left.value == LineInfo.COORDS
|| line2Left.value == LineInfo.COORDS
|| line1Right.value == LineInfo.COORDS
|| line2Right.value == LineInfo.COORDS
return line1Left == LineInfo.COORDS
|| line2Left == LineInfo.COORDS
|| line1Right == LineInfo.COORDS
|| line2Right == LineInfo.COORDS
}
private fun updateRPC() {
presence.details = getLine(line1Left.value) + getSeparator(0) + getLine(line1Right.value)
presence.state = getLine(line2Left.value) + getSeparator(1) + getLine(line2Right.value)
presence.details = getLine(line1Left) + getSeparator(0) + getLine(line1Right)
presence.state = getLine(line2Left) + getSeparator(1) + getLine(line2Right)
rpc.Discord_UpdatePresence(presence)
}
@ -131,7 +131,7 @@ object DiscordRPC : Module(
InfoCalculator.getServerType()
}
LineInfo.COORDS -> {
if (mc.player != null && coordsConfirm.value) "(${mc.player.positionVector.toBlockPos().asString()})"
if (mc.player != null && coordsConfirm) "(${mc.player.positionVector.toBlockPos().asString()})"
else "No Coords"
}
LineInfo.SPEED -> {
@ -156,9 +156,9 @@ object DiscordRPC : Module(
private fun getSeparator(line: Int): String {
return if (line == 0) {
if (line1Left.value == LineInfo.NONE || line1Right.value == LineInfo.NONE) " " else " | "
if (line1Left == LineInfo.NONE || line1Right == LineInfo.NONE) " " else " | "
} else {
if (line2Left.value == LineInfo.NONE || line2Right.value == LineInfo.NONE) " " else " | "
if (line2Left == LineInfo.NONE || line2Right == LineInfo.NONE) " " else " | "
}
}

View File

@ -2,6 +2,8 @@ package me.zeroeightsix.kami.module.modules.misc
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.runSafeR
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.world.GameType
import net.minecraftforge.fml.common.gameevent.TickEvent
@ -11,7 +13,7 @@ object FakeGameMode : Module(
description = "Fakes your current gamemode client side",
category = Category.MISC
) {
private val gamemode = setting("Mode", GameMode.CREATIVE)
private val gamemode by setting("Mode", GameMode.CREATIVE)
@Suppress("UNUSED")
private enum class GameMode(val gameType: GameType) {
@ -25,16 +27,19 @@ object FakeGameMode : Module(
init {
safeListener<TickEvent.ClientTickEvent> {
playerController.setGameType(gamemode.value.gameType)
playerController.setGameType(gamemode.gameType)
}
onEnable {
runSafeR {
prevGameMode = playerController.currentGameType
} ?: disable()
}
onDisable {
runSafe {
prevGameMode?.let { playerController.setGameType(it) }
}
}
}
override fun onEnable() {
if (mc.player == null) disable()
else prevGameMode = mc.playerController.currentGameType
}
override fun onDisable() {
if (mc.player != null) prevGameMode?.let { mc.playerController.setGameType(it) }
}
}

View File

@ -8,6 +8,8 @@ import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.text.formatValue
import me.zeroeightsix.kami.util.threads.onMainThreadSafe
import me.zeroeightsix.kami.util.threads.runSafeR
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.gui.GuiGameOver
import org.kamiblue.event.listener.listener
@ -18,8 +20,8 @@ object FakePlayer : Module(
description = "Spawns a client sided fake player",
category = Category.MISC
) {
private val copyInventory = setting("CopyInventory", false)
val playerName = setting("PlayerName", "Player", { false })
private val copyInventory by setting("CopyInventory", false)
val playerName by setting("PlayerName", "Player")
private var fakePlayer: EntityOtherPlayerMP? = null
private const val ENTITY_ID = -7170400
@ -32,34 +34,30 @@ object FakePlayer : Module(
listener<GuiEvent.Displayed> {
if (it.screen is GuiGameOver) disable()
}
}
override fun onEnable() {
if (mc.world == null || mc.player == null) {
disable()
return
onEnable {
runSafeR {
if (playerName == "Player") {
MessageSendHelper.sendChatMessage("You can use " +
formatValue("${CommandManager.prefix}set FakePlayer PlayerName <name>") +
" to set a custom name")
}
fakePlayer = EntityOtherPlayerMP(Companion.mc.world, GameProfile(UUID.randomUUID(), playerName)).apply {
copyLocationAndAnglesFrom(Companion.mc.player)
rotationYawHead = Companion.mc.player.rotationYawHead
if (copyInventory) inventory.copyInventory(Companion.mc.player.inventory)
}.also {
Companion.mc.world.addEntityToWorld(ENTITY_ID, it)
}
} ?: disable()
}
if (playerName.value == "Player") {
MessageSendHelper.sendChatMessage("You can use " +
formatValue("${CommandManager.prefix}set FakePlayer PlayerName <name>") +
" to set a custom name")
}
fakePlayer = EntityOtherPlayerMP(mc.world, GameProfile(UUID.randomUUID(), playerName.value)).apply {
copyLocationAndAnglesFrom(mc.player)
rotationYawHead = mc.player.rotationYawHead
if (copyInventory.value) inventory.copyInventory(mc.player.inventory)
}.also {
mc.world.addEntityToWorld(ENTITY_ID, it)
}
}
override fun onDisable() {
mc.addScheduledTask {
if (mc.world == null || mc.player == null) return@addScheduledTask
fakePlayer?.setDead()
mc.world?.removeEntityFromWorld(-911)
onDisable {
onMainThreadSafe {
fakePlayer?.setDead()
world.removeEntityFromWorld(-911)
}
}
}
}

View File

@ -9,6 +9,7 @@ import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.*
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.runSafeR
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.init.Blocks
import net.minecraft.init.SoundEvents
@ -78,20 +79,19 @@ object NoteBot : Module(
channel13, channel14, channel15, channel16
)
override fun onEnable() {
if (mc.world == null || mc.player == null) {
disable()
return
}
init {
onEnable {
runSafeR {
if (player.isCreative) {
MessageSendHelper.sendChatMessage("You are in creative mode and cannot play music.")
disable()
return@runSafeR
}
if (mc.player.isCreative) {
MessageSendHelper.sendChatMessage("You are in creative mode and cannot play music.")
disable()
return
loadSong()
scanNoteBlocks()
} ?: disable()
}
loadSong()
scanNoteBlocks()
}
private fun loadSong() {

View File

@ -1,19 +1,19 @@
package me.zeroeightsix.kami.module.modules.misc
import me.zeroeightsix.kami.event.events.RenderOverlayEvent
import me.zeroeightsix.kami.event.events.RenderEvent
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.TickTimer
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.entity.player.EnumPlayerModelParts
import org.kamiblue.event.listener.listener
object SkinFlicker : Module(
name = "SkinFlicker",
description = "Toggle your skin layers rapidly for a cool skin effect",
category = Category.MISC
) {
private val mode = setting("Mode", FlickerMode.HORIZONTAL)
private val delay = setting("Delay(ms)", 10, 0..500, 10)
private val mode by setting("Mode", FlickerMode.HORIZONTAL)
private val delay by setting("Delay(ms)", 10, 0..500, 10)
private enum class FlickerMode {
HORIZONTAL, VERTICAL, RANDOM
@ -23,11 +23,10 @@ object SkinFlicker : Module(
private var lastIndex = 0
init {
listener<RenderOverlayEvent> {
if (mc.world == null || mc.player == null) return@listener
if (!timer.tick(delay.value.toLong())) return@listener
safeListener<RenderEvent> {
if (!timer.tick(delay.toLong())) return@safeListener
val part = when (mode.value) {
val part = when (mode) {
FlickerMode.RANDOM -> EnumPlayerModelParts.values().random()
FlickerMode.VERTICAL -> verticalParts[lastIndex]
FlickerMode.HORIZONTAL -> horizontalParts[lastIndex]
@ -35,11 +34,11 @@ object SkinFlicker : Module(
mc.gameSettings.switchModelPartEnabled(part)
lastIndex = (lastIndex + 1) % 7
}
}
override fun onDisable() {
for (model in EnumPlayerModelParts.values()) {
mc.gameSettings.setModelPartEnabled(model, true)
onDisable {
for (model in EnumPlayerModelParts.values()) {
mc.gameSettings.setModelPartEnabled(model, true)
}
}
}
@ -50,7 +49,8 @@ object SkinFlicker : Module(
EnumPlayerModelParts.HAT,
EnumPlayerModelParts.CAPE,
EnumPlayerModelParts.RIGHT_PANTS_LEG,
EnumPlayerModelParts.RIGHT_SLEEVE)
EnumPlayerModelParts.RIGHT_SLEEVE
)
private val verticalParts = arrayOf(
EnumPlayerModelParts.HAT,
@ -59,5 +59,6 @@ object SkinFlicker : Module(
EnumPlayerModelParts.LEFT_SLEEVE,
EnumPlayerModelParts.RIGHT_SLEEVE,
EnumPlayerModelParts.LEFT_PANTS_LEG,
EnumPlayerModelParts.RIGHT_PANTS_LEG)
EnumPlayerModelParts.RIGHT_PANTS_LEG
)
}

View File

@ -24,7 +24,7 @@ object AutoWalk : Module(
description = "Automatically walks somewhere"
) {
val mode = setting("Direction", AutoWalkMode.BARITONE)
private val disableOnDisconnect = setting("DisableOnDisconnect", true)
private val disableOnDisconnect by setting("DisableOnDisconnect", true)
enum class AutoWalkMode {
FORWARD, BACKWARDS, BARITONE
@ -46,11 +46,11 @@ object AutoWalk : Module(
}
}
override fun onDisable() {
if (mc.player != null && mode.value == AutoWalkMode.BARITONE) BaritoneUtils.cancelEverything()
}
init {
onDisable {
if (mode.value == AutoWalkMode.BARITONE) BaritoneUtils.cancelEverything()
}
listener<BaritoneCommandEvent> {
if (it.command.contains("cancel")) {
disable()
@ -58,11 +58,11 @@ object AutoWalk : Module(
}
listener<ConnectionEvent.Disconnect> {
if (disableOnDisconnect.value) disable()
if (disableOnDisconnect) disable()
}
listener<InputUpdateEvent>(6969) {
if (LagNotifier.paused && LagNotifier.pauseAutoWalk.value) return@listener
if (LagNotifier.paused && LagNotifier.pauseAutoWalk) return@listener
if (it.movementInput !is MovementInputFromOptions) return@listener
@ -74,7 +74,7 @@ object AutoWalk : Module(
it.movementInput.moveForward = -1.0f
}
else -> {
// this is fine, Java meme
// Baritone mode
}
}
}

View File

@ -27,6 +27,7 @@ import net.minecraft.network.play.server.SPacketPlayerPosLook
import org.kamiblue.commons.extension.toRadian
import kotlin.math.*
// TODO: Rewrite
object ElytraFlight : Module(
name = "ElytraFlight",
description = "Allows infinite and way easier Elytra flying",
@ -34,61 +35,61 @@ object ElytraFlight : Module(
modulePriority = 1000
) {
private val mode = setting("Mode", ElytraFlightMode.CONTROL)
private val page = setting("Page", Page.GENERIC_SETTINGS)
private val durabilityWarning = setting("DurabilityWarning", true, { page.value == Page.GENERIC_SETTINGS })
private val threshold = setting("Broken%", 5, 1..50, 1, { durabilityWarning.value && page.value == Page.GENERIC_SETTINGS })
private val autoLanding = setting("AutoLanding", false, { page.value == Page.GENERIC_SETTINGS })
private val page by setting("Page", Page.GENERIC_SETTINGS)
private val durabilityWarning by setting("DurabilityWarning", true, { page == Page.GENERIC_SETTINGS })
private val threshold by setting("Broken%", 5, 1..50, 1, { durabilityWarning && page == Page.GENERIC_SETTINGS })
private var autoLanding by setting("AutoLanding", false, { page == Page.GENERIC_SETTINGS })
/* Generic Settings */
/* Takeoff */
private val easyTakeOff = setting("EasyTakeoff", true, { page.value == Page.GENERIC_SETTINGS })
private val timerControl = setting("TakeoffTimer", true, { easyTakeOff.value && page.value == Page.GENERIC_SETTINGS })
private val highPingOptimize = setting("HighPingOptimize", false, { easyTakeOff.value && page.value == Page.GENERIC_SETTINGS })
private val minTakeoffHeight = setting("MinTakeoffHeight", 0.5f, 0.0f..1.5f, 0.1f, { easyTakeOff.value && !highPingOptimize.value && page.value == Page.GENERIC_SETTINGS })
private val easyTakeOff by setting("EasyTakeoff", true, { page == Page.GENERIC_SETTINGS })
private val timerControl by setting("TakeoffTimer", true, { easyTakeOff && page == Page.GENERIC_SETTINGS })
private val highPingOptimize by setting("HighPingOptimize", false, { easyTakeOff && page == Page.GENERIC_SETTINGS })
private val minTakeoffHeight by setting("MinTakeoffHeight", 0.5f, 0.0f..1.5f, 0.1f, { easyTakeOff && !highPingOptimize && page == Page.GENERIC_SETTINGS })
/* Acceleration */
private val accelerateStartSpeed = setting("StartSpeed", 100, 0..100, 5, { mode.value != ElytraFlightMode.BOOST && page.value == Page.GENERIC_SETTINGS })
private val accelerateTime = setting("AccelerateTime", 0.0f, 0.0f..10.0f, 0.25f, { mode.value != ElytraFlightMode.BOOST && page.value == Page.GENERIC_SETTINGS })
private val autoReset = setting("AutoReset", false, { mode.value != ElytraFlightMode.BOOST && page.value == Page.GENERIC_SETTINGS })
private val accelerateStartSpeed by setting("StartSpeed", 100, 0..100, 5, { mode.value != ElytraFlightMode.BOOST && page == Page.GENERIC_SETTINGS })
private val accelerateTime by setting("AccelerateTime", 0.0f, 0.0f..10.0f, 0.25f, { mode.value != ElytraFlightMode.BOOST && page == Page.GENERIC_SETTINGS })
private val autoReset by setting("AutoReset", false, { mode.value != ElytraFlightMode.BOOST && page == Page.GENERIC_SETTINGS })
/* Spoof Pitch */
private val spoofPitch = setting("SpoofPitch", true, { mode.value != ElytraFlightMode.BOOST && page.value == Page.GENERIC_SETTINGS })
private val blockInteract = setting("BlockInteract", false, { spoofPitch.value && mode.value != ElytraFlightMode.BOOST && page.value == Page.GENERIC_SETTINGS })
private val forwardPitch = setting("ForwardPitch", 0, -90..90, 5, { spoofPitch.value && mode.value != ElytraFlightMode.BOOST && page.value == Page.GENERIC_SETTINGS })
private val spoofPitch by setting("SpoofPitch", true, { mode.value != ElytraFlightMode.BOOST && page == Page.GENERIC_SETTINGS })
private val blockInteract by setting("BlockInteract", false, { spoofPitch && mode.value != ElytraFlightMode.BOOST && page == Page.GENERIC_SETTINGS })
private val forwardPitch by setting("ForwardPitch", 0, -90..90, 5, { spoofPitch && mode.value != ElytraFlightMode.BOOST && page == Page.GENERIC_SETTINGS })
/* Extra */
val elytraSounds = setting("ElytraSounds", true, { page.value == Page.GENERIC_SETTINGS })
private val swingSpeed = setting("SwingSpeed", 1.0f, 0.0f..2.0f, 0.1f, { page.value == Page.GENERIC_SETTINGS && (mode.value == ElytraFlightMode.CONTROL || mode.value == ElytraFlightMode.PACKET) })
private val swingAmount = setting("SwingAmount", 0.8f, 0.0f..2.0f, 0.1f, { page.value == Page.GENERIC_SETTINGS && (mode.value == ElytraFlightMode.CONTROL || mode.value == ElytraFlightMode.PACKET) })
val elytraSounds by setting("ElytraSounds", true, { page == Page.GENERIC_SETTINGS })
private val swingSpeed by setting("SwingSpeed", 1.0f, 0.0f..2.0f, 0.1f, { page == Page.GENERIC_SETTINGS && (mode.value == ElytraFlightMode.CONTROL || mode.value == ElytraFlightMode.PACKET) })
private val swingAmount by setting("SwingAmount", 0.8f, 0.0f..2.0f, 0.1f, { page == Page.GENERIC_SETTINGS && (mode.value == ElytraFlightMode.CONTROL || mode.value == ElytraFlightMode.PACKET) })
/* End of Generic Settings */
/* Mode Settings */
/* Boost */
private val speedBoost = setting("SpeedB", 1.0f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page.value == Page.MODE_SETTINGS })
private val upSpeedBoost = setting("UpSpeedB", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page.value == Page.MODE_SETTINGS })
private val downSpeedBoost = setting("DownSpeedB", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page.value == Page.MODE_SETTINGS })
private val speedBoost by setting("SpeedB", 1.0f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS })
private val upSpeedBoost by setting("UpSpeedB", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS })
private val downSpeedBoost by setting("DownSpeedB", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS })
/* Control */
private val boostPitchControl = setting("BaseBoostPitch", 20, 0..90, 5, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val ncpStrict = setting("NCPStrict", true, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val legacyLookBoost = setting("LegacyLookBoost", false, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val altitudeHoldControl = setting("AutoControlAltitude", false, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val dynamicDownSpeed = setting("DynamicDownSpeed", false, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val speedControl = setting("SpeedC", 1.81f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val fallSpeedControl = setting("FallSpeedC", 0.00000000000003f, 0.0f..0.3f, 0.01f, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val downSpeedControl = setting("DownSpeedC", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CONTROL && page.value == Page.MODE_SETTINGS })
private val fastDownSpeedControl = setting("DynamicDownSpeedC", 2.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CONTROL && dynamicDownSpeed.value && page.value == Page.MODE_SETTINGS })
private val boostPitchControl by setting("BaseBoostPitch", 20, 0..90, 5, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val ncpStrict by setting("NCPStrict", true, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val legacyLookBoost by setting("LegacyLookBoost", false, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val altitudeHoldControl by setting("AutoControlAltitude", false, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val dynamicDownSpeed by setting("DynamicDownSpeed", false, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val speedControl by setting("SpeedC", 1.81f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val fallSpeedControl by setting("FallSpeedC", 0.00000000000003f, 0.0f..0.3f, 0.01f, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val downSpeedControl by setting("DownSpeedC", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS })
private val fastDownSpeedControl by setting("DynamicDownSpeedC", 2.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CONTROL && dynamicDownSpeed && page == Page.MODE_SETTINGS })
/* Creative */
private val speedCreative = setting("SpeedCR", 1.8f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.CREATIVE && page.value == Page.MODE_SETTINGS })
private val fallSpeedCreative = setting("FallSpeedCR", 0.00001f, 0.0f..0.3f, 0.01f, { mode.value == ElytraFlightMode.CREATIVE && page.value == Page.MODE_SETTINGS })
private val upSpeedCreative = setting("UpSpeedCR", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CREATIVE && page.value == Page.MODE_SETTINGS })
private val downSpeedCreative = setting("DownSpeedCR", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CREATIVE && page.value == Page.MODE_SETTINGS })
private val speedCreative by setting("SpeedCR", 1.8f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.CREATIVE && page == Page.MODE_SETTINGS })
private val fallSpeedCreative by setting("FallSpeedCR", 0.00001f, 0.0f..0.3f, 0.01f, { mode.value == ElytraFlightMode.CREATIVE && page == Page.MODE_SETTINGS })
private val upSpeedCreative by setting("UpSpeedCR", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CREATIVE && page == Page.MODE_SETTINGS })
private val downSpeedCreative by setting("DownSpeedCR", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.CREATIVE && page == Page.MODE_SETTINGS })
/* Packet */
private val speedPacket = setting("SpeedP", 1.8f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.PACKET && page.value == Page.MODE_SETTINGS })
private val fallSpeedPacket = setting("FallSpeedP", 0.00001f, 0.0f..0.3f, 0.01f, { mode.value == ElytraFlightMode.PACKET && page.value == Page.MODE_SETTINGS })
private val downSpeedPacket = setting("DownSpeedP", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.PACKET && page.value == Page.MODE_SETTINGS })
private val speedPacket by setting("SpeedP", 1.8f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.PACKET && page == Page.MODE_SETTINGS })
private val fallSpeedPacket by setting("FallSpeedP", 0.00001f, 0.0f..0.3f, 0.01f, { mode.value == ElytraFlightMode.PACKET && page == Page.MODE_SETTINGS })
private val downSpeedPacket by setting("DownSpeedP", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.PACKET && page == Page.MODE_SETTINGS })
/* End of Mode Settings */
private enum class ElytraFlightMode {
@ -137,7 +138,7 @@ object ElytraFlight : Module(
if (player.isSpectator) return@safeListener
stateUpdate(it)
if (elytraIsEquipped && elytraDurability > 1) {
if (autoLanding.value) {
if (autoLanding) {
landing(it)
return@safeListener
}
@ -174,12 +175,12 @@ object ElytraFlight : Module(
/* Elytra Durability Warning, runs when player is in the air and durability changed */
if (!player.onGround && oldDurability != elytraDurability) {
if (durabilityWarning.value && elytraDurability > 1 && elytraDurability < threshold.value * armorSlot.maxDamage / 100) {
if (durabilityWarning && elytraDurability > 1 && elytraDurability < threshold * armorSlot.maxDamage / 100) {
mc.soundHandler.playSound(PositionedSoundRecord.getRecord(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f))
sendChatMessage("$chatName Warning: Elytra has " + (elytraDurability - 1) + " durability remaining")
} else if (elytraDurability <= 1 && !outOfDurability) {
outOfDurability = true
if (durabilityWarning.value) {
if (durabilityWarning) {
mc.soundHandler.playSound(PositionedSoundRecord.getRecord(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f))
sendChatMessage("$chatName Elytra is out of durability, holding player in the air")
}
@ -207,14 +208,14 @@ object ElytraFlight : Module(
isStandingStill = isStandingStillH && !player.movementInput.jump && !player.movementInput.sneak
/* Reset acceleration */
if (!isFlying || isStandingStill) speedPercentage = accelerateStartSpeed.value.toFloat()
if (!isFlying || isStandingStill) speedPercentage = accelerateStartSpeed.toFloat()
/* Modify leg swing */
if (shouldSwing()) {
player.prevLimbSwingAmount = player.limbSwingAmount
player.limbSwing += swingSpeed.value
player.limbSwing += swingSpeed
val speedRatio = (player.speed / getSettingSpeed()).toFloat()
player.limbSwingAmount += ((speedRatio * swingAmount.value) - player.limbSwingAmount) * 0.4f
player.limbSwingAmount += ((speedRatio * swingAmount) - player.limbSwingAmount) * 0.4f
}
}
@ -239,14 +240,14 @@ object ElytraFlight : Module(
when {
player.onGround -> {
sendChatMessage("$chatName Landed!")
autoLanding.value = false
autoLanding = false
return
}
isLiquidBelow() -> {
sendChatMessage("$chatName Liquid below, disabling.")
autoLanding.value = false
autoLanding = false
}
LagNotifier.paused && LagNotifier.pauseTakeoff.value -> {
LagNotifier.paused && LagNotifier.pauseTakeoff -> {
holdPlayer(event)
}
player.capabilities.isFlying || !player.isElytraFlying || isPacketFlying -> {
@ -277,27 +278,27 @@ object ElytraFlight : Module(
/* The best takeoff method <3 */
private fun SafeClientEvent.takeoff(event: PlayerTravelEvent) {
/* Pause Takeoff if server is lagging, player is in water/lava, or player is on ground */
val timerSpeed = if (highPingOptimize.value) 400.0f else 200.0f
val height = if (highPingOptimize.value) 0.0f else minTakeoffHeight.value
val timerSpeed = if (highPingOptimize) 400.0f else 200.0f
val height = if (highPingOptimize) 0.0f else minTakeoffHeight
val closeToGround = player.posY <= getGroundPos().y + height && !wasInLiquid && !mc.isSingleplayer
if (!easyTakeOff.value || (LagNotifier.paused && LagNotifier.pauseTakeoff.value) || player.onGround) {
if (LagNotifier.paused && LagNotifier.pauseTakeoff.value && player.posY - getGroundPos().y > 4.0f) holdPlayer(event) /* Holds player in the air if server is lagging and the distance is enough for taking fall damage */
if (!easyTakeOff || (LagNotifier.paused && LagNotifier.pauseTakeoff) || player.onGround) {
if (LagNotifier.paused && LagNotifier.pauseTakeoff && player.posY - getGroundPos().y > 4.0f) holdPlayer(event) /* Holds player in the air if server is lagging and the distance is enough for taking fall damage */
reset(player.onGround)
return
}
if (player.motionY < 0 && !highPingOptimize.value || player.motionY < -0.02) {
if (player.motionY < 0 && !highPingOptimize || player.motionY < -0.02) {
if (closeToGround) {
mc.timer.tickLength = 25.0f
return
}
if (!highPingOptimize.value && !wasInLiquid && !mc.isSingleplayer) { /* Cringe moment when you use elytra flight in single player world */
if (!highPingOptimize && !wasInLiquid && !mc.isSingleplayer) { /* Cringe moment when you use elytra flight in single player world */
event.cancel()
player.setVelocity(0.0, -0.02, 0.0)
}
if (timerControl.value && !mc.isSingleplayer) mc.timer.tickLength = timerSpeed * 2.0f
if (timerControl && !mc.isSingleplayer) mc.timer.tickLength = timerSpeed * 2.0f
connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_FALL_FLYING))
hoverTarget = player.posY + 0.2
} else if (highPingOptimize.value && !closeToGround) {
} else if (highPingOptimize && !closeToGround) {
mc.timer.tickLength = timerSpeed
}
}
@ -320,13 +321,13 @@ object ElytraFlight : Module(
*/
private fun getSpeed(boosting: Boolean): Double {
return when {
boosting -> (if (ncpStrict.value) min(speedControl.value, 2.0f) else speedControl.value).toDouble()
boosting -> (if (ncpStrict) min(speedControl, 2.0f) else speedControl).toDouble()
accelerateTime.value != 0.0f && accelerateStartSpeed.value != 100 -> {
accelerateTime != 0.0f && accelerateStartSpeed != 100 -> {
speedPercentage = when {
mc.gameSettings.keyBindSprint.isKeyDown -> 100.0f
autoReset.value && speedPercentage >= 100.0f -> accelerateStartSpeed.value.toFloat()
else -> min(speedPercentage + (100.0f - accelerateStartSpeed.value.toFloat()) / (accelerateTime.value * 20), 100.0f)
autoReset && speedPercentage >= 100.0f -> accelerateStartSpeed.toFloat()
else -> min(speedPercentage + (100.0f - accelerateStartSpeed.toFloat()) / (accelerateTime * 20), 100.0f)
}
getSettingSpeed() * (speedPercentage / 100.0) * (cos((speedPercentage / 100.0) * PI) * -0.5 + 0.5)
}
@ -337,10 +338,10 @@ object ElytraFlight : Module(
private fun getSettingSpeed(): Float {
return when (mode.value) {
ElytraFlightMode.BOOST -> speedBoost.value
ElytraFlightMode.CONTROL -> speedControl.value
ElytraFlightMode.CREATIVE -> speedCreative.value
ElytraFlightMode.PACKET -> speedPacket.value
ElytraFlightMode.BOOST -> speedBoost
ElytraFlightMode.CONTROL -> speedControl
ElytraFlightMode.CREATIVE -> speedCreative
ElytraFlightMode.PACKET -> speedPacket
}
}
@ -353,38 +354,38 @@ object ElytraFlight : Module(
/* Boost mode */
private fun SafeClientEvent.boostMode() {
val yaw = player.rotationYaw.toDouble().toRadian()
player.motionX -= player.movementInput.moveForward * sin(yaw) * speedBoost.value / 20
if (player.movementInput.jump) player.motionY += upSpeedBoost.value / 15 else if (player.movementInput.sneak) player.motionY -= downSpeedBoost.value / 15
player.motionZ += player.movementInput.moveForward * cos(yaw) * speedBoost.value / 20
player.motionX -= player.movementInput.moveForward * sin(yaw) * speedBoost / 20
if (player.movementInput.jump) player.motionY += upSpeedBoost / 15 else if (player.movementInput.sneak) player.motionY -= downSpeedBoost / 15
player.motionZ += player.movementInput.moveForward * cos(yaw) * speedBoost / 20
}
/* Control Mode */
private fun SafeClientEvent.controlMode(event: PlayerTravelEvent) {
/* States and movement input */
val currentSpeed = sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ)
val moveUp = if (!legacyLookBoost.value) player.movementInput.jump else player.rotationPitch < -10.0f && !isStandingStillH
val moveDown = if (InventoryMove.isEnabled && !InventoryMove.sneak.value && mc.currentScreen != null || moveUp) false else player.movementInput.sneak
val moveUp = if (!legacyLookBoost) player.movementInput.jump else player.rotationPitch < -10.0f && !isStandingStillH
val moveDown = if (InventoryMove.isEnabled && !InventoryMove.sneak && mc.currentScreen != null || moveUp) false else player.movementInput.sneak
/* Dynamic down speed */
val calcDownSpeed = if (dynamicDownSpeed.value) {
val minDownSpeed = min(downSpeedControl.value, fastDownSpeedControl.value).toDouble()
val maxDownSpeed = max(downSpeedControl.value, fastDownSpeedControl.value).toDouble()
val calcDownSpeed = if (dynamicDownSpeed) {
val minDownSpeed = min(downSpeedControl, fastDownSpeedControl).toDouble()
val maxDownSpeed = max(downSpeedControl, fastDownSpeedControl).toDouble()
if (player.rotationPitch > 0) {
player.rotationPitch / 90.0 * (maxDownSpeed - minDownSpeed) + minDownSpeed
} else minDownSpeed
} else downSpeedControl.value.toDouble()
} else downSpeedControl.toDouble()
/* Hover */
if (hoverTarget < 0.0 || moveUp) hoverTarget = player.posY else if (moveDown) hoverTarget = player.posY - calcDownSpeed
hoverState = (if (hoverState) player.posY < hoverTarget else player.posY < hoverTarget - 0.1) && altitudeHoldControl.value
hoverState = (if (hoverState) player.posY < hoverTarget else player.posY < hoverTarget - 0.1) && altitudeHoldControl
/* Set velocity */
if (!isStandingStillH || moveUp) {
if ((moveUp || hoverState) && (currentSpeed >= 0.8 || player.motionY > 1.0)) {
upwardFlight(currentSpeed, getYaw())
} else if (!isStandingStillH || moveUp) { /* Runs when pressing wasd */
packetPitch = forwardPitch.value.toFloat()
player.motionY = -fallSpeedControl.value.toDouble()
packetPitch = forwardPitch.toFloat()
player.motionY = -fallSpeedControl.toDouble()
setSpeed(getYaw(), moveUp)
boostingTick = 0
}
@ -396,13 +397,13 @@ object ElytraFlight : Module(
}
private fun SafeClientEvent.upwardFlight(currentSpeed: Double, yaw: Double) {
val multipliedSpeed = 0.128 * min(speedControl.value, 2.0f)
val multipliedSpeed = 0.128 * min(speedControl, 2.0f)
val strictPitch = Math.toDegrees(asin((multipliedSpeed - sqrt(multipliedSpeed * multipliedSpeed - 0.0348)) / 0.12)).toFloat()
val basePitch = if (ncpStrict.value && strictPitch < boostPitchControl.value && !strictPitch.isNaN()) -strictPitch
else -boostPitchControl.value.toFloat()
val basePitch = if (ncpStrict && strictPitch < boostPitchControl && !strictPitch.isNaN()) -strictPitch
else -boostPitchControl.toFloat()
val targetPitch = if (player.rotationPitch < 0.0f) {
max(player.rotationPitch * (90.0f - boostPitchControl.value.toFloat()) / 90.0f - boostPitchControl.value.toFloat(), -90.0f)
} else -boostPitchControl.value.toFloat()
max(player.rotationPitch * (90.0f - boostPitchControl.toFloat()) / 90.0f - boostPitchControl.toFloat(), -90.0f)
} else -boostPitchControl.toFloat()
packetPitch = if (packetPitch <= basePitch && boostingTick > 2) {
if (packetPitch < targetPitch) packetPitch += 17.0f
@ -437,15 +438,15 @@ object ElytraFlight : Module(
return
}
packetPitch = forwardPitch.value.toFloat()
packetPitch = forwardPitch.toFloat()
player.capabilities.isFlying = true
player.capabilities.flySpeed = getSpeed(false).toFloat()
val motionY = when {
isStandingStill -> 0.0
player.movementInput.jump -> upSpeedCreative.value.toDouble()
player.movementInput.sneak -> -downSpeedCreative.value.toDouble()
else -> -fallSpeedCreative.value.toDouble()
player.movementInput.jump -> upSpeedCreative.toDouble()
player.movementInput.sneak -> -downSpeedCreative.toDouble()
else -> -fallSpeedCreative.toDouble()
}
player.setVelocity(0.0, motionY, 0.0) /* Remove the creative flight acceleration and set the motionY */
}
@ -459,13 +460,13 @@ object ElytraFlight : Module(
if (!isStandingStillH) { /* Runs when pressing wasd */
setSpeed(getYaw(), false)
} else player.setVelocity(0.0, 0.0, 0.0)
player.motionY = (if (player.movementInput.sneak) -downSpeedPacket.value else -fallSpeedPacket.value).toDouble()
player.motionY = (if (player.movementInput.sneak) -downSpeedPacket else -fallSpeedPacket).toDouble()
event.cancel()
}
fun shouldSwing(): Boolean {
return isEnabled && isFlying && !autoLanding.value && (mode.value == ElytraFlightMode.CONTROL || mode.value == ElytraFlightMode.PACKET)
return isEnabled && isFlying && !autoLanding && (mode.value == ElytraFlightMode.CONTROL || mode.value == ElytraFlightMode.PACKET)
}
private fun SafeClientEvent.spoofRotation() {
@ -473,15 +474,15 @@ object ElytraFlight : Module(
val packet = PlayerPacketManager.PlayerPacket(rotating = true)
var rotation = Vec2f(player)
if (autoLanding.value) {
if (autoLanding) {
rotation = Vec2f(rotation.x, -20f)
} else if (mode.value != ElytraFlightMode.BOOST) {
if (!isStandingStill && mode.value != ElytraFlightMode.CREATIVE) rotation = Vec2f(packetYaw, rotation.y)
if (spoofPitch.value) {
if (spoofPitch) {
if (!isStandingStill) rotation = Vec2f(rotation.x, packetPitch)
/* Cancels rotation packets if player is not moving and not clicking */
val cancelRotation = isStandingStill && ((!mc.gameSettings.keyBindUseItem.isKeyDown && !mc.gameSettings.keyBindAttack.isKeyDown && blockInteract.value) || !blockInteract.value)
val cancelRotation = isStandingStill && ((!mc.gameSettings.keyBindUseItem.isKeyDown && !mc.gameSettings.keyBindAttack.isKeyDown && blockInteract) || !blockInteract)
if (cancelRotation) {
packet.rotating = false
}
@ -492,17 +493,17 @@ object ElytraFlight : Module(
PlayerPacketManager.addPacket(this@ElytraFlight, packet)
}
override fun onDisable() {
runSafe { reset(true) }
}
override fun onEnable() {
autoLanding.value = false
speedPercentage = accelerateStartSpeed.value.toFloat() /* For acceleration */
hoverTarget = -1.0 /* For control mode */
}
init {
onEnable {
autoLanding = false
speedPercentage = accelerateStartSpeed.toFloat() /* For acceleration */
hoverTarget = -1.0 /* For control mode */
}
onDisable {
runSafe { reset(true) }
}
/* Reset isFlying states when switching mode */
mode.listeners.add {
runSafe { reset(true) }

View File

@ -8,6 +8,8 @@ import me.zeroeightsix.kami.manager.managers.PlayerPacketManager
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.MovementUtils
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.network.play.client.CPacketPlayer
import net.minecraft.network.play.server.SPacketCloseWindow
import org.kamiblue.event.listener.listener
@ -20,77 +22,77 @@ object Flight : Module(
description = "Makes the player fly",
modulePriority = 500
) {
private val mode = setting("Mode", FlightMode.VANILLA)
private val speed = setting("Speed", 1.0f, 0.0f..10.0f, 0.1f)
private val glideSpeed = setting("GlideSpeed", 0.05, 0.0..0.3, 0.001)
private val mode by setting("Mode", FlightMode.VANILLA)
private val speed by setting("Speed", 1.0f, 0.0f..10.0f, 0.1f)
private val glideSpeed by setting("GlideSpeed", 0.05, 0.0..0.3, 0.001)
private enum class FlightMode {
VANILLA, STATIC, PACKET
}
override fun onDisable() {
mc.player?.capabilities?.apply {
isFlying = false
flySpeed = 0.05f
}
}
init {
listener<PlayerTravelEvent> {
if (mc.player == null) return@listener
onDisable {
runSafe {
player.capabilities?.apply {
isFlying = false
flySpeed = 0.05f
}
}
}
when (mode.value) {
safeListener<PlayerTravelEvent> {
when (mode) {
FlightMode.STATIC -> {
mc.player.capabilities.isFlying = true
mc.player.capabilities.flySpeed = speed.value
player.capabilities.isFlying = true
player.capabilities.flySpeed = speed
mc.player.motionX = 0.0
mc.player.motionY = -glideSpeed.value
mc.player.motionZ = 0.0
player.motionX = 0.0
player.motionY = -glideSpeed
player.motionZ = 0.0
if (mc.gameSettings.keyBindJump.isKeyDown) mc.player.motionY += speed.value / 2.0f
if (mc.gameSettings.keyBindSneak.isKeyDown) mc.player.motionY -= speed.value / 2.0f
if (mc.gameSettings.keyBindJump.isKeyDown) player.motionY += speed / 2.0f
if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY -= speed / 2.0f
}
FlightMode.VANILLA -> {
mc.player.capabilities.isFlying = true
mc.player.capabilities.flySpeed = speed.value / 11.11f
player.capabilities.isFlying = true
player.capabilities.flySpeed = speed / 11.11f
if (glideSpeed.value != 0.0
if (glideSpeed != 0.0
&& !mc.gameSettings.keyBindJump.isKeyDown
&& !mc.gameSettings.keyBindSneak.isKeyDown) mc.player.motionY = -glideSpeed.value
&& !mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = -glideSpeed
}
FlightMode.PACKET -> {
it.cancel()
mc.player.motionY = if (mc.gameSettings.keyBindJump.isKeyDown xor mc.gameSettings.keyBindSneak.isKeyDown) {
player.motionY = if (mc.gameSettings.keyBindJump.isKeyDown xor mc.gameSettings.keyBindSneak.isKeyDown) {
if (mc.gameSettings.keyBindJump.isKeyDown) 0.0622
else -0.0622
} else {
if (MovementUtils.isInputting) {
val yaw = MovementUtils.calcMoveYaw()
mc.player.motionX = -sin(yaw) * 0.2f
mc.player.motionZ = cos(yaw) * 0.2f
player.motionX = -sin(yaw) * 0.2f
player.motionZ = cos(yaw) * 0.2f
}
-glideSpeed.value
-glideSpeed
}
val posX = mc.player.posX + mc.player.motionX
val posY = mc.player.posY + mc.player.motionY
val posZ = mc.player.posZ + mc.player.motionZ
val posX = player.posX + player.motionX
val posY = player.posY + player.motionY
val posZ = player.posZ + player.motionZ
mc.connection?.sendPacket(CPacketPlayer.PositionRotation(posX, posY, posZ, mc.player.rotationYaw, mc.player.rotationPitch, false))
mc.connection?.sendPacket(CPacketPlayer.Position(posX, mc.player.posY - 42069, posZ, true))
connection.sendPacket(CPacketPlayer.PositionRotation(posX, posY, posZ, player.rotationYaw, player.rotationPitch, false))
connection.sendPacket(CPacketPlayer.Position(posX, player.posY - 42069, posZ, true))
}
}
}
listener<OnUpdateWalkingPlayerEvent> {
if (mode.value != FlightMode.PACKET || it.phase != Phase.PRE) return@listener
if (mode != FlightMode.PACKET || it.phase != Phase.PRE) return@listener
PlayerPacketManager.addPacket(this, PlayerPacketManager.PlayerPacket(moving = false, rotating = false))
}
listener<PacketEvent.Receive> {
if (mode.value == FlightMode.PACKET && it.packet is SPacketCloseWindow) it.cancel()
if (mode == FlightMode.PACKET && it.packet is SPacketCloseWindow) it.cancel()
}
}
}

View File

@ -12,19 +12,19 @@ object IceSpeed : Module(
description = "Changes how slippery ice is",
category = Category.MOVEMENT
) {
private val slipperiness = setting("Slipperiness", 0.4f, 0.1f..1.0f, 0.01f)
private val slipperiness by setting("Slipperiness", 0.4f, 0.1f..1.0f, 0.01f)
init {
safeListener<TickEvent.ClientTickEvent> {
Blocks.ICE.slipperiness = slipperiness.value
Blocks.PACKED_ICE.slipperiness = slipperiness.value
Blocks.FROSTED_ICE.slipperiness = slipperiness.value
Blocks.ICE.slipperiness = slipperiness
Blocks.PACKED_ICE.slipperiness = slipperiness
Blocks.FROSTED_ICE.slipperiness = slipperiness
}
onDisable {
Blocks.ICE.slipperiness = 0.98f
Blocks.PACKED_ICE.slipperiness = 0.98f
Blocks.FROSTED_ICE.slipperiness = 0.98f
}
}
override fun onDisable() {
Blocks.ICE.slipperiness = 0.98f
Blocks.PACKED_ICE.slipperiness = 0.98f
Blocks.FROSTED_ICE.slipperiness = 0.98f
}
}

View File

@ -16,8 +16,8 @@ object InventoryMove : Module(
description = "Allows you to walk around with GUIs opened",
category = Category.MOVEMENT
) {
private val rotateSpeed = setting("RotateSpeed", 5, 0..20, 1)
val sneak = setting("Sneak", false)
private val rotateSpeed by setting("RotateSpeed", 5, 0..20, 1)
val sneak by setting("Sneak", false)
private var hasSent = false
@ -26,18 +26,18 @@ object InventoryMove : Module(
if (it.movementInput !is MovementInputFromOptions || checkGui()) return@listener
if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
mc.player.rotationYaw = mc.player.rotationYaw - rotateSpeed.value
mc.player.rotationYaw = mc.player.rotationYaw - rotateSpeed
}
if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
mc.player.rotationYaw = mc.player.rotationYaw + rotateSpeed.value
mc.player.rotationYaw = mc.player.rotationYaw + rotateSpeed
}
// pitch can not exceed 90 degrees nor -90 degrees, otherwise AAC servers will flag this and kick you.
if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
mc.player.rotationPitch = (mc.player.rotationPitch - rotateSpeed.value).coerceAtLeast(-90.0f)
mc.player.rotationPitch = (mc.player.rotationPitch - rotateSpeed).coerceAtLeast(-90.0f)
}
if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
mc.player.rotationPitch = (mc.player.rotationPitch + rotateSpeed.value).coerceAtMost(90.0f)
mc.player.rotationPitch = (mc.player.rotationPitch + rotateSpeed).coerceAtMost(90.0f)
}
it.movementInput.moveStrafe = 0.0f
@ -76,7 +76,7 @@ object InventoryMove : Module(
it.movementInput.jump = true
}
if (Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.keyCode) && sneak.value) {
if (Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.keyCode) && sneak) {
it.movementInput.sneak = true
}
} catch (e: IndexOutOfBoundsException) {

View File

@ -29,11 +29,11 @@ object Jesus : Module(
private val WATER_WALK_AA = AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.99, 1.0)
override fun onToggle() {
BaritoneUtils.settings?.assumeWalkOnWater?.value = isEnabled
}
init {
onToggle {
BaritoneUtils.settings?.assumeWalkOnWater?.value = isEnabled
}
safeListener<TickEvent.ClientTickEvent> {
if (isInWater(player) && !player.isSneaking) {
if (dolphin.value) {

View File

@ -1,11 +1,12 @@
package me.zeroeightsix.kami.module.modules.movement
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.mixin.client.world.MixinBlockSoulSand
import me.zeroeightsix.kami.mixin.client.world.MixinBlockWeb
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.math.VectorUtils.toBlockPos
import me.zeroeightsix.kami.util.EntityUtils.flooredPosition
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.init.Blocks
import net.minecraft.item.*
@ -15,7 +16,6 @@ import net.minecraft.network.play.client.CPacketPlayerDigging.Action
import net.minecraft.util.EnumFacing
import net.minecraftforge.client.event.InputUpdateEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener
/**
* @see MixinBlockSoulSand
@ -26,24 +26,24 @@ object NoSlowDown : Module(
category = Category.MOVEMENT,
description = "Prevents being slowed down when using an item or going through cobwebs"
) {
private val ncpStrict = setting("NCPStrict", true)
private val sneak = setting("Sneak", true)
val soulSand = setting("SoulSand", true)
val cobweb = setting("Cobweb", true)
private val slime = setting("Slime", true)
private val allItems = setting("AllItems", false)
private val food = setting("Food", true, { !allItems.value })
private val bow = setting("Bows", true, { !allItems.value })
private val potion = setting("Potions", true, { !allItems.value })
private val shield = setting("Shield", true, { !allItems.value })
private val ncpStrict by setting("NCPStrict", true)
private val sneak by setting("Sneak", true)
val soulSand by setting("SoulSand", true)
val cobweb by setting("Cobweb", true)
private val slime by setting("Slime", true)
private val allItems by setting("AllItems", false)
private val food by setting("Food", true, { !allItems })
private val bow by setting("Bows", true, { !allItems })
private val potion by setting("Potions", true, { !allItems })
private val shield by setting("Shield", true, { !allItems })
/*
* InputUpdateEvent is called just before the player is slowed down @see EntityPlayerSP.onLivingUpdate)
* We'll abuse this fact, and multiply moveStrafe and moveForward by 5 to nullify the *0.2f hardcoded by Mojang.
*/
init {
listener<InputUpdateEvent> {
if ((passItemCheck(mc.player.activeItemStack.getItem()) || (mc.player.isSneaking && sneak.value)) && !mc.player.isRiding) {
safeListener<InputUpdateEvent> {
if ((passItemCheck(mc.player.activeItemStack.item) || (mc.player.isSneaking && sneak)) && !mc.player.isRiding) {
it.movementInput.moveStrafe *= 5f
it.movementInput.moveForward *= 5f
}
@ -54,30 +54,30 @@ object NoSlowDown : Module(
* Used with explicit permission and MIT license permission
* https://github.com/ionar2/salhack/blob/163f86e/src/main/java/me/ionar/salhack/module/movement/NoSlowModule.java#L175
*/
listener<PacketEvent.PostSend> {
if (ncpStrict.value && it.packet is CPacketPlayer && passItemCheck(mc.player.activeItemStack.getItem()) && !mc.player.isRiding) {
mc.player.connection.sendPacket(CPacketPlayerDigging(Action.ABORT_DESTROY_BLOCK, mc.player.positionVector.toBlockPos(), EnumFacing.DOWN))
safeListener<PacketEvent.PostSend> {
if (ncpStrict && it.packet is CPacketPlayer && passItemCheck(mc.player.activeItemStack.item) && !mc.player.isRiding) {
mc.player.connection.sendPacket(CPacketPlayerDigging(Action.ABORT_DESTROY_BLOCK, mc.player.flooredPosition, EnumFacing.DOWN))
}
}
safeListener<TickEvent.ClientTickEvent> {
@Suppress("DEPRECATION")
if (slime.value) Blocks.SLIME_BLOCK.slipperiness = 0.4945f // normal block speed 0.4945
if (slime) Blocks.SLIME_BLOCK.slipperiness = 0.4945f // normal block speed 0.4945
else Blocks.SLIME_BLOCK.slipperiness = 0.8f
}
onDisable {
@Suppress("DEPRECATION")
Blocks.SLIME_BLOCK.slipperiness = 0.8f
}
}
override fun onDisable() {
@Suppress("DEPRECATION")
Blocks.SLIME_BLOCK.slipperiness = 0.8f
}
private fun passItemCheck(item: Item): Boolean {
return if (!mc.player.isHandActive) false
else allItems.value
|| food.value && item is ItemFood
|| bow.value && item is ItemBow
|| potion.value && item is ItemPotion
|| shield.value && item is ItemShield
private fun SafeClientEvent.passItemCheck(item: Item): Boolean {
return if (!player.isHandActive) false
else allItems
|| food && item is ItemFood
|| bow && item is ItemBow
|| potion && item is ItemPotion
|| shield && item is ItemShield
}
}

View File

@ -1,5 +1,6 @@
package me.zeroeightsix.kami.module.modules.movement
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.manager.managers.PlayerPacketManager
import me.zeroeightsix.kami.mixin.extension.y
@ -9,6 +10,7 @@ import me.zeroeightsix.kami.setting.settings.impl.primitive.BooleanSetting
import me.zeroeightsix.kami.util.BaritoneUtils
import me.zeroeightsix.kami.util.Bind
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.network.play.client.CPacketPlayer
import net.minecraftforge.fml.common.gameevent.InputEvent
@ -26,17 +28,17 @@ object Step : Module(
category = Category.MOVEMENT,
modulePriority = 200
) {
private val mode = setting("Mode", Mode.PACKET)
private val mode by setting("Mode", Mode.PACKET)
private val upStep = setting("UpStep", true)
private val downStep = setting("DownStep", false)
private val entityStep = setting("Entities", true)
private val height = setting("Height", 1.0f, 0.25f..2.0f, 0.25f)
private val downSpeed = setting("DownSpeed", 0.2f, 0.0f..1.0f, 0.05f)
private val bindUpStep = setting("BindUpStep", Bind())
private val bindDownStep = setting("BindDownStep", Bind())
private val entityStep by setting("Entities", true)
private val height by setting("Height", 1.0f, 0.25f..2.0f, 0.25f)
private val downSpeed by setting("DownSpeed", 0.2f, 0.0f..1.0f, 0.05f)
private val bindUpStep by setting("BindUpStep", Bind())
private val bindDownStep by setting("BindDownStep", Bind())
private const val defaultHeight = 0.6f
private val shouldRunStep get() = !mc.player.isElytraFlying && !mc.player.capabilities.isFlying && !mc.player.isOnLadder && !mc.player.isInWater && !mc.player.isInLava
private val SafeClientEvent.shouldRunStep get() = !player.isElytraFlying && !player.capabilities.isFlying && !player.isOnLadder && !player.isInWater && !player.isInLava
private val ignoredPackets = HashSet<CPacketPlayer>()
private var lastCollidedTick = 0
@ -47,26 +49,30 @@ object Step : Module(
VANILLA, PACKET
}
override fun onDisable() {
mc.player?.let {
it.stepHeight = defaultHeight
it.ridingEntity?.stepHeight = 1.0f
}
ignoredPackets.clear()
}
override fun onToggle() {
BaritoneUtils.settings?.assumeStep?.value = isEnabled
}
init {
onDisable {
runSafe {
player.apply {
stepHeight = defaultHeight
ridingEntity?.stepHeight = 1.0f
}
}
ignoredPackets.clear()
}
onToggle {
BaritoneUtils.settings?.assumeStep?.value = isEnabled
}
listener<InputEvent.KeyInputEvent> {
if (bindUpStep.value.isDown(Keyboard.getEventKey())) {
val key = Keyboard.getEventKey()
if (bindUpStep.isDown(key)) {
upStep.value = !upStep.value
MessageSendHelper.sendChatMessage(upStep.toggleMsg())
}
if (bindDownStep.value.isDown(Keyboard.getEventKey())) {
if (bindDownStep.isDown(key)) {
downStep.value = !downStep.value
MessageSendHelper.sendChatMessage(downStep.toggleMsg())
}
@ -85,40 +91,40 @@ object Step : Module(
}
}
private fun setStepHeight() {
mc.player.stepHeight = if (upStep.value && mc.player.onGround && mc.player.collidedHorizontally) height.value else defaultHeight
mc.player.ridingEntity?.let {
it.stepHeight = if (entityStep.value && it.collidedHorizontally) height.value else 1.0f
private fun SafeClientEvent.setStepHeight() {
player.stepHeight = if (upStep.value && player.onGround && player.collidedHorizontally) height else defaultHeight
player.ridingEntity?.let {
it.stepHeight = if (entityStep && it.collidedHorizontally) height else 1.0f
}
}
private fun downStep() {
private fun SafeClientEvent.downStep() {
// Down step doesn't work for edge lower than 1 blocks anyways
val belowBB = mc.player.entityBoundingBox.expand(0.0, -1.05, 0.0)
if (mc.world.collidesWithAnyBlock(belowBB)) mc.player.motionY -= downSpeed.value
val belowBB = player.entityBoundingBox.expand(0.0, -1.05, 0.0)
if (world.collidesWithAnyBlock(belowBB)) player.motionY -= downSpeed
}
init {
listener<PacketEvent.Send> { event ->
if (mc.player == null || !upStep.value || mode.value != Mode.PACKET || !shouldRunStep) return@listener
if (event.packet !is CPacketPlayer || event.packet !is CPacketPlayer.Position && event.packet !is CPacketPlayer.PositionRotation) return@listener
if (ignoredPackets.remove(event.packet)) return@listener
safeListener<PacketEvent.Send> { event ->
if (!upStep.value || mode != Mode.PACKET || !shouldRunStep) return@safeListener
if (event.packet !is CPacketPlayer || event.packet !is CPacketPlayer.Position && event.packet !is CPacketPlayer.PositionRotation) return@safeListener
if (ignoredPackets.remove(event.packet)) return@safeListener
val prevPos = PlayerPacketManager.prevServerSidePosition
if (mc.player.ticksExisted - lastCollidedTick <= 5) getStepArray(event.packet.y - prevPos.y)?.let {
if (player.ticksExisted - lastCollidedTick <= 5) getStepArray(event.packet.y - prevPos.y)?.let {
for (posY in it) {
val packet = CPacketPlayer.Position(prevPos.x, prevPos.y + posY, prevPos.z, true)
ignoredPackets.add(packet)
mc.connection?.sendPacket(packet)
connection.sendPacket(packet)
}
}
}
}
private fun getStepArray(diff: Double) = when {
height.value >= diff && diff in 0.6..1.0 -> stepOne
height.value >= diff && diff in 1.0..1.5 -> stepOneHalf
height.value >= diff && diff in 1.5..2.0 -> stepTwo
height >= diff && diff in 0.6..1.0 -> stepOne
height >= diff && diff in 1.0..1.5 -> stepOneHalf
height >= diff && diff in 1.5..2.0 -> stepTwo
else -> null
}

View File

@ -19,29 +19,29 @@ object Strafe : Module(
category = Category.MOVEMENT,
description = "Improves control in air"
) {
private val airSpeedBoost = setting("AirSpeedBoost", true)
private val timerBoost = setting("TimerBoost", false)
private val autoJump = setting("AutoJump", false)
private val onHolding = setting("OnHoldingSprint", false)
private val airSpeedBoost by setting("AirSpeedBoost", true)
private val timerBoost by setting("TimerBoost", true)
private val autoJump by setting("AutoJump", true)
private val onHolding by setting("OnHoldingSprint", false)
private var jumpTicks = 0
override fun onDisable() {
reset()
}
/* If you skid this you omega gay */
init {
onDisable {
reset()
}
safeListener<TickEvent.ClientTickEvent> {
if (!shouldStrafe()) {
reset()
return@safeListener
}
MovementUtils.setSpeed(player.speed)
if (airSpeedBoost.value) player.jumpMovementFactor = 0.029f
if (timerBoost.value) mc.timer.tickLength = 45.87155914306640625f
if (airSpeedBoost) player.jumpMovementFactor = 0.029f
if (timerBoost) mc.timer.tickLength = 45.87155914306640625f
if (autoJump.value && player.onGround && jumpTicks <= 0) {
if (autoJump && player.onGround && jumpTicks <= 0) {
KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.keyCode, false)
player.motionY = 0.41
if (player.isSprinting) {
@ -59,11 +59,11 @@ object Strafe : Module(
private fun SafeClientEvent.shouldStrafe() = !BaritoneUtils.isPathing
&& !player.capabilities.isFlying
&& !player.isElytraFlying
&& (mc.gameSettings.keyBindSprint.isKeyDown || !onHolding.value)
&& (mc.gameSettings.keyBindSprint.isKeyDown || !onHolding)
&& (player.moveForward != 0f || player.moveStrafing != 0f)
private fun reset() {
mc.player.jumpMovementFactor = 0.02F
mc.player?.jumpMovementFactor = 0.02F
mc.timer.tickLength = 50F
jumpTicks = 0
}

View File

@ -35,12 +35,12 @@ object AutoEat : Module(
private var lastSlot = -1
var eating = false; private set
override fun onDisable() {
unpause()
eating = false
}
init {
onDisable {
unpause()
eating = false
}
safeListener<TickEvent.ClientTickEvent> {
if (CombatSetting.isActive()) return@safeListener

View File

@ -1,5 +1,6 @@
package me.zeroeightsix.kami.module.modules.player
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.ConnectionEvent
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.mixin.extension.x
@ -7,6 +8,7 @@ import me.zeroeightsix.kami.mixin.extension.y
import me.zeroeightsix.kami.mixin.extension.z
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.network.play.client.CPacketPlayer
@ -19,9 +21,9 @@ object Blink : Module(
category = Category.PLAYER,
description = "Cancels server side packets"
) {
private val cancelPacket = setting("CancelPackets", false)
private val autoReset = setting("AutoReset", true)
private val resetThreshold = setting("ResetThreshold", 20, 1..100, 5, { autoReset.value })
private val cancelPacket by setting("CancelPackets", false)
private val autoReset by setting("AutoReset", true)
private val resetThreshold by setting("ResetThreshold", 20, 1..100, 5, { autoReset })
private const val ENTITY_ID = -114514
private val packets = ArrayDeque<CPacketPlayer>()
@ -29,6 +31,16 @@ object Blink : Module(
private var sending = false
init {
onEnable {
runSafe {
begin()
}
}
onDisable {
end()
}
listener<PacketEvent.Send> {
if (!sending && it.packet is CPacketPlayer) {
it.cancel()
@ -38,7 +50,7 @@ object Blink : Module(
safeListener<TickEvent.ClientTickEvent> {
if (it.phase != TickEvent.Phase.END) return@safeListener
if (autoReset.value && packets.size >= resetThreshold.value) {
if (autoReset && packets.size >= resetThreshold) {
end()
begin()
}
@ -52,16 +64,7 @@ object Blink : Module(
}
}
override fun onEnable() {
begin()
}
override fun onDisable() {
end()
}
private fun begin() {
if (mc.player == null) return
private fun SafeClientEvent.begin() {
clonedPlayer = EntityOtherPlayerMP(mc.world, mc.session.profile).apply {
copyLocationAndAnglesFrom(mc.player)
rotationYawHead = mc.player.rotationYawHead
@ -74,22 +77,22 @@ object Blink : Module(
private fun end() {
mc.addScheduledTask {
val player = mc.player
val connection = mc.connection
if (player == null || connection == null) return@addScheduledTask
runSafe {
if (cancelPacket) {
packets.peek()?.let { player.setPosition(it.x, it.y, it.z) }
packets.clear()
} else {
sending = true
while (packets.isNotEmpty()) connection.sendPacket(packets.poll())
sending = false
}
if (cancelPacket.value || mc.connection == null) {
packets.peek()?.let { player.setPosition(it.x, it.y, it.z) }
packets.clear()
} else {
sending = true
while (packets.isNotEmpty()) connection.sendPacket(packets.poll())
sending = false
clonedPlayer?.setDead()
world.removeEntityFromWorld(ENTITY_ID)
clonedPlayer = null
}
clonedPlayer?.setDead()
mc.world?.removeEntityFromWorld(ENTITY_ID)
clonedPlayer = null
packets.clear()
}
}

View File

@ -4,32 +4,32 @@ import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.network.play.server.SPacketDisconnect
import net.minecraft.network.play.server.SPacketRespawn
import net.minecraft.util.text.TextComponentString
import org.kamiblue.event.listener.listener
object EndTeleport : Module(
name = "EndTeleport",
category = Category.PLAYER,
description = "Allows for teleportation when going through end portals"
) {
private val confirmed = setting("Confirm", false)
override fun onEnable() {
if (mc.getCurrentServerData() == null) {
MessageSendHelper.sendWarningMessage("$chatName This module does not work in singleplayer")
disable()
} else if (!confirmed.value) {
MessageSendHelper.sendWarningMessage("$chatName This module will kick you from the server! It is part of the exploit and cannot be avoided")
}
}
private val confirmed by setting("Confirm", false)
init {
listener<PacketEvent.Receive> {
if (it.packet !is SPacketRespawn) return@listener
if (it.packet.dimensionID == 1 && confirmed.value) {
mc.connection!!.handleDisconnect(SPacketDisconnect(TextComponentString("Attempting teleportation exploit")))
onEnable {
if (mc.currentServerData == null) {
MessageSendHelper.sendWarningMessage("$chatName This module does not work in singleplayer")
disable()
} else if (!confirmed) {
MessageSendHelper.sendWarningMessage("$chatName This module will kick you from the server! It is part of the exploit and cannot be avoided")
}
}
safeListener<PacketEvent.Receive> {
if (it.packet !is SPacketRespawn) return@safeListener
if (it.packet.dimensionID == 1 && confirmed) {
connection.handleDisconnect(SPacketDisconnect(TextComponentString("Attempting teleportation exploit")))
disable()
}
}

View File

@ -1,6 +1,7 @@
package me.zeroeightsix.kami.module.modules.player
import baritone.api.pathing.goals.GoalTwoBlocks
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.ConnectionEvent
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.event.events.PlayerAttackEvent
@ -9,6 +10,7 @@ import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.*
import me.zeroeightsix.kami.util.math.RotationUtils
import me.zeroeightsix.kami.util.math.VectorUtils.toBlockPos
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.entity.EntityPlayerSP
@ -56,35 +58,35 @@ object Freecam : Module(
private const val ENTITY_ID = -6969420
override fun onDisable() {
mc.renderChunksMany = true
resetCameraGuy()
resetMovementInput(mc.player?.movementInput)
}
override fun onEnable() {
mc.renderChunksMany = false
}
init {
onEnable {
mc.renderChunksMany = false
}
onDisable {
mc.renderChunksMany = true
resetCameraGuy()
resetMovementInput(mc.player?.movementInput)
}
listener<ConnectionEvent.Disconnect> {
prevThirdPersonViewSetting = -1
if (disableOnDisconnect.value) disable()
else cameraGuy = null
}
listener<PacketEvent.Send> {
if (mc.world == null || it.packet !is CPacketUseEntity) return@listener
safeListener<PacketEvent.Send> {
if (it.packet !is CPacketUseEntity) return@safeListener
// Don't interact with self
if (it.packet.getEntityFromWorld(mc.world) == mc.player) it.cancel()
if (it.packet.getEntityFromWorld(world) == player) it.cancel()
}
listener<PlayerAttackEvent> {
if (it.entity == mc.player) it.cancel()
}
listener<InputEvent.KeyInputEvent> {
if (mc.world == null || mc.player == null) return@listener
safeListener<InputEvent.KeyInputEvent> {
if (mc.world == null || mc.player == null) return@safeListener
// Force it to stay in first person lol
if (mc.gameSettings.keyBindTogglePerspective.isKeyDown) mc.gameSettings.thirdPersonView = 2
}
@ -100,8 +102,8 @@ object Freecam : Module(
if (cameraGuy == null && player.ticksExisted > 20) spawnCameraGuy()
}
listener<InputUpdateEvent>(9999) {
if (it.movementInput !is MovementInputFromOptions || BaritoneUtils.isPathing || BaritoneUtils.isActive) return@listener
safeListener<InputUpdateEvent>(9999) {
if (it.movementInput !is MovementInputFromOptions || BaritoneUtils.isPathing || BaritoneUtils.isActive) return@safeListener
resetMovementInput(it.movementInput)
if (autoRotate.value) updatePlayerRotation()
@ -154,52 +156,51 @@ object Freecam : Module(
}
}
private fun updatePlayerRotation() {
private fun SafeClientEvent.updatePlayerRotation() {
mc.objectMouseOver?.let {
val hitVec = it.hitVec
if (it.typeOfHit == RayTraceResult.Type.MISS || hitVec == null) return
val rotation = RotationUtils.getRotationTo(hitVec)
mc.player?.apply {
player.apply {
rotationYaw = rotation.x
rotationPitch = rotation.y
}
}
}
private fun updatePlayerMovement() {
mc.player?.let { player ->
cameraGuy?.let {
val forward = Keyboard.isKeyDown(Keyboard.KEY_UP) to Keyboard.isKeyDown(Keyboard.KEY_DOWN)
val strafe = Keyboard.isKeyDown(Keyboard.KEY_LEFT) to Keyboard.isKeyDown(Keyboard.KEY_RIGHT)
val movementInput = calcMovementInput(forward, strafe, false to false)
private fun SafeClientEvent.updatePlayerMovement() {
cameraGuy?.let {
val forward = Keyboard.isKeyDown(Keyboard.KEY_UP) to Keyboard.isKeyDown(Keyboard.KEY_DOWN)
val strafe = Keyboard.isKeyDown(Keyboard.KEY_LEFT) to Keyboard.isKeyDown(Keyboard.KEY_RIGHT)
val movementInput = calcMovementInput(forward, strafe, false to false)
val yawDiff = player.rotationYaw - it.rotationYaw
val yawRad = MovementUtils.calcMoveYaw(yawDiff, movementInput.first, movementInput.second).toFloat()
val inputTotal = min(abs(movementInput.first) + abs(movementInput.second), 1f)
val yawDiff = player.rotationYaw - it.rotationYaw
val yawRad = MovementUtils.calcMoveYaw(yawDiff, movementInput.first, movementInput.second).toFloat()
val inputTotal = min(abs(movementInput.first) + abs(movementInput.second), 1f)
player.movementInput?.apply {
moveForward = cos(yawRad) * inputTotal
moveStrafe = sin(yawRad) * inputTotal
player.movementInput?.apply {
moveForward = cos(yawRad) * inputTotal
moveStrafe = sin(yawRad) * inputTotal
forwardKeyDown = moveForward > 0f
backKeyDown = moveForward < 0f
leftKeyDown = moveStrafe < 0f
rightKeyDown = moveStrafe > 0f
forwardKeyDown = moveForward > 0f
backKeyDown = moveForward < 0f
leftKeyDown = moveStrafe < 0f
rightKeyDown = moveStrafe > 0f
jump = Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)
}
jump = Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)
}
}
}
private fun resetCameraGuy() {
mc.addScheduledTask {
if (mc.player == null) return@addScheduledTask
mc.world?.removeEntityFromWorld(ENTITY_ID)
mc.renderViewEntity = mc.player
cameraGuy = null
mc.renderGlobal.loadRenderers()
if (prevThirdPersonViewSetting != -1) mc.gameSettings.thirdPersonView = prevThirdPersonViewSetting
runSafe {
world.removeEntityFromWorld(ENTITY_ID)
mc.renderViewEntity = player
cameraGuy = null
mc.renderGlobal.loadRenderers()
if (prevThirdPersonViewSetting != -1) mc.gameSettings.thirdPersonView = prevThirdPersonViewSetting
}
}
}

View File

@ -52,12 +52,12 @@ object InventoryManager : Module(
return isEnabled && currentState != State.IDLE
}
override fun onToggle() {
paused = false
BaritoneUtils.unpause()
}
init {
onToggle {
paused = false
BaritoneUtils.unpause()
}
listener<PlayerTravelEvent> {
if (mc.player == null || mc.player.isSpectator || !pauseMovement.value || !paused) return@listener
mc.player.setVelocity(0.0, mc.player.motionY, 0.0)

View File

@ -28,24 +28,24 @@ object LagNotifier : Module(
description = "Displays a warning when the server is lagging",
category = Category.PLAYER
) {
private val detectRubberBand = setting("DetectRubberBand", true)
private val pauseBaritone = setting("PauseBaritone", true)
val pauseTakeoff = setting("PauseElytraTakeoff", true)
val pauseAutoWalk = setting("PauseAutoWalk", true)
private val feedback = setting("PauseFeedback", true, { pauseBaritone.value })
private val timeout = setting("Timeout", 3.5f, 0.0f..10.0f, 0.5f)
private val detectRubberBand by setting("DetectRubberBand", true)
private val pauseBaritone by setting("PauseBaritone", true)
val pauseTakeoff by setting("PauseElytraTakeoff", true)
val pauseAutoWalk by setting("PauseAutoWalk", true)
private val feedback by setting("PauseFeedback", true, { pauseBaritone })
private val timeout by setting("Timeout", 3.5f, 0.0f..10.0f, 0.5f)
private val pingTimer = TickTimer(TimeUnit.SECONDS)
private var lastPacketTimer = TickTimer()
private var lastRubberBandTimer = TickTimer()
private var text = ""
var paused = false
override fun onDisable() {
unpause()
}
var paused = false; private set
init {
onDisable {
unpause()
}
listener<RenderOverlayEvent> {
if (text.isBlank()) return@listener
@ -63,7 +63,7 @@ object LagNotifier : Module(
if (mc.isIntegratedServerRunning) unpause()
text = ""
} else {
val timeoutMillis = (timeout.value * 1000.0f).toLong()
val timeoutMillis = (timeout * 1000.0f).toLong()
when {
lastPacketTimer.tick(timeoutMillis, false) -> {
if (pingTimer.tick(1L)) WebUtils.update()
@ -71,7 +71,7 @@ object LagNotifier : Module(
text += timeDifference(lastPacketTimer.time)
pause()
}
detectRubberBand.value && !lastRubberBandTimer.tick(timeoutMillis, false) -> {
detectRubberBand && !lastRubberBandTimer.tick(timeoutMillis, false) -> {
text = "RubberBand Detected! ${timeDifference(lastRubberBandTimer.time)}"
pause()
}
@ -83,13 +83,13 @@ object LagNotifier : Module(
}
}
listener<PacketEvent.Receive>(2000) {
safeListener<PacketEvent.Receive>(2000) {
lastPacketTimer.reset()
if (!detectRubberBand.value || mc.player == null || it.packet !is SPacketPlayerPosLook) return@listener
if (!detectRubberBand || it.packet !is SPacketPlayerPosLook) return@safeListener
val dist = Vec3d(it.packet.x, it.packet.y, it.packet.z).subtract(mc.player.positionVector).length()
val rotationDiff = Vec2f(it.packet.yaw, it.packet.pitch).minus(Vec2f(mc.player)).length()
val dist = Vec3d(it.packet.x, it.packet.y, it.packet.z).subtract(player.positionVector).length()
val rotationDiff = Vec2f(it.packet.yaw, it.packet.pitch).minus(Vec2f(player)).length()
if (dist in 0.5..64.0 || rotationDiff > 1.0) lastRubberBandTimer.reset()
}
@ -101,16 +101,16 @@ object LagNotifier : Module(
}
private fun pause() {
if (pauseBaritone.value && !paused) {
if (feedback.value) MessageSendHelper.sendBaritoneMessage("Paused due to lag!")
if (pauseBaritone && !paused) {
if (feedback) MessageSendHelper.sendBaritoneMessage("Paused due to lag!")
BaritoneUtils.pause()
}
if (pauseTakeoff.value || pauseAutoWalk.value) paused = true
if (pauseTakeoff || pauseAutoWalk) paused = true
}
private fun unpause() {
if (BaritoneUtils.paused && paused) {
if (feedback.value) MessageSendHelper.sendBaritoneMessage("Unpaused!")
if (feedback) MessageSendHelper.sendBaritoneMessage("Unpaused!")
BaritoneUtils.unpause()
}
paused = false

View File

@ -11,36 +11,35 @@ object PacketCancel : Module(
description = "Cancels specific packets used for various actions",
category = Category.PLAYER
) {
private val all = setting("All", false)
private val packetInput = setting("CPacketInput", true, { !all.value })
private val packetPlayer = setting("CPacketPlayer", true, { !all.value })
private val packetEntityAction = setting("CPacketEntityAction", true, { !all.value })
private val packetUseEntity = setting("CPacketUseEntity", true, { !all.value })
private val packetVehicleMove = setting("CPacketVehicleMove", true, { !all.value })
private val all by setting("All", false)
private val packetInput by setting("CPacketInput", true, { !all })
private val packetPlayer by setting("CPacketPlayer", true, { !all })
private val packetEntityAction by setting("CPacketEntityAction", true, { !all })
private val packetUseEntity by setting("CPacketUseEntity", true, { !all })
private val packetVehicleMove by setting("CPacketVehicleMove", true, { !all })
private var numPackets = 0
override fun getHudInfo(): String {
return numPackets.toString()
}
init {
listener<PacketEvent.Send> {
if (mc.player == null) return@listener
if (all.value
|| it.packet is CPacketInput && packetInput.value
|| it.packet is CPacketPlayer && packetPlayer.value
|| it.packet is CPacketEntityAction && packetEntityAction.value
|| it.packet is CPacketUseEntity && packetUseEntity.value
|| it.packet is CPacketVehicleMove && packetVehicleMove.value
if (all
|| it.packet is CPacketInput && packetInput
|| it.packet is CPacketPlayer && packetPlayer
|| it.packet is CPacketEntityAction && packetEntityAction
|| it.packet is CPacketUseEntity && packetUseEntity
|| it.packet is CPacketVehicleMove && packetVehicleMove
) {
it.cancel()
numPackets++
}
}
}
public override fun onDisable() {
numPackets = 0
}
override fun getHudInfo(): String {
return numPackets.toString()
onDisable {
numPackets = 0
}
}
}

View File

@ -1,5 +1,7 @@
package me.zeroeightsix.kami.module.modules.player
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import me.zeroeightsix.kami.KamiMod
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.mixin.extension.pitch
@ -7,13 +9,12 @@ import me.zeroeightsix.kami.mixin.extension.yaw
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.defaultScope
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.network.play.client.CPacketPlayer
import net.minecraft.network.play.client.CPacketPlayerDigging
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener
import java.io.*
import java.nio.charset.StandardCharsets
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
@ -22,28 +23,23 @@ object PacketLogger : Module(
description = "Logs sent packets to a file",
category = Category.PLAYER
) {
private val append = setting("Append", false)
private val append by setting("Append", false)
private val clear = setting("Clear", false)
private const val filename = "KAMIBluePackets.txt"
private val lines = ArrayList<String>()
private val file = File("${KamiMod.DIRECTORY}packet_logger.txt")
private val lines = Collections.synchronizedList(ArrayList<String>())
private val sdf = SimpleDateFormat("HH:mm:ss.SSS")
override fun onEnable() {
if (mc.player == null) disable() else if (append.value) readToList()
}
override fun onDisable() {
if (mc.player != null) write()
}
init {
listener<PacketEvent.Send> {
if (mc.player == null) {
disable()
return@listener
}
onEnable {
if (append) read()
}
onDisable {
write()
}
safeListener<PacketEvent.Send> {
lines.add("${sdf.format(Date())}\n${it.packet.javaClass.simpleName}\n${it.packet.javaClass}\n${it.packet}")
when (it.packet) {
is CPacketPlayerDigging -> {
@ -62,43 +58,42 @@ object PacketLogger : Module(
}
private fun write() {
try {
FileWriter(filename).also {
for (line in lines) it.write(line)
it.close()
defaultScope.launch(Dispatchers.IO) {
try {
file.bufferedWriter().use {
lines.forEach(it::write)
}
} catch (e: Exception) {
KamiMod.LOG.error("$chatName Error saving!", e)
}
} catch (e: IOException) {
KamiMod.LOG.error("$chatName Error saving!")
e.printStackTrace()
lines.clear()
}
lines.clear()
}
private fun readToList() {
val bufferedReader: BufferedReader
private fun read() {
defaultScope.launch(Dispatchers.IO) {
lines.clear()
try {
bufferedReader = BufferedReader(InputStreamReader(FileInputStream(filename), StandardCharsets.UTF_8))
var line: String
lines.clear()
while (bufferedReader.readLine().also { line = it } != null) {
lines.add(line)
try {
file.bufferedReader().forEachLine {
lines.add(it)
}
} catch (e: Exception) {
KamiMod.LOG.error("$chatName Error loading!", e)
}
bufferedReader.close()
} catch (ignored: Exception) {
// this is fine, just don't load a file
KamiMod.LOG.error("$chatName Error loading!")
lines.clear()
}
}
init {
clear.listeners.add {
if (clear.value) {
clear.consumers.add{ _, input ->
if (input) {
lines.clear()
write()
MessageSendHelper.sendChatMessage("$chatName Packet log cleared!")
clear.value = false
false
} else {
input
}
}
}

View File

@ -3,6 +3,7 @@ package me.zeroeightsix.kami.module.modules.player
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.threads.runSafe
import net.minecraft.network.play.client.CPacketConfirmTeleport
import org.kamiblue.event.listener.listener
@ -11,21 +12,23 @@ object PortalGodMode : Module(
category = Category.PLAYER,
description = "Don't take damage in portals"
) {
private val confirm = setting("InstantTeleport", true)
private val instantTeleport by setting("InstantTeleport", true)
private var packet: CPacketConfirmTeleport? = null
override fun onEnable() {
packet = null
}
override fun onDisable() {
if (confirm.value) packet?.let {
mc.connection?.sendPacket(it)
}
}
init {
onEnable {
packet = null
}
onDisable {
runSafe {
if (instantTeleport) packet?.let {
connection.sendPacket(it)
}
}
}
listener<PacketEvent.Send> {
if (it.packet !is CPacketConfirmTeleport) return@listener
it.cancel()

View File

@ -3,6 +3,7 @@ package me.zeroeightsix.kami.module.modules.player
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import me.zeroeightsix.kami.event.Phase
import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.OnUpdateWalkingPlayerEvent
import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.event.events.PlayerTravelEvent
@ -18,6 +19,7 @@ import me.zeroeightsix.kami.util.math.Vec2f
import me.zeroeightsix.kami.util.math.VectorUtils.toBlockPos
import me.zeroeightsix.kami.util.threads.defaultScope
import me.zeroeightsix.kami.util.threads.onMainThreadSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.item.ItemBlock
import net.minecraft.network.play.client.CPacketEntityAction
import net.minecraft.network.play.server.SPacketPlayerPosLook
@ -38,12 +40,12 @@ object Scaffold : Module(
description = "Places blocks under you",
modulePriority = 500
) {
private val tower = setting("Tower", true)
private val spoofHotbar = setting("SpoofHotbar", true)
val safeWalk = setting("SafeWalk", true)
private val sneak = setting("Sneak", true)
private val delay = setting("Delay", 2, 1..10, 1)
private val maxRange = setting("MaxRange", 1, 0..3, 1)
private val tower by setting("Tower", true)
private val spoofHotbar by setting("SpoofHotbar", true)
val safeWalk by setting("SafeWalk", true)
private val sneak by setting("Sneak", true)
private val delay by setting("Delay", 2, 1..10, 1)
private val maxRange by setting("MaxRange", 1, 0..3, 1)
private var lastRotation = Vec2f.ZERO
private var placeInfo: Pair<EnumFacing, BlockPos>? = null
@ -56,23 +58,23 @@ object Scaffold : Module(
return isEnabled && inactiveTicks <= 5
}
override fun onDisable() {
placeInfo = null
inactiveTicks = 69
}
init {
onDisable {
placeInfo = null
inactiveTicks = 69
}
listener<PacketEvent.Receive> {
if (it.packet !is SPacketPlayerPosLook) return@listener
rubberBandTimer.reset()
}
listener<PlayerTravelEvent> {
if (mc.player == null || !tower.value || !mc.gameSettings.keyBindJump.isKeyDown || inactiveTicks > 5 || !isHoldingBlock) return@listener
safeListener<PlayerTravelEvent> {
if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || inactiveTicks > 5 || !isHoldingBlock) return@safeListener
if (rubberBandTimer.tick(10, false)) {
if (shouldTower) mc.player.motionY = 0.41999998688697815
} else if (mc.player.fallDistance <= 2.0f) {
mc.player.motionY = -0.169
if (shouldTower) player.motionY = 0.41999998688697815
} else if (player.fallDistance <= 2.0f) {
player.motionY = -0.169
}
}
}
@ -80,12 +82,13 @@ object Scaffold : Module(
private val isHoldingBlock: Boolean
get() = PlayerPacketManager.getHoldingItemStack().item is ItemBlock
private val shouldTower: Boolean
get() = !mc.player.onGround
&& mc.player.posY - floor(mc.player.posY) <= 0.1
private val SafeClientEvent.shouldTower: Boolean
get() = !player.onGround
&& player.posY - floor(player.posY) <= 0.1
init {
listener<OnUpdateWalkingPlayerEvent> { event ->
if (mc.world == null || mc.player == null || event.phase != Phase.PRE) return@listener
safeListener<OnUpdateWalkingPlayerEvent> { event ->
if (event.phase != Phase.PRE) return@safeListener
inactiveTicks++
placeInfo = calcNextPos()?.let {
WorldUtils.getNeighbour(it, 1, sides = arrayOf(EnumFacing.DOWN))
@ -102,25 +105,25 @@ object Scaffold : Module(
PlayerPacketManager.resetHotbar()
} else if (isHoldingBlock) {
val packet = PlayerPacketManager.PlayerPacket(rotating = true, rotation = lastRotation)
PlayerPacketManager.addPacket(this, packet)
PlayerPacketManager.addPacket(this@Scaffold, packet)
}
}
}
private fun calcNextPos(): BlockPos? {
val posVec = mc.player.positionVector
private fun SafeClientEvent.calcNextPos(): BlockPos? {
val posVec = player.positionVector
val blockPos = posVec.toBlockPos()
return checkPos(blockPos)
?: run {
val realMotion = posVec.subtract(mc.player.prevPosVector)
val realMotion = posVec.subtract(player.prevPosVector)
val nextPos = blockPos.add(roundToRange(realMotion.x), 0, roundToRange(realMotion.z))
checkPos(nextPos)
}
}
private fun checkPos(blockPos: BlockPos): BlockPos? {
private fun SafeClientEvent.checkPos(blockPos: BlockPos): BlockPos? {
val center = Vec3d(blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
val rayTraceResult = mc.world.rayTraceBlocks(
val rayTraceResult = world.rayTraceBlocks(
center,
center.subtract(0.0, 0.5, 0.0),
false,
@ -131,20 +134,20 @@ object Scaffold : Module(
}
private fun roundToRange(value: Double) =
(value * 2.5 * maxRange.value).roundToInt().coerceAtMost(maxRange.value)
(value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange)
private fun swapAndPlace(pos: BlockPos, side: EnumFacing) {
private fun SafeClientEvent.swapAndPlace(pos: BlockPos, side: EnumFacing) {
getBlockSlot()?.let { slot ->
if (spoofHotbar.value) PlayerPacketManager.spoofHotbar(slot)
if (spoofHotbar) PlayerPacketManager.spoofHotbar(slot)
else InventoryUtils.swapSlot(slot)
inactiveTicks = 0
if (placeTimer.tick(delay.value.toLong())) {
val shouldSneak = sneak.value && !mc.player.isSneaking
if (placeTimer.tick(delay.toLong())) {
val shouldSneak = sneak && !player.isSneaking
defaultScope.launch {
if (shouldSneak) {
mc.player?.let {
player.let {
it.connection.sendPacket(CPacketEntityAction(it, CPacketEntityAction.Action.START_SNEAKING))
}
}
@ -160,10 +163,10 @@ object Scaffold : Module(
}
}
private fun getBlockSlot(): Int? {
mc.playerController.updateController()
private fun SafeClientEvent.getBlockSlot(): Int? {
playerController.updateController()
for (i in 0..8) {
val itemStack = mc.player.inventory.mainInventory[i]
val itemStack = player.inventory.mainInventory[i]
if (itemStack.isEmpty || itemStack.item !is ItemBlock) continue
return i
}

View File

@ -12,19 +12,19 @@ object Timer : Module(
category = Category.PLAYER,
description = "Changes your client tick speed"
) {
private val slow = setting("SlowMode", false)
private val tickNormal = setting("TickN", 2.0f, 1f..10f, 0.1f, { !slow.value })
private val tickSlow = setting("TickS", 8f, 1f..10f, 0.1f, { slow.value })
public override fun onDisable() {
mc.timer.tickLength = 50.0f
}
private val slow by setting("SlowMode", false)
private val tickNormal by setting("TickN", 2.0f, 1f..10f, 0.1f, { !slow })
private val tickSlow by setting("TickS", 8f, 1f..10f, 0.1f, { slow })
init {
onDisable {
mc.timer.tickLength = 50.0f
}
safeListener<TickEvent.ClientTickEvent> {
mc.timer.tickLength = 50.0f /
if (!slow.value) tickNormal.value
else (tickSlow.value / 10.0f)
if (!slow) tickNormal
else (tickSlow / 10.0f)
}
}
}

View File

@ -34,13 +34,13 @@ object ViewLock : Module(
private var pitchSliceAngle = 1.0f
private var yawSliceAngle = 1.0f
override fun onEnable() {
yawSliceAngle = 360.0f / yawSlice.value
pitchSliceAngle = 180.0f / (pitchSlice.value - 1)
if (autoYaw.value || autoPitch.value) snapToNext()
}
init {
onEnable {
yawSliceAngle = 360.0f / yawSlice.value
pitchSliceAngle = 180.0f / (pitchSlice.value - 1)
if (autoYaw.value || autoPitch.value) snapToNext()
}
safeListener<TickEvent.ClientTickEvent> {
if (it.phase != TickEvent.Phase.END) return@safeListener
if (autoYaw.value || autoPitch.value) {

View File

@ -17,6 +17,7 @@ import org.kamiblue.event.listener.listener
import org.lwjgl.opengl.GL11.GL_LINE_STRIP
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import kotlin.collections.ArrayDeque
import kotlin.math.PI
import kotlin.math.max
import kotlin.math.min
@ -39,44 +40,39 @@ object Breadcrumbs : Module(
private val a = setting("Alpha", 200, 0..255, 1)
private val thickness = setting("LineThickness", 2.0f, 0.25f..8.0f, 0.25f)
private val mainList = ConcurrentHashMap<String, HashMap<Int, LinkedList<Vec3d>>>() /* <Server IP, <Dimension, PositionList>> */
private val mainList = ConcurrentHashMap<String, HashMap<Int, ArrayDeque<Vec3d>>>() /* <Server IP, <Dimension, PositionList>> */
private var prevDimension = -2
private var startTime = -1L
private var alphaMultiplier = 0f
private var tickCount = 0
override fun onToggle() {
if (!whileDisabled.value) {
mainList.clear()
}
}
init {
onToggle {
if (!whileDisabled.value) {
mainList.clear()
}
}
listener<ConnectionEvent.Disconnect> {
startTime = 0L
alphaMultiplier = 0f
}
listener<RenderWorldEvent> {
if (mc.player == null || (mc.integratedServer == null && mc.currentServerData == null)
|| (isDisabled && !whileDisabled.value)) {
return@listener
safeListener<RenderWorldEvent> {
if ((mc.integratedServer == null && mc.currentServerData == null) || (isDisabled && !whileDisabled.value)) {
return@safeListener
}
if (mc.player.dimension != prevDimension) {
startTime = 0L
alphaMultiplier = 0f
prevDimension = mc.player.dimension
prevDimension = player.dimension
}
if (!shouldRecord(true)) return@listener
if (!shouldRecord(true)) return@safeListener
/* Adding server and dimension to the map if they are not exist */
val serverIP = getServerIP()
val dimension = mc.player.dimension
if (!mainList.containsKey(serverIP)) { /* Add server to the map if not exist */
mainList[serverIP] = hashMapOf(Pair(dimension, LinkedList()))
} else if (!mainList[serverIP]!!.containsKey(dimension)) { /* Add dimension to the map if not exist */
mainList[serverIP]!![dimension] = LinkedList()
}
val dimension = player.dimension
/* Adding position points to list */
val renderPosList = addPos(serverIP, dimension, KamiTessellator.pTicks())
@ -97,13 +93,16 @@ object Breadcrumbs : Module(
tickCount++
} else {
val serverIP = getServerIP()
val dimension = player.dimension
val posList = ((mainList[serverIP] ?: return@safeListener)[dimension] ?: return@safeListener)
val posList = mainList.getOrPut(serverIP, ::HashMap).getOrPut(player.dimension, ::ArrayDeque)
val cutoffPos = posList.lastOrNull { pos -> player.distanceTo(pos) > maxDistance.value }
if (cutoffPos != null) while (posList.first() != cutoffPos) {
posList.remove()
if (cutoffPos != null) {
while (posList.first() != cutoffPos) {
posList.removeFirstOrNull()
}
}
mainList[serverIP]!![dimension] = posList
mainList.getOrPut(serverIP, ::HashMap)[player.dimension] = posList
tickCount = 0
}
}

View File

@ -15,6 +15,7 @@ import me.zeroeightsix.kami.util.color.ColorHolder
import me.zeroeightsix.kami.util.graphics.ESPRenderer
import me.zeroeightsix.kami.util.graphics.KamiTessellator
import me.zeroeightsix.kami.util.graphics.ShaderHelper
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.shader.Shader
@ -32,36 +33,36 @@ object ESP : Module(
category = Category.RENDER,
description = "Highlights entities"
) {
private val page = setting("Page", Page.ENTITY_TYPE)
private val page by setting("Page", Page.ENTITY_TYPE)
/* Entity type settings */
private val all = setting("AllEntity", false, { page.value == Page.ENTITY_TYPE })
private val experience = setting("Experience", false, { page.value == Page.ENTITY_TYPE && !all.value })
private val arrows = setting("Arrows", false, { page.value == Page.ENTITY_TYPE && !all.value })
private val throwable = setting("Throwable", false, { page.value == Page.ENTITY_TYPE && !all.value })
private val items = setting("Items", true, { page.value == Page.ENTITY_TYPE && !all.value })
private val players = setting("Players", true, { page.value == Page.ENTITY_TYPE && !all.value })
private val friends = setting("Friends", false, { page.value == Page.ENTITY_TYPE && !all.value && players.value })
private val sleeping = setting("Sleeping", false, { page.value == Page.ENTITY_TYPE && !all.value && players.value })
private val mobs = setting("Mobs", true, { page.value == Page.ENTITY_TYPE && !all.value })
private val passive = setting("PassiveMobs", false, { page.value == Page.ENTITY_TYPE && !all.value && mobs.value })
private val neutral = setting("NeutralMobs", true, { page.value == Page.ENTITY_TYPE && !all.value && mobs.value })
private val hostile = setting("HostileMobs", true, { page.value == Page.ENTITY_TYPE && !all.value && mobs.value })
private val invisible = setting("Invisible", true, { page.value == Page.ENTITY_TYPE && !all.value })
private val range = setting("Range", 64, 8..128, 8, { page.value == Page.ENTITY_TYPE })
private val all by setting("AllEntity", false, { page == Page.ENTITY_TYPE })
private val experience by setting("Experience", false, { page == Page.ENTITY_TYPE && !all })
private val arrows by setting("Arrows", false, { page == Page.ENTITY_TYPE && !all })
private val throwable by setting("Throwable", false, { page == Page.ENTITY_TYPE && !all })
private val items by setting("Items", true, { page == Page.ENTITY_TYPE && !all })
private val players by setting("Players", true, { page == Page.ENTITY_TYPE && !all })
private val friends by setting("Friends", false, { page == Page.ENTITY_TYPE && !all && players })
private val sleeping by setting("Sleeping", false, { page == Page.ENTITY_TYPE && !all && players })
private val mobs by setting("Mobs", true, { page == Page.ENTITY_TYPE && !all })
private val passive by setting("PassiveMobs", false, { page == Page.ENTITY_TYPE && !all && mobs })
private val neutral by setting("NeutralMobs", true, { page == Page.ENTITY_TYPE && !all && mobs })
private val hostile by setting("HostileMobs", true, { page == Page.ENTITY_TYPE && !all && mobs })
private val invisible by setting("Invisible", true, { page == Page.ENTITY_TYPE && !all })
private val range by setting("Range", 32.0f, 8.0f..64.0f, 0.5f, { page == Page.ENTITY_TYPE })
/* Rendering settings */
private val mode = setting("Mode", ESPMode.SHADER, { page.value == Page.RENDERING })
private val hideOriginal = setting("HideOriginal", false, { page.value == Page.RENDERING && mode.value == ESPMode.SHADER })
private val filled = setting("Filled", false, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val outline = setting("Outline", true, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val r = setting("Red", 155, 0..255, 1, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val g = setting("Green", 144, 0..255, 1, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val b = setting("Blue", 255, 0..255, 1, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val aFilled = setting("FilledAlpha", 63, 0..255, 1, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val aOutline = setting("OutlineAlpha", 255, 0..255, 1, { page.value == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val blurRadius = setting("BlurRadius", 0f, 0f..16f, 0.5f, { page.value == Page.RENDERING && mode.value == ESPMode.SHADER })
private val width = setting("Width", 2f, 1f..8f, 0.25f, { page.value == Page.RENDERING })
private val mode = setting("Mode", ESPMode.SHADER, { page == Page.RENDERING })
private val hideOriginal by setting("HideOriginal", false, { page == Page.RENDERING && mode.value == ESPMode.SHADER })
private val filled by setting("Filled", false, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val outline by setting("Outline", true, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val r by setting("Red", 155, 0..255, 1, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val g by setting("Green", 144, 0..255, 1, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val b by setting("Blue", 255, 0..255, 1, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val aFilled by setting("FilledAlpha", 63, 0..255, 1, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val aOutline by setting("OutlineAlpha", 255, 0..255, 1, { page == Page.RENDERING && (mode.value == ESPMode.BOX || mode.value == ESPMode.SHADER) })
private val blurRadius by setting("BlurRadius", 0f, 0f..16f, 0.5f, { page == Page.RENDERING && mode.value == ESPMode.SHADER })
private val width by setting("Width", 2f, 1f..8f, 0.25f, { page == Page.RENDERING })
private enum class Page {
ENTITY_TYPE, RENDERING
@ -79,23 +80,17 @@ object ESP : Module(
val frameBuffer = shaderHelper.getFrameBuffer("final")
init {
mode.listeners.add {
drawingOutline = false
drawNametag = false
resetGlow()
}
listener<RenderEntityEvent> {
if (mode.value != ESPMode.SHADER || mc.renderManager.renderOutlines || !entityList.contains(it.entity)) return@listener
if (it.phase == Phase.PRE && hideOriginal.value) {
if (it.phase == Phase.PRE && hideOriginal) {
// Steal it from Minecraft rendering kek
prepareFrameBuffer()
drawNametag = true
}
if (it.phase == Phase.PERI) {
if (!hideOriginal.value) {
if (!hideOriginal) {
prepareFrameBuffer()
mc.renderManager.getEntityRenderObject<Entity>(it.entity)?.doRender(it.entity, it.x, it.y, it.z, it.yaw, it.partialTicks)
}
@ -135,15 +130,16 @@ object ESP : Module(
}
init {
listener<RenderWorldEvent> {
if (mc.renderManager.options == null) return@listener
safeListener<RenderWorldEvent> {
if (mc.renderManager.options == null) return@safeListener
when (mode.value) {
ESPMode.BOX -> {
val color = ColorHolder(r.value, g.value, b.value)
val color = ColorHolder(r, g, b)
val renderer = ESPRenderer()
renderer.aFilled = if (filled.value) aFilled.value else 0
renderer.aOutline = if (outline.value) aOutline.value else 0
renderer.thickness = width.value
renderer.aFilled = if (filled) aFilled else 0
renderer.aOutline = if (outline) aOutline else 0
renderer.thickness = width
for (entity in entityList) {
renderer.add(entity, color)
}
@ -151,7 +147,7 @@ object ESP : Module(
}
else -> {
// other modes, such as GLOW, use onUpdate()
// Glow and Shader mode
}
}
}
@ -163,7 +159,7 @@ object ESP : Module(
if (mode.value == ESPMode.GLOW) {
if (entityList.isNotEmpty()) {
for (shader in mc.renderGlobal.entityOutlineShader.listShaders) {
shader.shaderManager.getShaderUniform("Radius")?.set(width.value)
shader.shaderManager.getShaderUniform("Radius")?.set(width)
}
for (entity in world.loadedEntityList) { // Set glow for entities in the list. Remove glow for entities not in the list
@ -183,24 +179,24 @@ object ESP : Module(
}
private fun SafeClientEvent.getEntityList(): List<Entity> {
val player = arrayOf(players.value, friends.value, sleeping.value)
val mob = arrayOf(mobs.value, passive.value, neutral.value, hostile.value)
val playerSettings = arrayOf(players, friends, sleeping)
val mob = arrayOf(mobs, passive, neutral, hostile)
val entityList = ArrayList<Entity>()
if (all.value) {
if (all) {
for (entity in world.loadedEntityList) {
if (entity == mc.renderViewEntity) continue
if (mc.player.getDistance(entity) > range.value) continue
if (player.getDistance(entity) > range) continue
entityList.add(entity)
}
} else {
entityList.addAll(getTargetList(player, mob, invisible.value, range.value.toFloat(), ignoreSelf = false))
entityList.addAll(getTargetList(playerSettings, mob, invisible, range, ignoreSelf = false))
for (entity in world.loadedEntityList) {
if (entity == player) continue
if (mc.player.getDistance(entity) > range.value) continue
if (entity is EntityXPOrb && experience.value
|| entity is EntityArrow && arrows.value
|| entity is EntityThrowable && throwable.value
|| entity is EntityItem && items.value) {
if (player.getDistance(entity) > range) continue
if (entity is EntityXPOrb && experience
|| entity is EntityArrow && arrows
|| entity is EntityThrowable && throwable
|| entity is EntityItem && items) {
entityList.add(entity)
}
}
@ -209,26 +205,34 @@ object ESP : Module(
}
private fun setShaderSettings(shader: Shader) {
shader.shaderManager.getShaderUniform("color")?.set(r.value / 255f, g.value / 255f, b.value / 255f)
shader.shaderManager.getShaderUniform("outlineAlpha")?.set(if (outline.value) aOutline.value / 255f else 0f)
shader.shaderManager.getShaderUniform("filledAlpha")?.set(if (filled.value) aFilled.value / 255f else 0f)
shader.shaderManager.getShaderUniform("width")?.set(width.value)
shader.shaderManager.getShaderUniform("Radius")?.set(blurRadius.value)
shader.shaderManager.getShaderUniform("color")?.set(r / 255f, g / 255f, b / 255f)
shader.shaderManager.getShaderUniform("outlineAlpha")?.set(if (outline) aOutline / 255f else 0f)
shader.shaderManager.getShaderUniform("filledAlpha")?.set(if (filled) aFilled / 255f else 0f)
shader.shaderManager.getShaderUniform("width")?.set(width)
shader.shaderManager.getShaderUniform("Radius")?.set(blurRadius)
}
override fun onDisable() {
resetGlow()
init {
onDisable {
resetGlow()
}
mode.listeners.add {
drawingOutline = false
drawNametag = false
resetGlow()
}
}
private fun resetGlow() {
if (mc.player == null) return
runSafe {
for (shader in mc.renderGlobal.entityOutlineShader.listShaders) {
shader.shaderManager.getShaderUniform("Radius")?.set(2f) // default radius
}
for (shader in mc.renderGlobal.entityOutlineShader.listShaders) {
shader.shaderManager.getShaderUniform("Radius")?.set(2f) // default radius
}
for (entity in mc.world.loadedEntityList) {
entity.isGlowing = false
for (entity in world.loadedEntityList) {
entity.isGlowing = false
}
}
}
}

View File

@ -14,37 +14,37 @@ object FullBright : Module(
category = Category.RENDER,
alwaysListening = true
) {
private val gamma = setting("Gamma", 12.0f, 5.0f..15.0f, 0.5f)
private val transitionLength = setting("TransitionLength", 3.0f, 0.0f..10.0f, 0.5f)
private val oldValue = setting("OldValue", 1.0f, 0.0f..1.0f, 0.1f, { false })
private val gamma by setting("Gamma", 12.0f, 5.0f..15.0f, 0.5f)
private val transitionLength by setting("TransitionLength", 3.0f, 0.0f..10.0f, 0.5f)
private var oldValue by setting("OldValue", 1.0f, 0.0f..1.0f, 0.1f, { false })
private var gammaSetting: Float
get() = mc.gameSettings.gammaSetting
set(gammaIn) {
mc.gameSettings.gammaSetting = gammaIn
}
private var disableTimer = TickTimer()
override fun onEnable() {
oldValue.value = mc.gameSettings.gammaSetting
}
override fun onDisable() {
disableTimer.reset()
}
private val disableTimer = TickTimer()
init {
onEnable {
oldValue = mc.gameSettings.gammaSetting
}
onDisable {
disableTimer.reset()
}
safeListener<TickEvent.ClientTickEvent> {
if (it.phase != TickEvent.Phase.START) return@safeListener
when {
isEnabled -> {
transition(gamma.value)
transition(gamma)
alwaysListening = true
}
isDisabled && gammaSetting != oldValue.value
&& !disableTimer.tick((transitionLength.value * 1000.0f).toLong(), false) -> {
transition(oldValue.value)
isDisabled && gammaSetting != oldValue
&& !disableTimer.tick((transitionLength * 1000.0f).toLong(), false) -> {
transition(oldValue)
}
else -> {
@ -68,7 +68,7 @@ object FullBright : Module(
}
private fun getTransitionAmount(): Float {
if (transitionLength.value == 0f) return 15f
return (1f / transitionLength.value / 20f) * (gamma.value - oldValue.value)
if (transitionLength == 0f) return 15f
return (1f / transitionLength / 20f) * (gamma - oldValue)
}
}

View File

@ -3,6 +3,7 @@ package me.zeroeightsix.kami.module.modules.render
import me.zeroeightsix.kami.manager.managers.UUIDManager
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.threads.runSafe
import me.zeroeightsix.kami.util.threads.safeListener
import net.minecraft.entity.passive.AbstractHorse
import net.minecraft.entity.passive.EntityTameable
@ -43,16 +44,18 @@ object MobOwner : Module(
}
}
}
}
override fun onDisable() {
for (entity in mc.world.loadedEntityList) {
if (entity !is AbstractHorse) continue
onDisable {
runSafe {
for (entity in world.loadedEntityList) {
if (entity !is AbstractHorse) continue
try {
entity.alwaysRenderNameTag = false
} catch (_: Exception) {
// this is fine
try {
entity.alwaysRenderNameTag = false
} catch (_: Exception) {
// Ignored
}
}
}
}
}

View File

@ -26,6 +26,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.LinkedHashSet
object NewChunks : Module(
name = "NewChunks",
@ -53,19 +54,19 @@ object NewChunks : Module(
private var lastSetting = LastSetting()
private var logWriter: PrintWriter? = null
private val timer = TickTimer(TimeUnit.MINUTES)
val chunks = HashSet<Chunk>()
override fun onDisable() {
logWriterClose()
chunks.clear()
MessageSendHelper.sendChatMessage("$chatName Saved and cleared chunks!")
}
override fun onEnable() {
timer.reset()
}
private val chunks = LinkedHashSet<Chunk>()
init {
onEnable {
timer.reset()
}
onDisable {
logWriterClose()
chunks.clear()
MessageSendHelper.sendChatMessage("$chatName Saved and cleared chunks!")
}
safeListener<TickEvent.ClientTickEvent> {
if (it.phase == TickEvent.Phase.END && autoClear.value && timer.tick(10L)) {
chunks.clear()

View File

@ -80,6 +80,10 @@ object NoRender : Module(
var entityList = HashSet<Class<*>>(); private set
init {
onEnable {
updateList()
}
listener<PacketEvent.Receive> {
if (lightning.value && it.packet is SPacketSpawnGlobalEntity ||
explosion.value && it.packet is SPacketExplosion ||
@ -144,10 +148,6 @@ object NoRender : Module(
}
}
override fun onEnable() {
updateList()
}
private fun updateList() {
entityList = HashSet<Class<*>>().apply {
settingMap.forEach {

View File

@ -62,16 +62,16 @@ object Search : Module(
return renderer.size.toString()
}
override fun onEnable() {
if (!overrideWarning && ShaderHelper.isIntegratedGraphics) {
MessageSendHelper.sendErrorMessage("$chatName Warning: Running Search with an Intel Integrated GPU is not recommended, as it has a &llarge&r impact on performance.")
MessageSendHelper.sendWarningMessage("$chatName If you're sure you want to try, run the ${formatValue("${CommandManager.prefix}search override")} command")
disable()
return
}
}
init {
onEnable {
if (!overrideWarning && ShaderHelper.isIntegratedGraphics) {
MessageSendHelper.sendErrorMessage("$chatName Warning: Running Search with an Intel Integrated GPU is not recommended, as it has a &llarge&r impact on performance.")
MessageSendHelper.sendWarningMessage("$chatName If you're sure you want to try, run the ${formatValue("${CommandManager.prefix}search override")} command")
disable()
return@onEnable
}
}
safeListener<RenderWorldEvent> {
renderer.render(false)

View File

@ -136,15 +136,15 @@ object WaypointRender : Module(
glPopMatrix()
}
override fun onEnable() {
timer.reset(-10000L) // Update the map immediately and thread safely
}
override fun onDisable() {
currentServer = null
}
init {
onEnable {
timer.reset(-10000L) // Update the map immediately and thread safely
}
onDisable {
currentServer = null
}
safeListener<TickEvent.ClientTickEvent> {
if (WaypointManager.genDimension() != prevDimension || timer.tick(10L, false)) {
updateList()

View File

@ -17,26 +17,34 @@ object Zoom : Module(
private val sensitivityMultiplier = setting("SensitivityMultiplier", 1.0f, 0.25f..2.0f, 0.25f, { modifySensitivity.value })
private val smoothCamera = setting("CinematicCamera", false)
override fun onEnable() {
if (mc.player == null) return
fov = mc.gameSettings.fovSetting
sensi = mc.gameSettings.mouseSensitivity
mc.gameSettings.fovSetting = fovChange.value
if (modifySensitivity.value) mc.gameSettings.mouseSensitivity = sensi * sensitivityMultiplier.value
mc.gameSettings.smoothCamera = smoothCamera.value
}
override fun onDisable() {
mc.gameSettings.fovSetting = fov
mc.gameSettings.mouseSensitivity = sensi
mc.gameSettings.smoothCamera = false
}
init {
fovChange.listeners.add { if (isEnabled) mc.gameSettings.fovSetting = fovChange.value }
modifySensitivity.listeners.add { if (isEnabled) if (modifySensitivity.value) mc.gameSettings.mouseSensitivity = sensi * sensitivityMultiplier.value else mc.gameSettings.mouseSensitivity = sensi }
sensitivityMultiplier.listeners.add { if (isEnabled) mc.gameSettings.mouseSensitivity = sensi * sensitivityMultiplier.value }
smoothCamera.listeners.add { if (isEnabled) mc.gameSettings.smoothCamera = smoothCamera.value }
onEnable {
fov = mc.gameSettings.fovSetting
sensi = mc.gameSettings.mouseSensitivity
mc.gameSettings.fovSetting = fovChange.value
if (modifySensitivity.value) mc.gameSettings.mouseSensitivity = sensi * sensitivityMultiplier.value
mc.gameSettings.smoothCamera = smoothCamera.value
}
onDisable {
mc.gameSettings.fovSetting = fov
mc.gameSettings.mouseSensitivity = sensi
mc.gameSettings.smoothCamera = false
}
fovChange.listeners.add {
if (isEnabled) mc.gameSettings.fovSetting = fovChange.value
}
modifySensitivity.listeners.add {
if (isEnabled) if (modifySensitivity.value) mc.gameSettings.mouseSensitivity = sensi * sensitivityMultiplier.value
else mc.gameSettings.mouseSensitivity = sensi
}
sensitivityMultiplier.listeners.add {
if (isEnabled) mc.gameSettings.mouseSensitivity = sensi * sensitivityMultiplier.value
}
smoothCamera.listeners.add {
if (isEnabled) mc.gameSettings.smoothCamera = smoothCamera.value
}
}
}

View File

@ -2,7 +2,6 @@ package me.zeroeightsix.kami.setting
import me.zeroeightsix.kami.KamiMod
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.module.ModuleManager
import me.zeroeightsix.kami.setting.GenericConfig.setting
import me.zeroeightsix.kami.setting.config.AbstractConfig
import me.zeroeightsix.kami.setting.settings.AbstractSetting
@ -24,7 +23,6 @@ internal object ModuleConfig : AbstractConfig<Module>(
override fun save() {
super.save()
for (module in ModuleManager.modules) module.destroy()
}
}

View File

@ -16,7 +16,7 @@ abstract class AbstractSetting<T : Any> : Nameable {
abstract val description: String
val listeners = ArrayList<() -> Unit>()
val valueListeners = ArrayList<(T, T) -> Unit>()
val valueListeners = ArrayList<(prev: T, input: T) -> Unit>()
val isVisible get() = visibility()

View File

@ -33,7 +33,6 @@ open class MutableSetting<T : Any>(
field = new
valueListeners.forEach { it(prev, field) }
for (listener in valueListeners) listener(prev, field)
listeners.forEach { it() }
}
}

View File

@ -21,7 +21,7 @@ object MessageDetection {
},
ANY {
override val prefixes: Array<out CharSequence>
get() = arrayOf(*ANY_EXCEPT_DELIMITER.prefixes, ChatEncryption.delimiter.value)
get() = arrayOf(*ANY_EXCEPT_DELIMITER.prefixes, ChatEncryption.delimiter)
}
}