From ef58e92c169ac94370c8a6dd48146587571cf8d2 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Tue, 23 Aug 2022 22:34:07 +0200 Subject: added rng meter coloring methods --- CHANGELOG.md | 13 +-- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 + .../skyhanni/config/features/Inventory.java | 26 +++++- .../skyhanni/data/ItemRenderBackground.kt | 8 +- .../skyhanni/features/anvil/AnvilCombineHelper.kt | 8 -- .../skyhanni/features/bazaar/BazaarOrderHelper.kt | 8 -- .../features/items/HideNotClickableItems.kt | 4 +- .../skyhanni/features/items/RngMeterInventory.kt | 96 ++++++++++++++++++++++ .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 7 +- .../at/hannibal2/skyhanni/utils/RenderUtils.kt | 7 ++ 10 files changed, 145 insertions(+), 34 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 94ce48984..eb96f3488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,17 +3,18 @@ ## Version 0.5 ### New Features -- Added a display that shows the last time the hopper inside an minion has been emptied -- Added marker to the location of the last clicked minion (even through walls) -- Added option to hide mob nametags close to minions -- Added showing stars on all items (not only dungeon and master stars but also crimson armors and cloaks) +- Added a display that shows the last time the hopper inside a minion has been emptied +- Added a marker to the location of the last clicked minion for a couple of seconds (even through walls) +- Added option to hide mob name tags close to minions +- Added showing stars on all items (not only dungeon stars and master stars but also on crimson armours, cloaks and fishing rods) - Added a display timer that shows the real time +- Added overlay features to the RNG meter inventory (highlight selected drop and floors without a drop and show floor) ### Minor Changes - Summoning souls display is rendering better close to corners - Ashfang gravity orbs are now rendering better close to corners -- Showing the name of ashfang gravity orbs as a nametag above -- Bazaar how knows books and essences (thanks again, hypixel) +- Showing the name of ashfang gravity orbs as a name tag above +- Bazaar how knows books and essences (thanks again, HyPixel) ### Bug Fixes - Fixed damage Indicator damage over time display order swapping sometimes \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index a12348214..e1ce44eec 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.features.fishing.TrophyFishMessages; import at.hannibal2.skyhanni.features.items.HideNotClickableItems; import at.hannibal2.skyhanni.features.items.ItemDisplayOverlayFeatures; import at.hannibal2.skyhanni.features.items.ItemStars; +import at.hannibal2.skyhanni.features.items.RngMeterInventory; import at.hannibal2.skyhanni.features.items.abilitycooldown.ItemAbilityCooldown; import at.hannibal2.skyhanni.features.minion.MinionFeatures; import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown; @@ -91,6 +92,7 @@ public class SkyHanniMod { registerEvent(new ItemStars()); registerEvent(new MinionFeatures()); registerEvent(new RealTime()); + registerEvent(new RngMeterInventory()); Commands.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index e2231a9d1..ba11c6098 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -1,8 +1,6 @@ package at.hannibal2.skyhanni.config.features; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorBoolean; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigEditorDraggableList; -import at.hannibal2.skyhanni.config.gui.core.config.annotations.ConfigOption; +import at.hannibal2.skyhanni.config.gui.core.config.annotations.*; import com.google.gson.annotations.Expose; import java.util.ArrayList; @@ -48,4 +46,26 @@ public class Inventory { desc = "Show a compact star count in the item name for all items") @ConfigEditorBoolean public boolean itemStars = false; + + @ConfigOption(name = "RNG Meter", desc = "") + @ConfigEditorAccordion(id = 0) + public boolean rngMeter = false; + + @Expose + @ConfigOption(name = "Floor Names", desc = "Show the floor names in the catacombs rng meter inventory") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean rngMeterFloorName = false; + + @Expose + @ConfigOption(name = "No Drop", desc = "Highlight floors without a drop selected in the catacombs rng meter inventory") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean rngMeterNoDrop = false; + + @Expose + @ConfigOption(name = "Selected Drop", desc = "Highlight the selected drop in the catacombs oder slayer rng meter inventory") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean rngMeterSelectedDrop = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt index ad815ad23..9b25933ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt @@ -12,16 +12,16 @@ class ItemRenderBackground { companion object { - val map = mutableMapOf() - val mapTime = mutableMapOf() + private val mapColor = mutableMapOf() + private val mapTime = mutableMapOf() var ItemStack.background: Int get() { if (System.currentTimeMillis() > mapTime.getOrDefault(this, 0) + 200) return -1 - return map.getOrDefault(this, -1) + return mapColor.getOrDefault(this, -1) } set(value) { - map[this] = value + mapColor[this] = value mapTime[this] = System.currentTimeMillis() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt index 251c4e7a6..b2d397714 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt @@ -7,10 +7,8 @@ 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.minecraftforge.fml.common.eventhandler.SubscribeEvent -import org.lwjgl.opengl.GL11 class AnvilCombineHelper { @@ -46,10 +44,6 @@ class AnvilCombineHelper { } } - val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING) - GlStateManager.disableLighting() - GlStateManager.color(1f, 1f, 1f, 1f) - if (matchLore.isEmpty()) return for (slot in chest.inventorySlots) { @@ -75,8 +69,6 @@ class AnvilCombineHelper { //// slot highlight LorenzColor.YELLOW //// } // } - - if (lightingState) GlStateManager.enableLighting() } } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt index 893a356c4..31bc1e978 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt @@ -7,10 +7,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor 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.minecraftforge.fml.common.eventhandler.SubscribeEvent -import org.lwjgl.opengl.GL11 class BazaarOrderHelper { @@ -29,11 +27,7 @@ class BazaarOrderHelper { val guiChest = event.gui val chest = guiChest.inventorySlots as ContainerChest val inventoryName = chest.lowerChestInventory.displayName.unformattedText.trim() - if (!isBazaarOrderInventory(inventoryName)) return - val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING) - GlStateManager.disableLighting() - GlStateManager.color(1f, 1f, 1f, 1f) out@ for (slot in chest.inventorySlots) { if (slot == null) continue @@ -71,7 +65,5 @@ class BazaarOrderHelper { } } } - - if (lightingState) GlStateManager.enableLighting() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt index a96632d74..cee707155 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt @@ -94,7 +94,7 @@ class HideNotClickableItems { val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() val stack = event.itemStack - if (ItemUtils.getItemsInOpenChest().contains(stack)) return + if (ItemUtils.getItemsInOpenChest().map { it.stack }.contains(stack)) return if (!ItemUtils.getItemsInInventory().contains(stack)) return if (hide(chestName, stack)) { @@ -104,7 +104,7 @@ class HideNotClickableItems { event.toolTip.add("") if (hideReason == "") { event.toolTip.add("§4No hide reason!") - LorenzUtils.warning("Not hide reason for not clickable item!") + LorenzUtils.warning("No hide reason for not clickable item!") } else { event.toolTip.add("§c$hideReason") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt new file mode 100644 index 000000000..1c0c4cfb5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt @@ -0,0 +1,96 @@ +package at.hannibal2.skyhanni.features.items + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.between +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RngMeterInventory { + + @SubscribeEvent + fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) { + if (!LorenzUtils.inSkyblock) return + + val screen = Minecraft.getMinecraft().currentScreen + if (screen !is GuiChest) return + val chest = screen.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + var stackTip = "" + + val stack = event.stack ?: return + if (SkyHanniMod.feature.inventory.rngMeterFloorName) { + if (chestName == "Catacombs RNG Meter") { + val name = stack.name ?: return + if (name.removeColor() == "RNG Meter") { + stackTip = stack.getLore()[0].between("(", ")") + } + } + } + + + if (stackTip.isNotEmpty()) { + GlStateManager.disableLighting() + GlStateManager.disableDepth() + GlStateManager.disableBlend() + event.fontRenderer.drawStringWithShadow( + stackTip, + (event.x + 17 - event.fontRenderer.getStringWidth(stackTip)).toFloat(), + (event.y + 9).toFloat(), + 16777215 + ) + GlStateManager.enableLighting() + GlStateManager.enableDepth() + } + } + + @SubscribeEvent(priority = EventPriority.LOW) + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyblock) 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 (SkyHanniMod.feature.inventory.rngMeterNoDrop) { + if (chestName == "Catacombs RNG Meter") { + for (slot in ItemUtils.getItemsInOpenChest()) { + val stack = slot.stack + if (stack.getLore().any { it.contains("You don't have an RNG drop") }) { + slot highlight LorenzColor.RED +// val color = LorenzColor.RED.addOpacity(160) +// slot.stack.background = color.rgb + //TODO use other coloring logic + } + } + } + } + + if (SkyHanniMod.feature.inventory.rngMeterSelectedDrop) { + if (chestName.endsWith(" RNG Meter")) { + for (slot in ItemUtils.getItemsInOpenChest()) { + val stack = slot.stack + if (stack.getLore().any { it.contains("§aSELECTED") }) { + slot highlight LorenzColor.YELLOW +// val color = LorenzColor.YELLOW.addOpacity(160) +// slot.stack.background = color.rgb + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index c9ddea9a8..24c3d822a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -7,6 +7,7 @@ import com.google.gson.JsonObject import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.init.Items +import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack import net.minecraftforge.common.util.Constants import java.util.* @@ -16,8 +17,8 @@ object ItemUtils { fun ItemStack.cleanName() = this.displayName.removeColor() - fun getItemsInOpenChest(): List { - val list = mutableListOf() + fun getItemsInOpenChest(): List { + val list = mutableListOf() val guiChest = Minecraft.getMinecraft().currentScreen as GuiChest val inventorySlots = guiChest.inventorySlots.inventorySlots val skipAt = inventorySlots.size - 9 * 4 @@ -25,7 +26,7 @@ object ItemUtils { for (slot in inventorySlots) { val stack = slot.stack if (stack != null) { - list.add(stack) + list.add(slot) } i++ if (i == skipAt) break diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 453b220e5..9de886f37 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -28,6 +28,11 @@ object RenderUtils { } infix fun Slot.highlight(color: Color) { + val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING) + + GlStateManager.disableLighting() + GlStateManager.color(1f, 1f, 1f, 1f) + GlStateManager.pushMatrix() GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel) Gui.drawRect( @@ -38,6 +43,8 @@ object RenderUtils { color.rgb ) GlStateManager.popMatrix() + + if (lightingState) GlStateManager.enableLighting() } fun RenderWorldLastEvent.drawColor(location: LorenzVec, color: LorenzColor, beacon: Boolean = false) { -- cgit