diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt index 4a3423b07b7..577b9dd0951 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/ModuleManager.kt @@ -260,6 +260,7 @@ object ModuleManager : EventListener, Iterable by modules { ModuleSpammer, ModuleAutoAccount, ModuleTeams, + ModuleElytraSwap, ModuleAutoChatGame, ModuleFocus, ModuleAutoPearl, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleElytraSwap.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleElytraSwap.kt new file mode 100644 index 00000000000..11c8681f408 --- /dev/null +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleElytraSwap.kt @@ -0,0 +1,89 @@ +@file:Suppress("NOTHING_TO_INLINE") +package net.ccbluex.liquidbounce.features.module.modules.misc + +import net.ccbluex.liquidbounce.event.events.KeyEvent +import net.ccbluex.liquidbounce.event.events.ScheduleInventoryActionEvent +import net.ccbluex.liquidbounce.event.handler +import net.ccbluex.liquidbounce.features.module.Category +import net.ccbluex.liquidbounce.features.module.ClientModule +import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleElytraSwap.constraints +import net.ccbluex.liquidbounce.utils.inventory.* +import net.minecraft.item.ArmorItem +import net.minecraft.item.ItemStack +import net.minecraft.item.Items +import org.lwjgl.glfw.GLFW + +private var swapRequested = false + +private val slots = Slots.Hotbar + Slots.Inventory + Slots.OffHand +private val chestplateSlot = ArmorItemSlot(2 /* chestplate */) + +/** + * ModuleElytraSwap + * + * Allows to quickly replace the chestplate with an elytra and vice versa + * + * @author sqlerrorthing + * @since 2/13/2025 + **/ +object ModuleElytraSwap : ClientModule("ElytraSwap", Category.MISC) { + internal val constraints = tree(PlayerInventoryConstraints()) + private val swapKey by key("Swap", GLFW.GLFW_KEY_UNKNOWN) + + @Suppress("unused") + private val keyboardHandler = handler { + if (it.action != GLFW.GLFW_PRESS) { + return@handler + } + + when (it.key.code) { + swapKey.code -> { + swapRequested = true + } + } + } + + @Suppress("unused") + private val elytraSwapHandler = handler(priority = 500) { event -> + if (!swapRequested) { + return@handler + } else { + swapRequested = false + } + + val elytra = slots.findSlot(Items.ELYTRA) + val chestplate = slots.findSlot { it.isChestplate() } + + with (chestplateSlot.itemStack /* worn item */) { + when { + // put on elytra + isEmpty && elytra != null -> event.doSwap(elytra) + + // replacing of elytra with a chestplate + isElytra() && chestplate != null -> event.doSwap(chestplate) + + // replacing the chestplate with elytra + isChestplate() && elytra != null -> event.doSwap(elytra) + } + } + } +} + +private inline fun ScheduleInventoryActionEvent.doSwap(slot: ItemSlot) = schedule( + constraints, + ClickInventoryAction.performPickup(slot = slot), + ClickInventoryAction.performPickup(slot = chestplateSlot), + ClickInventoryAction.performPickup(slot = slot) +) + +private inline fun ItemStack.isChestplate() = with(this.item) { + this is ArmorItem && + this == Items.LEATHER_CHESTPLATE + || this == Items.CHAINMAIL_CHESTPLATE + || this == Items.IRON_CHESTPLATE + || this == Items.GOLDEN_CHESTPLATE + || this == Items.NETHERITE_CHESTPLATE + || this == Items.DIAMOND_CHESTPLATE +} + +private inline fun ItemStack.isElytra() = this.item == Items.ELYTRA diff --git a/src/main/resources/resources/liquidbounce/lang/de_de.json b/src/main/resources/resources/liquidbounce/lang/de_de.json index 846fcb8306d..420200637b8 100644 --- a/src/main/resources/resources/liquidbounce/lang/de_de.json +++ b/src/main/resources/resources/liquidbounce/lang/de_de.json @@ -623,8 +623,9 @@ "liquidbounce.module.holeFiller.description": "Füllt automatisch sichere Orte mit Blöcken für Crystal PvP.", "liquidbounce.module.itemChams.description": "Wendet visuelle Effekte auf Gegenstände in deiner Hand an.", "liquidbounce.module.bookBot.description": "Schreibt automatisch in Bücher.", - "liquidbounce.module.betterTab.description": "Verschiedene Verbesserungen für die Tab-Liste.", + "liquidbounce.module.betterTab.description": "Verschiedene Verbesserungen für die Tab-Liste.", "liquidbounce.module.itemTags.description": "Zeigt Bilder und Mengenangaben fallengelassener Gegenstände an.", + "liquidbounce.module.elytraSwap.description": "Ermöglicht es, schnell zwischen Brustpanzer und Elytra zu wechseln.", "liquidbounce.module.baritone.description": "Einstellungen für Baritone.", "liquidbounce.command.tps.description": "Schätzt die TPS des Servers ab.", "liquidbounce.command.tps.result.tpsCheck": "Die TPS des Servers betragen %s.", diff --git a/src/main/resources/resources/liquidbounce/lang/en_pt.json b/src/main/resources/resources/liquidbounce/lang/en_pt.json index bfbf4fe9811..71fe707a5f3 100644 --- a/src/main/resources/resources/liquidbounce/lang/en_pt.json +++ b/src/main/resources/resources/liquidbounce/lang/en_pt.json @@ -302,6 +302,7 @@ "liquidbounce.module.noSignRender.description": "Prevents the sign text from being rendered.", "liquidbounce.module.noSwing.description": "Disables the swing effect.", "liquidbounce.module.noWeather.description": "Disables the rain effect.", + "liquidbounce.module.elytraSwap.description": "Allows you to quickly swap between the chestplate and elytra.", "liquidbounce.module.rotations.description": "Allows you to see server-sided rotations.", "liquidbounce.module.storageEsp.description": "Allows you to see chests, dispensers, etc. through walls.", "liquidbounce.module.trajectories.description": "Allows you to see where projectile items will land.", diff --git a/src/main/resources/resources/liquidbounce/lang/en_us.json b/src/main/resources/resources/liquidbounce/lang/en_us.json index 23be7edea35..b433808fd25 100644 --- a/src/main/resources/resources/liquidbounce/lang/en_us.json +++ b/src/main/resources/resources/liquidbounce/lang/en_us.json @@ -541,6 +541,7 @@ "liquidbounce.module.noSwing.description": "Disables the hand swing animation.", "liquidbounce.module.noWeather.description": "Disables weather effects.", "liquidbounce.module.noWeb.description": "Disables slow down caused by webs.", + "liquidbounce.module.elytraSwap.description": "Allows to quickly replace the chestplate with an elytra and vice versa.", "liquidbounce.module.notifier.description": "Notifies you about all kinds of events.", "liquidbounce.module.nuker.description": "Automatically destroys all blocks in your area. Be careful!", "liquidbounce.module.parkour.description": "Automatically jumps at the very edge of a block.", diff --git a/src/main/resources/resources/liquidbounce/lang/ja_jp.json b/src/main/resources/resources/liquidbounce/lang/ja_jp.json index 7a86695847d..f648e02c63b 100644 --- a/src/main/resources/resources/liquidbounce/lang/ja_jp.json +++ b/src/main/resources/resources/liquidbounce/lang/ja_jp.json @@ -454,6 +454,7 @@ "liquidbounce.module.noSlowBreak.description": "悪影響を与える状況にある場合、採掘速度を自動的に調整します。", "liquidbounce.module.noSwing.description": "スイング効果を無効にします。", "liquidbounce.module.noWeather.description": "雨の効果を無効にします。", + "liquidbounce.module.elytraSwap.description": "チェストプレートとエリトラを素早く入れ替えることができます。", "liquidbounce.module.noWeb.description": "クモの巣のスローダウンを無効にします。", "liquidbounce.module.notifier.description": "あらゆる種類のイベントについて通知します。", "liquidbounce.module.nuker.description": "エリア内のすべてのブロックを自動的に破壊します。", diff --git a/src/main/resources/resources/liquidbounce/lang/pt_br.json b/src/main/resources/resources/liquidbounce/lang/pt_br.json index 0d06b8182ea..c49a374d64a 100644 --- a/src/main/resources/resources/liquidbounce/lang/pt_br.json +++ b/src/main/resources/resources/liquidbounce/lang/pt_br.json @@ -338,6 +338,7 @@ "liquidbounce.command.config.subcommand.create.result.created": "O arquivo de configuração chamado %s foi criado.", "liquidbounce.command.config.subcommand.create.result.alreadyExists": "O arquivo de configuração chamado %s já existe.", "liquidbounce.module.fastPlace.description": "Permite que você coloque blocos mais rápido.", + "liquidbounce.module.elytraSwap.description": "Permite trocar rapidamente entre a couraça e a elytra.", "liquidbounce.module.trueSight.description": "Permite que você veja objetos e entidades invisíveis.", "liquidbounce.module.noRotateSet.description": "Impede que o servidor gire sua cabeça.", "liquidbounce.module.sprint.description": "Corre automaticamente.", diff --git a/src/main/resources/resources/liquidbounce/lang/ru_ru.json b/src/main/resources/resources/liquidbounce/lang/ru_ru.json index d8cdc8608e3..1f7b9f11910 100644 --- a/src/main/resources/resources/liquidbounce/lang/ru_ru.json +++ b/src/main/resources/resources/liquidbounce/lang/ru_ru.json @@ -616,6 +616,7 @@ "liquidbounce.module.velocity.description": "Изменяет величину отдачи, которую вы получаете.", "liquidbounce.module.vomit.description": "Выбрасывает предметы из вашего инвентаря.", "liquidbounce.module.xRay.description": "Отрисовывает только выбранные блоки.", + "liquidbounce.module.elytraSwap.description": "Позволяет быстро заменять нагрудник элитрой и наоборот.", "liquidbounce.module.zoom.description": "Позволяет сделать всё в мире больше или меньше.", "liquidbounce.module.packetLogger.description": "Выводит все пакеты и их содержание (поля).", "liquidbounce.module.packetLogger.messages.send": "Отправляющиеся", diff --git a/src/main/resources/resources/liquidbounce/lang/ua_ua.json b/src/main/resources/resources/liquidbounce/lang/ua_ua.json index 255f1a8846f..f9570b6a86a 100644 --- a/src/main/resources/resources/liquidbounce/lang/ua_ua.json +++ b/src/main/resources/resources/liquidbounce/lang/ua_ua.json @@ -496,6 +496,7 @@ "liquidbounce.module.xRay.description": "Опис рентгену", "liquidbounce.module.antiHunger.description": "Опис антиголоду", "liquidbounce.module.antiHunger.messages.warnSprint": "Попередження: біг", + "liquidbounce.module.elytraSwap.description": "Дозволяє швидко змінювати нагрудник на елітри і навпаки.", "liquidbounce.module.antiHunger.messages.warnBreak": "Попередження: перерва", "liquidbounce.module.liquidChat.description": "Опис рідкого чату", "liquidbounce.module.consoleSpammer.description": "Опис спамера консолі", diff --git a/src/main/resources/resources/liquidbounce/lang/zh_cn.json b/src/main/resources/resources/liquidbounce/lang/zh_cn.json index 02573358a0a..0c81b66dc42 100644 --- a/src/main/resources/resources/liquidbounce/lang/zh_cn.json +++ b/src/main/resources/resources/liquidbounce/lang/zh_cn.json @@ -627,6 +627,7 @@ "liquidbounce.module.autoBuild.messages.noFlintAndSteel": "没有打火石,无法启动传送门, 关闭中...", "liquidbounce.module.dupe.description": "尝试利用漏洞从物品栏中自动复制物品。", "liquidbounce.module.surround.description": "自动在周围建造安全方块,保护你免受爆炸伤害。", + "liquidbounce.module.elytraSwap.description": "允许快速在胸甲和鞘翅之间切换。", "liquidbounce.module.blockIn.description": "自动在周围建造方块覆盖自己。", "liquidbounce.module.blockIn.messages.filled": "放置完成!", "liquidbounce.module.blockIn.messages.positionChanged": "你的位置变了!已自动关闭模块。",