aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
authorBrandon <brandon.wamboldt@gmail.com>2023-09-08 06:35:43 -0300
committerGitHub <noreply@github.com>2023-09-08 11:35:43 +0200
commit62ebd2a830490ab921c94819e1d24ff4494f00ec (patch)
treefef05e8e2bd5d72821690cc95236e169a0e62887 /src/main/java/at/hannibal2/skyhanni/features/misc
parentc0ca23e0027b8a70b3e81b4db176eee02b79b1ca (diff)
downloadskyhanni-62ebd2a830490ab921c94819e1d24ff4494f00ec.tar.gz
skyhanni-62ebd2a830490ab921c94819e1d24ff4494f00ec.tar.bz2
skyhanni-62ebd2a830490ab921c94819e1d24ff4494f00ec.zip
Feature: Outline dropped items (#449)
Add feature to outline dropped items #449
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt
new file mode 100644
index 000000000..4e7afc376
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt
@@ -0,0 +1,68 @@
+package at.hannibal2.skyhanni.features.misc.items
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf
+import net.minecraft.entity.Entity
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.item.EntityItem
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class GlowingDroppedItems {
+
+ private val config get() = SkyHanniMod.feature.misc.glowingDroppedItems
+
+ /**
+ * List of skyblock locations where we might see items in showcases
+ */
+ private val showcaseItemLocations = setOf(
+ "The End",
+ "Jerry's Workshop"
+ )
+
+ @SubscribeEvent
+ fun onRenderEntityOutlines(event: RenderEntityOutlineEvent) {
+ if (isEnabled() && event.type === RenderEntityOutlineEvent.Type.XRAY) {
+ event.queueEntitiesToOutline(getEntityOutlineColor)
+ }
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
+
+ private val getEntityOutlineColor: (entity: Entity) -> Int? = { entity ->
+ if (entity is EntityItem && !shouldHideShowcaseItem(entity)) {
+ val rarity = entity.entityItem.getItemRarityOrNull()
+
+ if (config.highlightFishingBait || entity.entityItem.name?.endsWith(" Bait") != true) {
+ rarity?.color?.toColor()?.rgb
+ } else null
+ } else null
+ }
+
+ private fun isShowcaseArea() =
+ showcaseItemLocations.contains(LorenzUtils.skyBlockArea) ||
+ LorenzUtils.skyBlockIsland.equalsOneOf(
+ IslandType.HUB,
+ IslandType.PRIVATE_ISLAND,
+ IslandType.PRIVATE_ISLAND_GUEST
+ )
+
+ private fun shouldHideShowcaseItem(entity: EntityItem): Boolean {
+ if (!isShowcaseArea() || config.highlightShowcase) return false
+
+ for (entityArmorStand in entity.worldObj.getEntitiesWithinAABB(
+ EntityArmorStand::class.java,
+ entity.entityBoundingBox
+ )) {
+ if (entityArmorStand.isInvisible) {
+ return true
+ }
+ }
+
+ return false
+ }
+} \ No newline at end of file