diff options
Diffstat (limited to 'src/main/kotlin')
12 files changed, 261 insertions, 17 deletions
diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt index d8faa8d..ed2d072 100644 --- a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt +++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt @@ -77,7 +77,8 @@ class AmbientAddons { CatOverlay, PingOverlay, ThornOverlay, - KuudraFeatures + KuudraFeatures, + Salvage ).forEach(MinecraftForge.EVENT_BUS::register) keyBinds.values.forEach(ClientRegistry::registerKeyBinding) guiElements = listOf( diff --git a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt index e86f137..9ba1988 100644 --- a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt +++ b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt @@ -22,6 +22,7 @@ class AmbientCommand : CommandBase() { null -> AmbientAddons.currentGui = Config.gui() "location" -> UChat.chat(SBLocation.toString().withModPrefix()) "buy" -> AutoBuyCommand.processCommand(args.drop(1)) + "salvage" -> SalvageCommand.processCommand(args.drop(1)) else -> UChat.chat("§cUnknown argument!") } } diff --git a/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt b/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt new file mode 100644 index 0000000..0d11e79 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt @@ -0,0 +1,47 @@ +package com.ambientaddons.commands + +import AmbientAddons.Companion.persistentData +import com.ambientaddons.utils.Extensions.withModPrefix +import com.ambientaddons.utils.SalvageStrategy +import gg.essential.universal.UChat + +object SalvageCommand { + fun processCommand(args: List<String>) { + when (args.getOrNull(0)) { + "auto" -> { + val item = args[1] + val added = persistentData.salvageMap.put(item, SalvageStrategy.Always) != SalvageStrategy.Always + persistentData.save() + UChat.chat((if (added) "§aAdded item §a§l${item}." else "§cItem already added.").withModPrefix()) + } + "allow" -> { + val item = args[1] + val allowed = persistentData.salvageMap.put(item, SalvageStrategy.Allow) != SalvageStrategy.Allow + persistentData.save() + UChat.chat((if (allowed) "§aAllowing item §a§l${item}." else "§cItem already allowed.").withModPrefix()) + } + "remove" -> { + val item = args[1] + val removed = persistentData.salvageMap.remove(item) != null + persistentData.save() + UChat.chat((if (removed) "§aRemoving item §a§l${item}." else "§cItem not in list.").withModPrefix()) + } + "list" -> { + UChat.chat("§2§lItems §7(§aalways salvage, §callow salvaging§7)".withModPrefix()) + persistentData.salvageMap.forEach { + if (it.value == SalvageStrategy.Always) { + UChat.chat(" §a${it.key}") + } else { + UChat.chat(" §e${it.key}") + } + } + } + else -> { + UChat.chat("§2§lUsage".withModPrefix()) + UChat.chat(" §aAlways salvage item: §b/ambient salvage auto <Skyblock ID>") + UChat.chat(" §aAllow salvaging item: §b/ambient salvage allow <Skyblock ID>") + UChat.chat(" §aBlock salvaging item: §b/ambient remove <Skyblock ID>") + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt index 691b784..6e5bfc8 100644 --- a/src/main/kotlin/com/ambientaddons/config/Config.kt +++ b/src/main/kotlin/com/ambientaddons/config/Config.kt @@ -10,7 +10,8 @@ import java.io.File object Config : Vigilant( File(AmbientAddons.configDirectory, "config.toml"), AmbientAddons.metadata.name ) { - + var salvageMode = 0 + var topQualityStrategy = false var kuudraReady = false var kuudraHp = false @@ -50,10 +51,24 @@ object Config : Vigilant( var melodyBlockMisclicks = false var melodyAnnouncement = "Meowlody on me!" - var throttledAnnouncement = "Hi! This is Hypixel Support. We noticed that your runs are actually efficient so we’re throttling this menu. Enjoy slower runs, dipshit. Hope Goldor kills you. Meow." + var throttledAnnouncement = + "Hi! This is Hypixel Support. We noticed that your runs are actually efficient so we’re throttling this menu. Enjoy slower runs, dipshit. Hope Goldor kills you. Meow." init { category("Misc") { + subcategory("Salvaging") { + selector( + ::salvageMode, + name = "Salvaging features", + description = "Various modes to improve salvaging.", + options = listOf("Off", "Highlight", "Block misclicks", "Legit autosalvage", "Unlegit autosalvage") + ) + switch( + ::topQualityStrategy, + name = "Should salvage top quality", + description = "If selected, automatically salvages top-quality items. Otherwise, allows them to be salvaged but does not automatically." + ) + } subcategory("Kuudra") { switch( ::kuudraReady, @@ -181,13 +196,7 @@ object Config : Vigilant( ) } - category("Notifications") { - switch( - ::maskWarning, - name = "Mask proc warning", - description = "Displays a title when a spirit mask or bonzo mask procs." - ) - } + category("Displays") { button( @@ -197,6 +206,11 @@ object Config : Vigilant( currentGui = MoveGui() } switch( + ::maskWarning, + name = "Mask proc warning", + description = "Displays a title when a spirit mask or bonzo mask procs." + ) + switch( ::cat, name = "Cat", description = "Show catplague's awesome cat upgrade! Disabling is a crime.", @@ -219,7 +233,7 @@ object Config : Vigilant( name = "Enable ping", description = "Enables ping in command and display. This requires sending packets to the server.", options = listOf("Off", "In Skyblock", "On Hypixel", "Always") - ) + ) selector( ::pingDisplay, name = "Ping and TPS display", @@ -252,6 +266,8 @@ object Config : Vigilant( switch( ::ignoreCarpet, name = "Ignore carpet hitboxes", description = "Removes all carpet hitboxes" ) + } + subcategory("Melody") { switch( ::melodyBlockMisclicks, name = "Block misclicks on Melody terminal", @@ -268,6 +284,7 @@ object Config : Vigilant( description = "Announces that a terminal was throttled in party chat; leave empty to disable." ) } + } } }
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt index 9588e21..f46bcd9 100644 --- a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt +++ b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt @@ -1,6 +1,7 @@ package com.ambientaddons.config import com.ambientaddons.gui.GuiPosition +import com.ambientaddons.utils.SalvageStrategy import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import java.io.File @@ -25,7 +26,36 @@ data class PersistentData( "WITHER_CHESTPLATE" to null, "ULTIMATE_ONE_FOR_ALL_1" to null ), - var positions: MutableMap<String, GuiPosition> = mutableMapOf() + var positions: MutableMap<String, GuiPosition> = mutableMapOf(), + var salvageMap: MutableMap<String, SalvageStrategy> = mutableMapOf( + "SLUG_BOOTS" to SalvageStrategy.Always, + "MOOGMA_LEGGINGS" to SalvageStrategy.Always, + "FLAMING_CHESTPLATE" to SalvageStrategy.Always, + "TAURUS_HELMET" to SalvageStrategy.Always, + "BLADE_OF_THE_VOLCANO" to SalvageStrategy.Always, + "STAFF_OF_THE_VOLCANO" to SalvageStrategy.Always, + "RAMPART_HELMET" to SalvageStrategy.Always, + "RAMPART_CHESTPLATE" to SalvageStrategy.Always, + "RAMPART_LEGGINGS" to SalvageStrategy.Always, + "RAMPART_BOOTS" to SalvageStrategy.Always, + "SWORD_OF_BAD_HEALTH" to SalvageStrategy.Always, + "ARACHNE_HELMET" to SalvageStrategy.Always, + "ARACHNE_CHESTPLATE" to SalvageStrategy.Always, + "ARACHNE_LEGGINGS" to SalvageStrategy.Always, + "ARACHNE_BOOTS" to SalvageStrategy.Always, + "WITHER_CLOAK_SWORD" to SalvageStrategy.Block, + "DARK_CLAYMORE" to SalvageStrategy.Block, + "GIANTS_SWORD" to SalvageStrategy.Block, + "WITHER_HELMET" to SalvageStrategy.Block, + "WITHER_CHESTPLATE" to SalvageStrategy.Block, + "WITHER_LEGGINGS" to SalvageStrategy.Block, + "WITHER_BOOTS" to SalvageStrategy.Block, + "ICE_SPRAY_WAND" to SalvageStrategy.Block, + "SHADOW_ASSASSIN_HELMET" to SalvageStrategy.Block, + "SHADOW_ASSASSIN_CHESTPLATE" to SalvageStrategy.Block, + "SHADOW_ASSASSIN_LEGGINGS" to SalvageStrategy.Block, + "SHADOW_ASSASSIN_BOOTS" to SalvageStrategy.Block, + ) ) { fun save() { diff --git a/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt b/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt index 276abc3..563f0f2 100644 --- a/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt +++ b/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt @@ -9,9 +9,9 @@ import net.minecraftforge.fml.common.eventhandler.Event // credit Harry282/Skyblock-Client, under AGPL 3.0 open class GuiContainerEvent(val container: Container, val gui: GuiContainer) : Event() { @Cancelable - class DrawSlotEvent(container: Container, gui: GuiContainer, var slot: Slot) : GuiContainerEvent(container, gui) + class DrawSlotEvent(container: Container, gui: GuiContainer, val slot: Slot) : GuiContainerEvent(container, gui) @Cancelable - class SlotClickEvent(container: Container, gui: GuiContainer, var slot: Slot?, var slotId: Int) : + class SlotClickEvent(container: Container, gui: GuiContainer, val slot: Slot?, val slotId: Int) : GuiContainerEvent(container, gui) }
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt b/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt new file mode 100644 index 0000000..256fbe1 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt @@ -0,0 +1,7 @@ +package com.ambientaddons.events + +import net.minecraft.util.BlockPos +import net.minecraft.util.EnumFacing +import net.minecraftforge.fml.common.eventhandler.Event + +class HitBlockEvent(val blockPos: BlockPos, val face: EnumFacing) : Event()
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt index 612ae1b..fbe60b0 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt @@ -13,7 +13,7 @@ import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object MelodyHelper { - private val completedStageRegex = Regex("/^[\\w]{2,16} (?:completed|activated) a (?:lever|terminal|device)! \\((?:[07]/7|[08]/8)\\)") + private val completedStageRegex = Regex("^[\\w]{2,16} (?:completed|activated) a (?:lever|terminal|device)! \\((?:[07]/7|[08]/8)\\)") private var hasSaidMeowlody = false private var hasSaidThrottled = false private var isThrottled = false diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt b/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt new file mode 100644 index 0000000..c90de6e --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt @@ -0,0 +1,7 @@ +package com.ambientaddons.features.misc + +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object Farming { + +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt b/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt index a716758..914870f 100644 --- a/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt +++ b/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt @@ -1,5 +1,121 @@ package com.ambientaddons.features.misc -class Salvage { - +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.events.GuiContainerEvent +import com.ambientaddons.utils.Extensions.chest +import com.ambientaddons.utils.Extensions.itemQuality +import com.ambientaddons.utils.Extensions.items +import com.ambientaddons.utils.Extensions.skyblockID +import com.ambientaddons.utils.Extensions.stars +import com.ambientaddons.utils.SalvageStrategy +import com.ambientaddons.utils.render.OverlayUtils +import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.inventory.Slot +import net.minecraft.item.ItemStack +import net.minecraftforge.client.event.GuiOpenEvent +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color + +object Salvage { + private var status: SalvageStatus = SalvageStatus.Idle + private const val salvageSlot = 31 + private const val clickDelay = 300 + private const val topQualityDelay = 1000 + private var nextClickTime = System.currentTimeMillis() + + private val canClick: Boolean + get() = (System.currentTimeMillis() - nextClickTime) >= 0 + + @SubscribeEvent + fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { + val chest = event.gui?.chest ?: return + if (config.salvageMode < 3 || chest.lowerChestInventory.name != "Salvage Item") return + val color = chest.lowerChestInventory.items.last()?.itemDamage + if (status == SalvageStatus.Waiting && color == 5) { + mc.playerController.windowClick( + chest.windowId, salvageSlot, 0, 0, mc.thePlayer + ) + status = SalvageStatus.Clicked + } else if (status == SalvageStatus.Clicked && chest.lowerChestInventory.getStackInSlot(salvageSlot)?.itemDamage == 5) { + status = SalvageStatus.Confirming + nextClickTime = System.currentTimeMillis() + topQualityDelay + } else if ((status == SalvageStatus.Clicked || status == SalvageStatus.Confirmed) && color == 14) { + status = SalvageStatus.Idle + nextClickTime = System.currentTimeMillis() + clickDelay + } else if (status == SalvageStatus.Confirming && canClick) { + mc.playerController.windowClick( + chest.windowId, salvageSlot, 0, 0, mc.thePlayer + ) + status = SalvageStatus.Confirmed + nextClickTime = System.currentTimeMillis() + clickDelay + } else if (config.salvageMode == 4 && status == SalvageStatus.Idle && canClick) { + val salvageableItemIndex = chest.inventory.slice(54 until 90).indexOfFirst { + if (it == null) false else getSalvageStrategy(it) == SalvageStrategy.Always + } + if (salvageableItemIndex != -1) { + mc.playerController.windowClick( + chest.windowId, salvageableItemIndex + 54, 0, 1, mc.thePlayer + ) + status = SalvageStatus.Waiting + } + } + } + + @SubscribeEvent + fun onContainerOpen(event: GuiOpenEvent) { + if (event.gui?.chest == null) return + status = SalvageStatus.Idle + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (config.salvageMode < 2 || event.slot == null) return + if (!isSlotInInventory(event.gui, event.slot)) return + if (status != SalvageStatus.Idle + || getSalvageStrategy(event.slot.stack ?: return) == SalvageStrategy.Block + || !canClick + ) { + event.isCanceled = true + mc.thePlayer.playSound("random.pop", 1f, 0f) + } else { + event.isCanceled = true + mc.playerController.windowClick( + event.container.windowId, event.slotId, 0, 1, mc.thePlayer + ) + status = SalvageStatus.Waiting + } + } + + + @SubscribeEvent + fun onDrawSlot(event: GuiContainerEvent.DrawSlotEvent) { + if (config.salvageMode == 0 || !isSlotInInventory(event.gui, event.slot)) return + val color = when (getSalvageStrategy(event.slot.stack ?: return)) { + SalvageStrategy.Always -> Color.GREEN + SalvageStrategy.Allow -> Color.YELLOW + else -> return + } + OverlayUtils.renderRect( + event.slot.xDisplayPosition.toDouble(), event.slot.yDisplayPosition.toDouble(), 16.0, 16.0, color + ) + } + + private enum class SalvageStatus { + Idle, Waiting, Clicked, Confirming, Confirmed + } + + private fun getSalvageStrategy(item: ItemStack): SalvageStrategy { + AmbientAddons.persistentData.salvageMap[item.skyblockID]?.let { return it } + return when { + item.stars != null -> SalvageStrategy.Block + item.itemQuality == 50 -> if (config.topQualityStrategy) SalvageStrategy.Always else SalvageStrategy.Allow + item.itemQuality != null -> SalvageStrategy.Always + else -> SalvageStrategy.Block + } + } + + private fun isSlotInInventory(gui: GuiContainer, slot: Slot): Boolean = + gui.chest?.lowerChestInventory?.let { it.name == "Salvage Item" && it != slot.inventory } ?: false }
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/utils/Extensions.kt b/src/main/kotlin/com/ambientaddons/utils/Extensions.kt index ef4bcf1..62c8c37 100644 --- a/src/main/kotlin/com/ambientaddons/utils/Extensions.kt +++ b/src/main/kotlin/com/ambientaddons/utils/Extensions.kt @@ -55,6 +55,21 @@ object Extensions { return it.getString("id") } + val ItemStack.itemQuality: Int? + get() = this.extraAttributes?.let { + if (!it.hasKey("baseStatBoostPercentage", 3)) return null + return it.getInteger("baseStatBoostPercentage") + } + + val ItemStack.stars: Int? + get() = this.extraAttributes?.let { + return when { + it.hasKey("dungeon_item_level", 3) -> it.getInteger("dungeon_item_level") + it.hasKey("upgrade_level", 3) -> it.getInteger("upgrade_level") + else -> null + } + } + val ItemStack.enchants: Map<String, Int>? get() = this.extraAttributes?.let { extraAttributes -> if (!extraAttributes.hasKey("enchantments", 10)) return null diff --git a/src/main/kotlin/com/ambientaddons/utils/SalvageStrategy.kt b/src/main/kotlin/com/ambientaddons/utils/SalvageStrategy.kt new file mode 100644 index 0000000..992a45c --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/SalvageStrategy.kt @@ -0,0 +1,3 @@ +package com.ambientaddons.utils + +enum class SalvageStrategy { Always, Allow, Block }
\ No newline at end of file |