Skip to content

Commit

Permalink
feat: ElytraSwap module (#5608)
Browse files Browse the repository at this point in the history
  • Loading branch information
sqlerrorthing authored Feb 13, 2025
1 parent e1c8709 commit aedfc8b
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ object ModuleManager : EventListener, Iterable<ClientModule> by modules {
ModuleSpammer,
ModuleAutoAccount,
ModuleTeams,
ModuleElytraSwap,
ModuleAutoChatGame,
ModuleFocus,
ModuleAutoPearl,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<KeyEvent> {
if (it.action != GLFW.GLFW_PRESS) {
return@handler
}

when (it.key.code) {
swapKey.code -> {
swapRequested = true
}
}
}

@Suppress("unused")
private val elytraSwapHandler = handler<ScheduleInventoryActionEvent>(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
3 changes: 2 additions & 1 deletion src/main/resources/resources/liquidbounce/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/en_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "エリア内のすべてのブロックを自動的に破壊します。",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Отправляющиеся",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/ua_ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Опис спамера консолі",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "你的位置变了!已自动关闭模块。",
Expand Down

0 comments on commit aedfc8b

Please sign in to comment.