aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt67
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderGuiItemOverlayEvent.kt (renamed from src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt)4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt45
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt60
10 files changed, 120 insertions, 123 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 45055829c..0a7569e3e 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -31,7 +31,6 @@ import at.hannibal2.skyhanni.data.HighlightOnHoverSlot
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.ItemAddManager
import at.hannibal2.skyhanni.data.ItemClickData
-import at.hannibal2.skyhanni.data.ItemRenderBackground
import at.hannibal2.skyhanni.data.ItemTipHelper
import at.hannibal2.skyhanni.data.LocationFixData
import at.hannibal2.skyhanni.data.MaxwellAPI
@@ -478,7 +477,6 @@ class SkyHanniMod {
loadModule(ScoreboardData())
loadModule(SeaCreatureFeatures())
loadModule(SeaCreatureManager())
- loadModule(ItemRenderBackground())
loadModule(EntityData())
loadModule(MobData())
loadModule(MobDetection())
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
deleted file mode 100644
index ba150a72b..000000000
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-package at.hannibal2.skyhanni.data
-
-import at.hannibal2.skyhanni.events.RenderRealOverlayEvent
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.TimeLimitedCache
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.Gui
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraft.item.ItemStack
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import kotlin.time.Duration.Companion.milliseconds
-
-class ItemRenderBackground {
-
- companion object {
-
- private val backgroundColour = TimeLimitedCache<ItemStack, Int>(60.milliseconds)
- private val borderLineColour = TimeLimitedCache<ItemStack, Int>(60.milliseconds)
-
- var ItemStack.background: Int
- get() {
- return backgroundColour.getOrNull(this) ?: -1
- }
- set(value) {
- backgroundColour.put(this, value)
- }
-
- var ItemStack.borderLine: Int
- get() {
- return borderLineColour.getOrNull(this) ?: -1
- }
- set(value) {
- borderLineColour.put(this, value)
- }
- }
-
- @SubscribeEvent
- fun onRenderRealOverlay(event: RenderRealOverlayEvent) {
- val stack = event.stack ?: return
- if (!LorenzUtils.inSkyBlock) return
-
- val backgroundColor = stack.background
- if (backgroundColor != -1) {
- GlStateManager.pushMatrix()
- GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
- val x = event.x
- val y = event.y
- Gui.drawRect(x, y, x + 16, y + 16, backgroundColor)
- GlStateManager.popMatrix()
- }
-
- val borderLineColor = stack.borderLine
- if (borderLineColor != -1) {
- GlStateManager.pushMatrix()
- GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
- val x = event.x
- val y = event.y
-
- Gui.drawRect(x, y, x + 1, y + 16, borderLineColor)
- Gui.drawRect(x, y, x + 16, y + 1, borderLineColor)
-
- Gui.drawRect(x, y + 15, x + 16, y + 16, borderLineColor)
- Gui.drawRect(x + 15, y, x + 16, y + 16, borderLineColor)
- GlStateManager.popMatrix()
- }
- }
-}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderGuiItemOverlayEvent.kt
index a6b547add..0db2e4e14 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderGuiItemOverlayEvent.kt
@@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.events
import net.minecraft.item.ItemStack
-class RenderRealOverlayEvent(
+class RenderGuiItemOverlayEvent(
val stack: ItemStack?,
val x: Int,
val y: Int,
-) : LorenzEvent() \ No newline at end of file
+) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt
index 41e1b59b7..2336ce65a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt
@@ -1,7 +1,5 @@
package at.hannibal2.skyhanni.features.garden.visitor
-import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
-import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.borderLine
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.ACCEPT_SLOT
@@ -13,8 +11,10 @@ import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.NumberUtil
+import at.hannibal2.skyhanni.utils.RenderUtils.drawBorder
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import net.minecraft.item.ItemStack
+import net.minecraft.inventory.Slot
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -23,26 +23,29 @@ class VisitorRewardWarning {
private val config get() = VisitorAPI.config.rewardWarning
@SubscribeEvent
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ fun onBackgroundDrawn(event: GuiContainerEvent.ForegroundDrawnEvent) {
if (!VisitorAPI.inInventory) return
if (!config.preventRefusing && !config.preventRefusingCopper && !config.preventAcceptingCopper) return
val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return
- val refuseOfferStack = event.gui.inventorySlots.getSlot(REFUSE_SLOT).stack
- val acceptOfferStack = event.gui.inventorySlots.getSlot(ACCEPT_SLOT).stack
+ val refuseOfferSlot = event.gui.inventorySlots.getSlot(REFUSE_SLOT)
+ val acceptOfferSlot = event.gui.inventorySlots.getSlot(ACCEPT_SLOT)
val blockReason = visitor.blockReason ?: return
if (blockReason.blockRefusing) {
- renderColor(refuseOfferStack, acceptOfferStack, LorenzColor.GREEN)
+ renderColor(refuseOfferSlot, acceptOfferSlot, LorenzColor.GREEN)
} else {
- renderColor(acceptOfferStack, refuseOfferStack, LorenzColor.RED)
+ renderColor(acceptOfferSlot, refuseOfferSlot, LorenzColor.RED)
}
}
- private fun renderColor(backgroundStack: ItemStack?, outlineStack: ItemStack?, outlineColor: LorenzColor) {
- if (!config.bypassKey.isKeyHeld()) backgroundStack?.background =
- LorenzColor.DARK_GRAY.addOpacity(config.opacity).rgb
- if (config.optionOutline) outlineStack?.borderLine = outlineColor.addOpacity(200).rgb
+ private fun renderColor(backgroundSlot: Slot?, outlineSlot: Slot?, outlineColor: LorenzColor) {
+ if (!config.bypassKey.isKeyHeld() && backgroundSlot != null) {
+ backgroundSlot highlight LorenzColor.DARK_GRAY.addOpacity(config.opacity)
+ }
+ if (config.optionOutline && outlineSlot != null) {
+ outlineSlot drawBorder outlineColor.addOpacity(200)
+ }
}
@SubscribeEvent(priority = EventPriority.HIGH)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
index b67c03ad3..60ce618c8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
@@ -2,8 +2,6 @@ package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
-import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.borderLine
import at.hannibal2.skyhanni.data.jsonobjects.repo.HideNotClickableItemsJson
import at.hannibal2.skyhanni.data.jsonobjects.repo.HideNotClickableItemsJson.SalvageFilter
import at.hannibal2.skyhanni.events.GuiContainerEvent
@@ -33,6 +31,8 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.MultiFilter
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.RenderUtils.drawBorder
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isMuseumDonated
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftExportable
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftTransferable
@@ -93,7 +93,7 @@ class HideNotClickableItems {
}
@SubscribeEvent
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ fun onBackgroundDrawn(event: GuiContainerEvent.ForegroundDrawnEvent) {
if (!LorenzUtils.inSkyBlock) return
if (isDisabled()) return
if (bypasssActive()) return
@@ -102,14 +102,11 @@ class HideNotClickableItems {
val chest = guiChest.inventorySlots as ContainerChest
val chestName = chest.getInventoryName()
- for ((_, stack) in chest.getLowerItems()) {
+ for ((slot, stack) in chest.getLowerItems()) {
if (hide(chestName, stack)) {
- val opacity = config.opacity
- val color = LorenzColor.DARK_GRAY.addOpacity(opacity)
- stack.background = color.rgb
+ slot highlight LorenzColor.DARK_GRAY.addOpacity(config.opacity)
} else if (showGreenLine && config.itemsGreenLine) {
- val color = LorenzColor.GREEN.addOpacity(200)
- stack.borderLine = color.rgb
+ slot drawBorder LorenzColor.GREEN.addOpacity(200)
}
}
}
@@ -386,7 +383,6 @@ class HideNotClickableItems {
if (!chestName.startsWith("Sack of Sacks")) return false
if (ItemUtils.isSkyBlockMenuItem(stack)) return false
- val name = stack.cleanName()
showGreenLine = true
if (ItemUtils.isSack(stack)) return false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
index 1a88f1185..78ed735ec 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
@@ -11,6 +10,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
@@ -56,7 +56,7 @@ class QuickCraftFeatures {
}
@SubscribeEvent
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ fun onBackgroundDrawn(event: GuiContainerEvent.ForegroundDrawnEvent) {
val inventoryType = getInventoryType() ?: return
if (KeyboardManager.isModifierKeyDown()) return
if (event.gui !is GuiChest) return
@@ -66,8 +66,7 @@ class QuickCraftFeatures {
if (inventoryType.ignoreSlot(slot.slotNumber)) continue
if (stack.name == "§cQuick Crafting Slot") continue
if (needsQuickCraftConfirmation(stack)) {
- val color = LorenzColor.DARK_GRAY.addOpacity(180)
- stack.background = color.rgb
+ slot highlight LorenzColor.DARK_GRAY.addOpacity(180)
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
index 998e25e35..c48a28eff 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt
@@ -2,18 +2,19 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background
import at.hannibal2.skyhanni.events.ActionBarUpdateEvent
import at.hannibal2.skyhanni.events.ItemClickEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PlaySoundEvent
+import at.hannibal2.skyhanni.events.RenderGuiItemOverlayEvent
import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.events.RenderObject
import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbility.Companion.getMultiplier
import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown
import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
+import at.hannibal2.skyhanni.utils.CollectionUtils.mapKeysNotNull
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
@@ -23,6 +24,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemId
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemUuid
@@ -48,7 +50,7 @@ class ItemAbilityCooldown {
)
private var lastAbility = ""
- private var items = mapOf<ItemStack, List<ItemText>>()
+ private var items = mapOf<String, List<ItemText>>()
private var abilityItems = mapOf<ItemStack, MutableList<ItemAbility>>()
private val WEIRD_TUBA = "WEIRD_TUBA".asInternalName()
private val WEIRDER_TUBA = "WEIRDER_TUBA".asInternalName()
@@ -254,7 +256,12 @@ class ItemAbilityCooldown {
abilityItems = ItemUtils.getItemsInInventory(true).associateWith { hasAbility(it) }
}
- items = abilityItems.mapValues { kp -> kp.value.map { createItemText(it) } }
+ items = abilityItems.entries.associateByTo(
+ mutableMapOf(),
+ { it.key.getIdentifier() },
+ { kp -> kp.value.map { createItemText(it) } }
+ ).mapKeysNotNull { it.key }
+
}
private fun createItemText(ability: ItemAbility): ItemText {
@@ -291,8 +298,7 @@ class ItemAbilityCooldown {
val guiOpen = Minecraft.getMinecraft().currentScreen != null
val uuid = stack.getIdentifier() ?: return
- val list = items.filter { (it.key.getIdentifier()) == uuid }
- .firstNotNullOfOrNull { it.value } ?: return
+ val list = items[uuid] ?: return
for (itemText in list) {
if (guiOpen && !itemText.onCooldown) continue
@@ -303,16 +309,31 @@ class ItemAbilityCooldown {
renderObject.offsetY = -10
}
event.renderObjects.add(renderObject)
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderItem(event: RenderGuiItemOverlayEvent) {
+ if (!isEnabled()) return
+ if (!config.itemAbilityCooldownBackground) return
+
+ val guiOpen = Minecraft.getMinecraft().currentScreen != null
+ val stack = event.stack
+
+ val uuid = stack?.getIdentifier() ?: return
+ val list = items[uuid] ?: return
+
+ for (itemText in list) {
+ if (guiOpen && !itemText.onCooldown) continue
+ val color = itemText.color
// fix multiple problems when having multiple abilities
- if (config.itemAbilityCooldownBackground) {
- var opacity = 130
- if (color == LorenzColor.GREEN) {
- opacity = 80
- if (!config.itemAbilityShowWhenReady) return
- }
- stack.background = color.addOpacity(opacity).rgb
+ var opacity = 130
+ if (color == LorenzColor.GREEN) {
+ opacity = 80
+ if (!config.itemAbilityShowWhenReady) return
}
+ event highlight color.addOpacity(opacity)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt
index 38568987f..7d776e99b 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.mixins.hooks
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
-import at.hannibal2.skyhanni.events.RenderRealOverlayEvent
+import at.hannibal2.skyhanni.events.RenderGuiItemOverlayEvent
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import net.minecraft.client.gui.FontRenderer
import net.minecraft.item.ItemStack
@@ -25,5 +25,5 @@ fun renderItemOverlayPost(
fun renderItemReturn(stack: ItemStack, x: Int, y: Int) {
if (!SkyHanniDebugsAndTests.globalRender) return
- RenderRealOverlayEvent(stack, x, y).postAndCatch()
+ RenderGuiItemOverlayEvent(stack, x, y).postAndCatch()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
index d33729ae3..f538f2d53 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
@@ -262,4 +262,15 @@ object CollectionUtils {
addString("§a]")
}))
}
+
+ inline fun <K, V, R : Any> Map<K, V>.mapKeysNotNull(transform: (Map.Entry<K, V>) -> R?): Map<R, V> {
+ val destination = LinkedHashMap<R, V>()
+ for (element in this) {
+ val newKey = transform(element)
+ if (newKey != null) {
+ destination[newKey] = element.value
+ }
+ }
+ return destination
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 0c8b2b694..0ea8b76eb 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.RenderGuiItemOverlayEvent
import at.hannibal2.skyhanni.features.misc.RoundedRectangleShader
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.renderables.Renderable
@@ -66,22 +67,57 @@ object RenderUtils {
}
infix fun Slot.highlight(color: Color) {
- GlStateManager.color(1f, 1f, 1f, 1f)
- GlStateManager.pushAttrib()
- GL11.glDisable(GL11.GL_LIGHTING)
- GL11.glEnable(GL11.GL_DEPTH_TEST)
+ highlight(color, xDisplayPosition, yDisplayPosition)
+ }
+
+ infix fun RenderGuiItemOverlayEvent.highlight(color: LorenzColor) {
+ highlight(color.toColor())
+ }
+
+ infix fun RenderGuiItemOverlayEvent.highlight(color: Color) {
+ highlight(color, x, y)
+ }
+
+ fun highlight(color: Color, x: Int, y: Int) {
+ GlStateManager.disableLighting()
+ GlStateManager.disableDepth()
GlStateManager.pushMatrix()
// TODO don't use z
GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
- Gui.drawRect(
- this.xDisplayPosition,
- this.yDisplayPosition,
- this.xDisplayPosition + 16,
- this.yDisplayPosition + 16,
- color.rgb
- )
+ Gui.drawRect(x, y, x + 16, y + 16, color.rgb)
GlStateManager.popMatrix()
- GlStateManager.popAttrib()
+ GlStateManager.enableDepth()
+ GlStateManager.enableLighting()
+ }
+
+ infix fun Slot.drawBorder(color: LorenzColor) {
+ drawBorder(color.toColor())
+ }
+
+ infix fun Slot.drawBorder(color: Color) {
+ drawBorder(color, xDisplayPosition, yDisplayPosition)
+ }
+
+ infix fun RenderGuiItemOverlayEvent.drawBorder(color: LorenzColor) {
+ drawBorder(color.toColor())
+ }
+
+ infix fun RenderGuiItemOverlayEvent.drawBorder(color: Color) {
+ drawBorder(color, x, y)
+ }
+
+ fun drawBorder(color: Color, x: Int, y: Int) {
+ GlStateManager.disableLighting()
+ GlStateManager.disableDepth()
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
+ Gui.drawRect(x, y, x + 1, y + 16, color.rgb)
+ Gui.drawRect(x, y, x + 16, y + 1, color.rgb)
+ Gui.drawRect(x, y + 15, x + 16, y + 16, color.rgb)
+ Gui.drawRect(x + 15, y, x + 16, y + 16, color.rgb)
+ GlStateManager.popMatrix()
+ GlStateManager.enableDepth()
+ GlStateManager.enableLighting()
}
fun LorenzRenderWorldEvent.drawColor(