aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/ItemRenderBackground.kt47
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderItemHook.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt9
9 files changed, 93 insertions, 33 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/ItemRenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/ItemRenderBackground.kt
new file mode 100644
index 000000000..bd30ed597
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/ItemRenderBackground.kt
@@ -0,0 +1,47 @@
+package at.hannibal2.skyhanni
+
+import at.hannibal2.skyhanni.events.RenderRealOverlayEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+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
+
+class ItemRenderBackground {
+
+ companion object {
+
+ val map = mutableMapOf<ItemStack, Int>()
+ val mapTime = mutableMapOf<ItemStack, Long>()
+
+ var ItemStack.background: Int
+ get() {
+ if (System.currentTimeMillis() > mapTime.getOrDefault(this, 0) + 100) return -1
+ return map.getOrDefault(this, -1)
+ }
+ set(value) {
+ map[this] = value
+ mapTime[this] = System.currentTimeMillis()
+ }
+ }
+
+
+ @SubscribeEvent
+ fun renderOverlayLol(event: RenderRealOverlayEvent) {
+ val stack = event.stack
+ if (LorenzUtils.inSkyblock) {
+ if (stack != null) {
+ val color = stack.background
+ if (color != -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, color)
+ GlStateManager.popMatrix()
+ }
+ }
+ }
+ }
+} \ 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 03205141b..4ee9472ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -60,6 +60,7 @@ public class SkyHanniMod {
MinecraftForge.EVENT_BUS.register(new ScoreboardData());
MinecraftForge.EVENT_BUS.register(new ApiData());
MinecraftForge.EVENT_BUS.register(new SeaCreatureManager());
+ MinecraftForge.EVENT_BUS.register(new ItemRenderBackground());
MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper());
MinecraftForge.EVENT_BUS.register(new ChatFilter());
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt
new file mode 100644
index 000000000..a6b547add
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderRealOverlayEvent.kt
@@ -0,0 +1,9 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.item.ItemStack
+
+class RenderRealOverlayEvent(
+ val stack: ItemStack?,
+ val x: Int,
+ val y: Int,
+) : LorenzEvent() \ 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 17299253e..a603ff39f 100644
--- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt
@@ -1,25 +1,23 @@
package at.hannibal2.skyhanni.items
+import at.hannibal2.skyhanni.ItemRenderBackground.Companion.background
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.bazaar.BazaarApi
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
-import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes
-import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import com.google.gson.JsonObject
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.minecraft.item.ItemStack
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.opengl.GL11
class HideNotClickableItems {
@@ -73,10 +71,6 @@ class HideNotClickableItems {
val chest = guiChest.inventorySlots as ContainerChest
val chestName = chest.lowerChestInventory.displayName.unformattedText.trim()
- val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING)
- GlStateManager.disableLighting()
- GlStateManager.color(1f, 1f, 1f, 1f)
-
for (slot in chest.inventorySlots) {
if (slot == null) continue
@@ -84,30 +78,10 @@ class HideNotClickableItems {
if (slot.stack == null) continue
if (hide(chestName, slot.stack)) {
- slot highlight LorenzColor.GRAY
+ val color = LorenzColor.DARK_GRAY.addOpacity(160)
+ slot.stack.background = color.rgb
}
}
-
- if (lightingState) GlStateManager.enableLighting()
- }
-
- @SubscribeEvent
- fun onDrawSlot(event: GuiContainerEvent.DrawSlotEvent.Pre) {
- if (isDisabled()) return
- if (event.gui !is GuiChest) return
- val guiChest = event.gui
- val chest = guiChest.inventorySlots as ContainerChest
- val chestName = chest.lowerChestInventory.displayName.unformattedText.trim()
-
- val slot = event.slot
- if (slot.slotNumber == slot.slotIndex) return
- if (slot.stack == null) return
-
- val stack = slot.stack
-
- if (hide(chestName, stack)) {
- event.isCanceled = true
- }
}
@SubscribeEvent(priority = EventPriority.LOWEST)
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 c3358965e..e744f7ca6 100644
--- a/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt
+++ b/src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.items.abilitycooldown
+import at.hannibal2.skyhanni.ItemRenderBackground.Companion.background
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
@@ -107,7 +108,10 @@ class ItemAbilityCooldown {
.firstNotNullOfOrNull { it.value } ?: return
if (guiOpen && !itemText.onCooldown) return
- stackTip = itemText.color.getChatColor() + itemText.text
+ val color = itemText.color
+ stackTip = color.getChatColor() + itemText.text
+
+ item.background = color.addOpacity(120).rgb
if (stackTip.isNotEmpty()) {
GlStateManager.disableLighting()
diff --git a/src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderItemHook.kt b/src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderItemHook.kt
index 3b8dd925d..ae21c622b 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderItemHook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderItemHook.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.mixinhooks
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
+import at.hannibal2.skyhanni.events.RenderRealOverlayEvent
import net.minecraft.client.gui.FontRenderer
import net.minecraft.item.ItemStack
import net.minecraft.util.ResourceLocation
@@ -25,4 +26,8 @@ fun renderItemOverlayPost(
yPosition,
text
).postAndCatch()
-} \ No newline at end of file
+}
+
+fun renderItemReturn(stack: ItemStack, x: Int, y: Int, ci: CallbackInfo) {
+ RenderRealOverlayEvent(stack, x, y).postAndCatch()
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java
index 36be30414..9e41c5ba9 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java
@@ -38,4 +38,9 @@ public abstract class MixinRenderItem {
ci.cancel();
}
}
+
+ @Inject(method = "renderItemIntoGUI", at = @At("RETURN"))
+ public void renderItemReturn(ItemStack stack, int x, int y, CallbackInfo ci) {
+ RenderItemHookKt.renderItemReturn(stack, x, y, ci);
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
index 961ed57ec..69763f0c7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
@@ -24,4 +24,12 @@ enum class LorenzColor(private var chatColorCode: Char, private val color: Color
fun getChatColor(): String = "ยง$chatColorCode"
fun toColor(): Color = color
+
+ fun addOpacity(opacity: Int): Color {
+ val color = toColor()
+ val red = color.red
+ val green = color.green
+ val blue = color.blue
+ return Color(red, green, blue, opacity)
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 763e4288e..765a075a8 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -22,13 +22,20 @@ object RenderUtils {
val beaconBeam = ResourceLocation("textures/entity/beacon_beam.png")
infix fun Slot.highlight(color: LorenzColor) {
+ highlight(color.toColor())
+ }
+
+ infix fun Slot.highlight(color: Color) {
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
Gui.drawRect(
this.xDisplayPosition,
this.yDisplayPosition,
this.xDisplayPosition + 16,
this.yDisplayPosition + 16,
- color.toColor().rgb
+ color.rgb
)
+ GlStateManager.popMatrix()
}
fun RenderWorldLastEvent.drawColor(location: LorenzVec, color: LorenzColor, beacon: Boolean = false) {