From 62efc12ae194f8aee0bac3991ed584f9e426e549 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Sat, 23 Jul 2022 08:40:56 +0200 Subject: adding anvil combine helper feature --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 + .../at/hannibal2/skyhanni/config/Features.java | 10 +-- .../skyhanni/config/features/Inventory.java | 71 ++++++++++++++++++ .../hannibal2/skyhanni/config/features/Items.java | 66 ----------------- .../skyhanni/inventory/anvil/AnvilCombineHelper.kt | 83 ++++++++++++++++++++++ .../skyhanni/items/HideNotClickableItems.kt | 2 +- .../skyhanni/items/ItemDisplayOverlayFeatures.kt | 14 ++-- .../items/abilitycooldown/ItemAbilityCooldown.kt | 2 +- 8 files changed, 167 insertions(+), 83 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/Items.java create mode 100644 src/main/java/at/hannibal2/skyhanni/inventory/anvil/AnvilCombineHelper.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 1f63c54ac..2e5aa8cff 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.config.gui.commands.Commands; import at.hannibal2.skyhanni.dungeon.*; import at.hannibal2.skyhanni.dungeon.damageindicator.DungeonBossDamageIndicator; import at.hannibal2.skyhanni.fishing.TrophyFishMessages; +import at.hannibal2.skyhanni.inventory.anvil.AnvilCombineHelper; import at.hannibal2.skyhanni.items.HideNotClickableItems; import at.hannibal2.skyhanni.items.ItemDisplayOverlayFeatures; import at.hannibal2.skyhanni.items.abilitycooldown.ItemAbilityCooldown; @@ -71,6 +72,7 @@ public class SkyHanniMod { MinecraftForge.EVENT_BUS.register(new DungeonBossMessages()); MinecraftForge.EVENT_BUS.register(new TrophyFishMessages()); MinecraftForge.EVENT_BUS.register(new BazaarBestSellMethod()); + MinecraftForge.EVENT_BUS.register(new AnvilCombineHelper()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 990bbae5c..a45ad3abd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -62,8 +62,8 @@ public class Features { public Dungeon dungeon = new Dungeon(); @Expose - @Category(name = "Items", desc = "Changing the behavior around items and the inventory.") - public Items items = new Items(); + @Category(name = "Inventory", desc = "Changing the behavior around items and the inventory.") + public Inventory inventory = new Inventory(); @Expose @Category(name = "Bazaar", desc = "Bazaar settings.") @@ -84,10 +84,4 @@ public class Features { @Expose @Category(name = "Debug", desc = "Debug and test stuff.") public Debug debug = new Debug(); - - - - - - } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java new file mode 100644 index 000000000..eddb9fe15 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -0,0 +1,71 @@ +package at.hannibal2.skyhanni.config.features; + +import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigAccordionId; +import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorAccordion; +import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean; +import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption; +import com.google.gson.annotations.Expose; + +public class Inventory { + + @Expose + @ConfigOption(name = "Not Clickable Items", desc = "Hide items that are not clickable in " + "the current inventory: ah, bz, accessory bag, etc") + @ConfigEditorBoolean + public boolean hideNotClickableItems = false; + + @Expose + @ConfigOption(name = "Item number as stack size", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean filterTypes = false; + + @Expose + @ConfigOption(name = "Master Star Number", desc = "Show the Tier of the Master Star.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayMasterStarNumber = false; + + @Expose + @ConfigOption(name = "Master Skull Number", desc = "Show the tier of the Master Skull accessory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayMasterSkullNumber = false; + + @Expose + @ConfigOption(name = "Dungeon Head Floor", desc = "Show the correct floor for golden and diamond heads.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayDungeonHeadFloor = false; + + @Expose + @ConfigOption(name = "New Year Cake", desc = "Show the Number of the Year of New Year Cakes.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayNewYearCakeNumber = false; + + @Expose + @ConfigOption(name = "Pet Level", desc = "Show the level of the pet when not maxed.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayPetLevel = false; + + @Expose + @ConfigOption(name = "Minion Tier", desc = "Show the Minion Tier over Items.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayMinionTier = false; + + @Expose + @ConfigOption(name = "Sack Name", desc = "Show an abbreviation of the Sack name.") + @ConfigEditorBoolean + public boolean displaySackName = false; + + @Expose + @ConfigOption(name = "Ability Cooldown", desc = "Show the cooldown of item abilities.") + @ConfigEditorBoolean + public boolean itemAbilityCooldown = false; + + @Expose + @ConfigOption(name = "Anvil Combine Helper", desc = "Suggests the same item in the inventory when trying to combine two items in the anvil.") + @ConfigEditorBoolean + public boolean anvilCombineHelper = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Items.java b/src/main/java/at/hannibal2/skyhanni/config/features/Items.java deleted file mode 100644 index 2c172aa9f..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Items.java +++ /dev/null @@ -1,66 +0,0 @@ -package at.hannibal2.skyhanni.config.features; - -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigAccordionId; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorAccordion; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption; -import com.google.gson.annotations.Expose; - -public class Items { - - @Expose - @ConfigOption(name = "Not Clickable Items", desc = "Hide items that are not clickable in " + "the current inventory: ah, bz, accessory bag, etc") - @ConfigEditorBoolean - public boolean hideNotClickableItems = false; - - @Expose - @ConfigOption(name = "Item number as stack size", desc = "") - @ConfigEditorAccordion(id = 2) - public boolean filterTypes = false; - - @Expose - @ConfigOption(name = "Master Star Number", desc = "Show the Tier of the Master Star.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean displayMasterStarNumber = false; - - @Expose - @ConfigOption(name = "Master Skull Number", desc = "Show the tier of the Master Skull accessory.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean displayMasterSkullNumber = false; - - @Expose - @ConfigOption(name = "Dungeon Head Floor", desc = "Show the correct floor for golden and diamond heads.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean displayDungeonHeadFloor = false; - - @Expose - @ConfigOption(name = "New Year Cake", desc = "Show the Number of the Year of New Year Cakes.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean displayNewYearCakeNumber = false; - - @Expose - @ConfigOption(name = "Pet Level", desc = "Show the level of the pet when not maxed.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean displayPetLevel = false; - - @Expose - @ConfigOption(name = "Minion Tier", desc = "Show the Minion Tier over Items.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 2) - public boolean displayMinionTier = false; - - @Expose - @ConfigOption(name = "Sack Name", desc = "Show an abbreviation of the Sack name.") - @ConfigEditorBoolean - public boolean displaySackName = false; - - @Expose - @ConfigOption(name = "Ability Cooldown", desc = "Show the cooldown of item abilities.") - @ConfigEditorBoolean - public boolean itemAbilityCooldown = false; -} diff --git a/src/main/java/at/hannibal2/skyhanni/inventory/anvil/AnvilCombineHelper.kt b/src/main/java/at/hannibal2/skyhanni/inventory/anvil/AnvilCombineHelper.kt new file mode 100644 index 000000000..03405090b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/inventory/anvil/AnvilCombineHelper.kt @@ -0,0 +1,83 @@ +package at.hannibal2.skyhanni.inventory.anvil + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.inventory.ContainerChest +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.opengl.GL11 + +class AnvilCombineHelper { + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyblock) return + if (!SkyHanniMod.feature.inventory.anvilCombineHelper) return + + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + if (chestName != "Anvil") return + + val matchLore = mutableListOf() +// var compareItem: ItemStack? = null + + for (slot in chest.inventorySlots) { + if (slot == null) continue + + if (slot.slotNumber != slot.slotIndex) continue + if (slot.stack == null) continue + + if (slot.slotNumber == 29) { +// slot highlight LorenzColor.GREEN + val lore = slot.stack.getLore() +// compareItem = slot.stack + matchLore.addAll(lore) + break +// } else if (slot.slotIndex == 29) { +// slot highlight LorenzColor.YELLOW + } + } + + val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING) + GlStateManager.disableLighting() + GlStateManager.color(1f, 1f, 1f, 1f) + + if (matchLore.isEmpty()) return + + for (slot in chest.inventorySlots) { + if (slot == null) continue + + if (slot.slotNumber == slot.slotIndex) continue + if (slot.stack == null) continue + + + if (matchLore == slot.stack.getLore()) { + slot highlight LorenzColor.GREEN + } + +// if (compareItem == slot.stack) { +// slot highlight LorenzColor.GREEN +// } else if (compareItem.metadata == slot.stack.metadata) { +// slot highlight LorenzColor.YELLOW +// } + +// if (slot.slotNumber == 3) { +//// slot highlight LorenzColor.GREEN +//// } else if (slot.slotIndex == 4) { +//// slot highlight LorenzColor.YELLOW +//// } +// } + + if (lightingState) GlStateManager.enableLighting() + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt index 97eefe1ab..57b727791 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt @@ -164,7 +164,7 @@ class HideNotClickableItems { private fun isDisabled(): Boolean { if (bypassUntil > System.currentTimeMillis()) return true - return !SkyHanniMod.feature.items.hideNotClickableItems + return !SkyHanniMod.feature.inventory.hideNotClickableItems } private fun hide(chestName: String, stack: ItemStack): Boolean { diff --git a/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt index d5054ae47..6a3f7688c 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt @@ -42,7 +42,7 @@ class ItemDisplayOverlayFeatures { private fun getStackTip(item: ItemStack): String { val name = item.cleanName() - if (SkyHanniMod.feature.items.displayMasterStarNumber) { + if (SkyHanniMod.feature.inventory.displayMasterStarNumber) { when (name) { "First Master Star" -> return "1" "Second Master Star" -> return "2" @@ -52,13 +52,13 @@ class ItemDisplayOverlayFeatures { } } - if (SkyHanniMod.feature.items.displayMasterSkullNumber) { + if (SkyHanniMod.feature.inventory.displayMasterSkullNumber) { if (name.matchRegex("(.*)Master Skull - Tier .")) { return name.substring(name.length - 1) } } - if (SkyHanniMod.feature.items.displayDungeonHeadFloor) { + if (SkyHanniMod.feature.inventory.displayDungeonHeadFloor) { if (name.contains("Golden ") || name.contains("Diamond ")) { when { name.contains("Bonzo") -> return "1" @@ -72,13 +72,13 @@ class ItemDisplayOverlayFeatures { } } - if (SkyHanniMod.feature.items.displayNewYearCakeNumber) { + if (SkyHanniMod.feature.inventory.displayNewYearCakeNumber) { if (name.startsWith("New Year Cake (")) { return "§b" + name.between("(Year ", ")") } } - if (SkyHanniMod.feature.items.displayPetLevel) { + if (SkyHanniMod.feature.inventory.displayPetLevel) { if (ItemUtils.isPet(name)) { val level = name.between("Lvl ", "] ").toInt() if (level != ItemUtils.maxPetLevel(name)) { @@ -87,7 +87,7 @@ class ItemDisplayOverlayFeatures { } } - if (SkyHanniMod.feature.items.displaySackName) { + if (SkyHanniMod.feature.inventory.displaySackName) { if (ItemUtils.isSack(name)) { //TODO fix this and replace other // val sackName = grabSackName(name) @@ -97,7 +97,7 @@ class ItemDisplayOverlayFeatures { } } - if (SkyHanniMod.feature.items.displayMinionTier) { + if (SkyHanniMod.feature.inventory.displayMinionTier) { if (name.contains(" Minion ")) { if (item.getLore().any { it.contains("Place this minion") }) { val array = name.split(" ") diff --git a/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt index 708b81693..726c3172f 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt @@ -53,7 +53,7 @@ class ItemAbilityCooldown { } private fun isEnabled(): Boolean { - return LorenzUtils.inSkyblock && SkyHanniMod.feature.items.itemAbilityCooldown + return LorenzUtils.inSkyblock && SkyHanniMod.feature.inventory.itemAbilityCooldown } private fun click(ability: Ability) { -- cgit