summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-06 21:49:08 +0100
committerGitHub <noreply@github.com>2024-03-06 21:49:08 +0100
commitde0f0e888a4c0767c8e8ca911113482a3b1f9d5c (patch)
treeaa390c371a4643ac966f7bd95decb80fe1c08e45 /src/main/java
parentfb61f5717ee24829781a3fbe2152a647ef7137ed (diff)
downloadskyhanni-de0f0e888a4c0767c8e8ca911113482a3b1f9d5c.tar.gz
skyhanni-de0f0e888a4c0767c8e8ca911113482a3b1f9d5c.tar.bz2
skyhanni-de0f0e888a4c0767c8e8ca911113482a3b1f9d5c.zip
Renormalize line endings to be \n (#1112)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt236
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt220
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt372
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt78
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt196
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt64
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt170
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderGlobalHook.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RendererLivingEntityHook.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/CustomRenderGlobal.java32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderGlobal.java80
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRendererLivingEntity.java42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt110
13 files changed, 842 insertions, 842 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt
index d061becf9..85c3211fd 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt
@@ -1,118 +1,118 @@
-package at.hannibal2.skyhanni.events
-
-import net.minecraft.client.Minecraft
-import net.minecraft.entity.Entity
-import net.minecraft.entity.item.EntityArmorStand
-import net.minecraft.entity.item.EntityItemFrame
-import java.util.function.Consumer
-
-class RenderEntityOutlineEvent(theType: Type?, potentialEntities: HashSet<Entity>?) :
- LorenzEvent() {
-
- /**
- * The phase of the event (see [Type]
- */
- var type: Type? = null
-
- /**
- * The entities to outline. This is progressively cumulated from [.entitiesToChooseFrom]
- */
- var entitiesToOutline: HashMap<Entity, Int>? = null
-
- /**
- * The entities we can outline. Note that this set and [.entitiesToOutline] are disjoint at all times.
- */
- var entitiesToChooseFrom: HashSet<Entity>? = null
-
- /**
- * Constructs the event, given the type and optional entities to outline.
- *
- *
- * This will modify {@param potentialEntities} internally, so make a copy before passing it if necessary.
- *
- * @param theType of the event (see [Type]
- */
- init {
- type = theType
- entitiesToChooseFrom = potentialEntities
- if (potentialEntities != null) {
- entitiesToOutline = HashMap(potentialEntities.size)
- }
- }
-
- /**
- * Conditionally queue entities around which to render entities
- * Selects from the pool of [.entitiesToChooseFrom] to speed up the predicate testing on subsequent calls.
- * Is more efficient (theoretically) than calling [.queueEntityToOutline] for each entity because lists are handled internally.
- *
- *
- * This function loops through all entities and so is not very efficient.
- * It's advisable to encapsulate calls to this function with global checks (those not dependent on an individual entity) for efficiency purposes.
- *
- * @param outlineColor a function to test
- */
- fun queueEntitiesToOutline(outlineColor: ((entity: Entity) -> Int?)? = null) {
- if (outlineColor == null) {
- return
- }
- if (entitiesToChooseFrom == null) {
- computeAndCacheEntitiesToChooseFrom()
- }
- val itr: MutableIterator<Entity> = entitiesToChooseFrom!!.iterator()
- while (itr.hasNext()) {
- val e: Entity = itr.next()
- val i: Int? = outlineColor(e)
- if (i != null) {
- entitiesToOutline!![e] = i
- itr.remove()
- }
- }
- }
-
- /**
- * Adds a single entity to the list of the entities to outline
- *
- * @param entity the entity to add
- * @param outlineColor the color with which to outline
- */
- fun queueEntityToOutline(entity: Entity?, outlineColor: Int) {
- if (entity == null) {
- return
- }
- if (entitiesToChooseFrom == null) {
- computeAndCacheEntitiesToChooseFrom()
- }
- if (!entitiesToChooseFrom!!.contains(entity)) {
- return
- }
- entitiesToOutline!![entity] = outlineColor
- entitiesToChooseFrom!!.remove(entity)
- }
-
- /**
- * Used for on-the-fly generation of entities. Driven by event handlers in a decentralized fashion
- */
- private fun computeAndCacheEntitiesToChooseFrom() {
- val entities: List<Entity> = Minecraft.getMinecraft().theWorld.getLoadedEntityList()
- // Only render outlines around non-null entities within the camera frustum
- entitiesToChooseFrom = HashSet(entities.size)
- // Only consider entities that aren't invisible armorstands to increase FPS significantly
- entities.forEach(Consumer<Entity> { e: Entity? ->
- if (e != null && !(e is EntityArmorStand && e.isInvisible()) && e !is EntityItemFrame) {
- entitiesToChooseFrom!!.add(e)
- }
- })
- entitiesToOutline = HashMap(entitiesToChooseFrom!!.size)
- }
-
- /**
- * The phase of the event.
- * [.XRAY] means that this directly precedes entities whose outlines are rendered through walls (Vanilla 1.9+)
- * [.NO_XRAY] means that this directly precedes entities whose outlines are rendered only when visible to the client
- */
- enum class Type {
-
- XRAY,
- NO_XRAY
- }
-}
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.Entity
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.item.EntityItemFrame
+import java.util.function.Consumer
+
+class RenderEntityOutlineEvent(theType: Type?, potentialEntities: HashSet<Entity>?) :
+ LorenzEvent() {
+
+ /**
+ * The phase of the event (see [Type]
+ */
+ var type: Type? = null
+
+ /**
+ * The entities to outline. This is progressively cumulated from [.entitiesToChooseFrom]
+ */
+ var entitiesToOutline: HashMap<Entity, Int>? = null
+
+ /**
+ * The entities we can outline. Note that this set and [.entitiesToOutline] are disjoint at all times.
+ */
+ var entitiesToChooseFrom: HashSet<Entity>? = null
+
+ /**
+ * Constructs the event, given the type and optional entities to outline.
+ *
+ *
+ * This will modify {@param potentialEntities} internally, so make a copy before passing it if necessary.
+ *
+ * @param theType of the event (see [Type]
+ */
+ init {
+ type = theType
+ entitiesToChooseFrom = potentialEntities
+ if (potentialEntities != null) {
+ entitiesToOutline = HashMap(potentialEntities.size)
+ }
+ }
+
+ /**
+ * Conditionally queue entities around which to render entities
+ * Selects from the pool of [.entitiesToChooseFrom] to speed up the predicate testing on subsequent calls.
+ * Is more efficient (theoretically) than calling [.queueEntityToOutline] for each entity because lists are handled internally.
+ *
+ *
+ * This function loops through all entities and so is not very efficient.
+ * It's advisable to encapsulate calls to this function with global checks (those not dependent on an individual entity) for efficiency purposes.
+ *
+ * @param outlineColor a function to test
+ */
+ fun queueEntitiesToOutline(outlineColor: ((entity: Entity) -> Int?)? = null) {
+ if (outlineColor == null) {
+ return
+ }
+ if (entitiesToChooseFrom == null) {
+ computeAndCacheEntitiesToChooseFrom()
+ }
+ val itr: MutableIterator<Entity> = entitiesToChooseFrom!!.iterator()
+ while (itr.hasNext()) {
+ val e: Entity = itr.next()
+ val i: Int? = outlineColor(e)
+ if (i != null) {
+ entitiesToOutline!![e] = i
+ itr.remove()
+ }
+ }
+ }
+
+ /**
+ * Adds a single entity to the list of the entities to outline
+ *
+ * @param entity the entity to add
+ * @param outlineColor the color with which to outline
+ */
+ fun queueEntityToOutline(entity: Entity?, outlineColor: Int) {
+ if (entity == null) {
+ return
+ }
+ if (entitiesToChooseFrom == null) {
+ computeAndCacheEntitiesToChooseFrom()
+ }
+ if (!entitiesToChooseFrom!!.contains(entity)) {
+ return
+ }
+ entitiesToOutline!![entity] = outlineColor
+ entitiesToChooseFrom!!.remove(entity)
+ }
+
+ /**
+ * Used for on-the-fly generation of entities. Driven by event handlers in a decentralized fashion
+ */
+ private fun computeAndCacheEntitiesToChooseFrom() {
+ val entities: List<Entity> = Minecraft.getMinecraft().theWorld.getLoadedEntityList()
+ // Only render outlines around non-null entities within the camera frustum
+ entitiesToChooseFrom = HashSet(entities.size)
+ // Only consider entities that aren't invisible armorstands to increase FPS significantly
+ entities.forEach(Consumer<Entity> { e: Entity? ->
+ if (e != null && !(e is EntityArmorStand && e.isInvisible()) && e !is EntityItemFrame) {
+ entitiesToChooseFrom!!.add(e)
+ }
+ })
+ entitiesToOutline = HashMap(entitiesToChooseFrom!!.size)
+ }
+
+ /**
+ * The phase of the event.
+ * [.XRAY] means that this directly precedes entities whose outlines are rendered through walls (Vanilla 1.9+)
+ * [.NO_XRAY] means that this directly precedes entities whose outlines are rendered only when visible to the client
+ */
+ enum class Type {
+
+ XRAY,
+ NO_XRAY
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt
index f92e8dccd..ee8f2b8f0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt
@@ -1,110 +1,110 @@
-package at.hannibal2.skyhanni.features.combat.mobs
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
-import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
-import at.hannibal2.skyhanni.events.PacketEvent
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
-import at.hannibal2.skyhanni.utils.LorenzVec
-import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
-import at.hannibal2.skyhanni.utils.SimpleTimeMark
-import at.hannibal2.skyhanni.utils.StringUtils.matches
-import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import at.hannibal2.skyhanni.utils.TimeUtils.format
-import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import at.hannibal2.skyhanni.utils.toLorenzVec
-import net.minecraft.network.play.server.S2APacketParticles
-import net.minecraft.util.EnumParticleTypes
-import net.minecraftforge.fml.common.eventhandler.EventPriority
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import kotlin.time.Duration.Companion.seconds
-
-class SpawnTimers {
-
- private val config get() = SkyHanniMod.feature.combat.mobs
-
- private val patternGroup = RepoPattern.group("combat.mobs.spawntime.arachne")
- private val arachneFragmentPattern by patternGroup.pattern(
- "fragment",
- "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$"
- )
- private val arachneCrystalPattern by patternGroup.pattern(
- "crystal",
- "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$"
- )
-
- private val arachneAltarLocation = LorenzVec(-283f, 51f, -179f)
- private var arachneSpawnTime = SimpleTimeMark.farPast()
- private var saveNextTickParticles = false
- private var particleCounter = 0
- private var tickTime: Long = 0
- private var searchTime: Long = 0
-
- @SubscribeEvent
- fun onWorldChange(event: LorenzWorldChangeEvent) {
- searchTime = 0
- tickTime = 0
- particleCounter = 0
- saveNextTickParticles = false
- arachneSpawnTime = SimpleTimeMark.farPast()
- }
-
- @SubscribeEvent
- fun onRenderWorld(event: LorenzRenderWorldEvent) {
- if (!isEnabled()) return
- if (arachneSpawnTime.isInPast()) return
- val countDown = arachneSpawnTime.timeUntil()
-
- val format = countDown.format(showMilliSeconds = true)
- event.drawDynamicText(arachneAltarLocation, "§b$format", 1.5)
- }
-
- @SubscribeEvent
- fun onChatReceived(event: LorenzChatEvent) {
- if (!isEnabled()) return
- val message = event.message.removeColor().lowercase()
-
- if (arachneFragmentPattern.matches(message) || arachneCrystalPattern.matches(message)) {
- if (arachneCrystalPattern.matches(message)) {
- saveNextTickParticles = true
- searchTime = System.currentTimeMillis()
- particleCounter = 0
- tickTime = 0L
- } else arachneSpawnTime = SimpleTimeMark.now() + 19.seconds
- }
- }
-
- // All this to detect "quickspawn" vs regular arachne spawn
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onChatPacket(event: PacketEvent.ReceiveEvent) {
- if (!saveNextTickParticles) return
- if (System.currentTimeMillis() <= searchTime + 3000) return
-
- if (particleCounter == 0 && tickTime == 0L) tickTime = System.currentTimeMillis()
-
- if (System.currentTimeMillis() > tickTime + 60) {
- arachneSpawnTime = if (particleCounter <= 20) {
- SimpleTimeMark.now() + 21.seconds
- } else {
- SimpleTimeMark.now() + 37.seconds
- }
- saveNextTickParticles = false
- return
- }
-
- val packet = event.packet
- if (packet is S2APacketParticles) {
- val location = packet.toLorenzVec().round(2)
- if (arachneAltarLocation.distance(location) > 30) return
- if (packet.particleType == EnumParticleTypes.REDSTONE && packet.particleSpeed == 1.0f) {
- particleCounter += 1
- }
- }
- }
-
- fun isEnabled() =
- IslandType.SPIDER_DEN.isInIsland() && LorenzUtils.skyBlockArea == "Arachne's Sanctuary" && config.showArachneSpawnTimer
-}
+package at.hannibal2.skyhanni.features.combat.mobs
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.TimeUtils.format
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import at.hannibal2.skyhanni.utils.toLorenzVec
+import net.minecraft.network.play.server.S2APacketParticles
+import net.minecraft.util.EnumParticleTypes
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
+
+class SpawnTimers {
+
+ private val config get() = SkyHanniMod.feature.combat.mobs
+
+ private val patternGroup = RepoPattern.group("combat.mobs.spawntime.arachne")
+ private val arachneFragmentPattern by patternGroup.pattern(
+ "fragment",
+ "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$"
+ )
+ private val arachneCrystalPattern by patternGroup.pattern(
+ "crystal",
+ "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$"
+ )
+
+ private val arachneAltarLocation = LorenzVec(-283f, 51f, -179f)
+ private var arachneSpawnTime = SimpleTimeMark.farPast()
+ private var saveNextTickParticles = false
+ private var particleCounter = 0
+ private var tickTime: Long = 0
+ private var searchTime: Long = 0
+
+ @SubscribeEvent
+ fun onWorldChange(event: LorenzWorldChangeEvent) {
+ searchTime = 0
+ tickTime = 0
+ particleCounter = 0
+ saveNextTickParticles = false
+ arachneSpawnTime = SimpleTimeMark.farPast()
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!isEnabled()) return
+ if (arachneSpawnTime.isInPast()) return
+ val countDown = arachneSpawnTime.timeUntil()
+
+ val format = countDown.format(showMilliSeconds = true)
+ event.drawDynamicText(arachneAltarLocation, "§b$format", 1.5)
+ }
+
+ @SubscribeEvent
+ fun onChatReceived(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ val message = event.message.removeColor().lowercase()
+
+ if (arachneFragmentPattern.matches(message) || arachneCrystalPattern.matches(message)) {
+ if (arachneCrystalPattern.matches(message)) {
+ saveNextTickParticles = true
+ searchTime = System.currentTimeMillis()
+ particleCounter = 0
+ tickTime = 0L
+ } else arachneSpawnTime = SimpleTimeMark.now() + 19.seconds
+ }
+ }
+
+ // All this to detect "quickspawn" vs regular arachne spawn
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ if (!saveNextTickParticles) return
+ if (System.currentTimeMillis() <= searchTime + 3000) return
+
+ if (particleCounter == 0 && tickTime == 0L) tickTime = System.currentTimeMillis()
+
+ if (System.currentTimeMillis() > tickTime + 60) {
+ arachneSpawnTime = if (particleCounter <= 20) {
+ SimpleTimeMark.now() + 21.seconds
+ } else {
+ SimpleTimeMark.now() + 37.seconds
+ }
+ saveNextTickParticles = false
+ return
+ }
+
+ val packet = event.packet
+ if (packet is S2APacketParticles) {
+ val location = packet.toLorenzVec().round(2)
+ if (arachneAltarLocation.distance(location) > 30) return
+ if (packet.particleType == EnumParticleTypes.REDSTONE && packet.particleSpeed == 1.0f) {
+ particleCounter += 1
+ }
+ }
+ }
+
+ fun isEnabled() =
+ IslandType.SPIDER_DEN.isInIsland() && LorenzUtils.skyBlockArea == "Arachne's Sanctuary" && config.showArachneSpawnTimer
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt
index 4521aa2b9..d636f24e3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt
@@ -1,186 +1,186 @@
-package at.hannibal2.skyhanni.features.dungeon
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
-import at.hannibal2.skyhanni.events.LorenzToolTipEvent
-import at.hannibal2.skyhanni.events.RenderItemTipEvent
-import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
-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.NumberUtil.romanToDecimalIfNecessary
-import at.hannibal2.skyhanni.utils.RenderUtils.highlight
-import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
-import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.inventory.ContainerChest
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-class DungeonFinderFeatures {
-
- private val config get() = SkyHanniMod.feature.dungeon.partyFinder
-
- private val pricePattern = "([0-9]{2,3}K|[0-9]{1,3}M|[0-9]+\\.[0-9]M|[0-9] ?mil)".toRegex(RegexOption.IGNORE_CASE)
- private val carryPattern = "(carry|cary|carries|caries|comp|to cata [0-9]{2})".toRegex(RegexOption.IGNORE_CASE)
- private val nonPugPattern = "(perm|vc|discord)".toRegex(RegexOption.IGNORE_CASE)
- private val memberPattern = "^ §.*?§.: §.([A-Z]+)§. \\(§.([0-9]+)§.\\)".toRegex(RegexOption.IGNORE_CASE)
- private val ineligiblePattern =
- "^§c(Requires .*$|You don't meet the requirement!|Complete previous floor first!$)".toRegex()
- private val classLevelPattern = " §.(?<playerName>.*)§f: §e(?<className>.*)§b \\(§e(?<level>.*)§b\\)".toPattern()
- private val notePattern = "^(§7§7Note: |§f[^§])".toRegex()
-
- private var selectedClass = ""
-
- @SubscribeEvent
- fun onRenderItemTip(event: RenderItemTipEvent) {
- if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return
- if (!config.floorAsStackSize) return
-
- val itemName = event.stack.name?.removeColor() ?: ""
- val invName = InventoryUtils.openInventoryName()
-
- if (invName == "Select Floor") {
- if (itemName == "Any") {
- event.stackTip = "A"
- } else if (itemName == "Entrance") {
- event.stackTip = "E"
- } else if (itemName.startsWith("Floor ")) {
- event.stackTip = itemName.split(' ').last().romanToDecimalIfNecessary().toString()
- }
- } else if (itemName.startsWith("The Catacombs - ") || itemName.startsWith("MM Catacombs -")) {
- val floor = itemName.split(" - ").last().removeColor()
- val floorNum = floor.split(' ').last().romanToDecimalIfNecessary().toString()
- val isMasterMode = itemName.contains("MM ")
-
- event.stackTip = if (floor.contains("Entrance")) {
- "E"
- } else if (isMasterMode) {
- "M${floorNum}"
- } else {
- "F${floorNum}"
- }
- } else if (itemName.endsWith("'s Party")) {
- val floor = event.stack.getLore().find { it.startsWith("§7Floor: ") } ?: return
- val dungeon = event.stack.getLore().find { it.startsWith("§7Dungeon: ") } ?: return
- val floorNum = floor.split(' ').last().romanToDecimalIfNecessary().toString()
- val isMasterMode = dungeon.contains("Master Mode")
-
- event.stackTip = if (floor.contains("Entrance")) {
- "E"
- } else if (isMasterMode) {
- "M${floorNum}"
- } else {
- "F${floorNum}"
- }
- }
- }
-
- @SubscribeEvent
- fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
- if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return
- if (event.inventoryName != "Catacombs Gate") return
-
- val lore = event.inventoryItems[45]?.getLore() ?: return
-
- if (lore[0] == "§7View and select a dungeon class.") {
- selectedClass = lore[2].split(" ").last().removeColor()
- }
- }
-
- @SubscribeEvent
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (event.gui !is GuiChest) return
-
- val chest = event.gui.inventorySlots as ContainerChest
- val inventoryName = chest.getInventoryName()
- if (inventoryName != "Party Finder") return
-
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- if (slot.stack == null) continue
-
- val itemName = slot.stack.name ?: continue
- if (!itemName.endsWith(" Party")) continue
-
- if (config.markIneligibleGroups && slot.stack.getLore().any { ineligiblePattern.matches(it) }) {
- slot highlight LorenzColor.DARK_RED
- continue
- }
-
- if (config.markPaidCarries) {
- val note = slot.stack.getLore().filter { notePattern.containsMatchIn(it) }.joinToString(" ")
-
- if (pricePattern.containsMatchIn(note) && carryPattern.containsMatchIn(note)) {
- slot highlight LorenzColor.RED
- continue
- }
- }
-
- if (config.markNonPugs) {
- val note = slot.stack.getLore().filter { notePattern.containsMatchIn(it) }.joinToString(" ")
-
- if (nonPugPattern.containsMatchIn(note)) {
- slot highlight LorenzColor.LIGHT_PURPLE
- continue
- }
- }
-
- val members = slot.stack.getLore().filter { memberPattern.matches(it) }
- val memberLevels = members.map { memberPattern.matchEntire(it)?.groupValues?.get(2)?.toInt() ?: 0 }
- val memberClasses = members.map { memberPattern.matchEntire(it)?.groupValues?.get(1) ?: "" }
-
- if (memberLevels.any { it <= config.markBelowClassLevel }) {
- slot highlight LorenzColor.YELLOW
- continue
- }
-
- if (config.markMissingClass && memberClasses.none { it == selectedClass }) {
- slot highlight LorenzColor.GREEN
- }
- }
- }
-
- @SubscribeEvent
- fun onItemTooltip(event: LorenzToolTipEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (!config.coloredClassLevel) return
-
- val chestName = InventoryUtils.openInventoryName()
- if (chestName != "Party Finder") return
-
- val stack = event.itemStack
-
- for ((index, line) in stack.getLore().withIndex()) {
- classLevelPattern.matchMatcher(line) {
- val playerName = group("playerName")
- val className = group("className")
- val level = group("level").toInt()
- val color = getColor(level)
- event.toolTip[index + 1] = " §b$playerName§f: §e$className $color$level"
- }
- }
- }
-
- @SubscribeEvent
- fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
- event.move(2, "dungeon.partyFinderColoredClassLevel", "dungeon.partyFinder.coloredClassLevel")
- }
-}
-
-fun getColor(level: Int): String {
- if (level >= 50) return "§c§l"
- if (level >= 45) return "§c"
- if (level >= 40) return "§d"
- if (level >= 35) return "§6"
- if (level >= 30) return "§5"
- if (level >= 25) return "§9"
- if (level >= 20) return "§a"
- if (level >= 10) return "§f"
- return "§7"
-}
+package at.hannibal2.skyhanni.features.dungeon
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+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.NumberUtil.romanToDecimalIfNecessary
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.inventory.ContainerChest
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DungeonFinderFeatures {
+
+ private val config get() = SkyHanniMod.feature.dungeon.partyFinder
+
+ private val pricePattern = "([0-9]{2,3}K|[0-9]{1,3}M|[0-9]+\\.[0-9]M|[0-9] ?mil)".toRegex(RegexOption.IGNORE_CASE)
+ private val carryPattern = "(carry|cary|carries|caries|comp|to cata [0-9]{2})".toRegex(RegexOption.IGNORE_CASE)
+ private val nonPugPattern = "(perm|vc|discord)".toRegex(RegexOption.IGNORE_CASE)
+ private val memberPattern = "^ §.*?§.: §.([A-Z]+)§. \\(§.([0-9]+)§.\\)".toRegex(RegexOption.IGNORE_CASE)
+ private val ineligiblePattern =
+ "^§c(Requires .*$|You don't meet the requirement!|Complete previous floor first!$)".toRegex()
+ private val classLevelPattern = " §.(?<playerName>.*)§f: §e(?<className>.*)§b \\(§e(?<level>.*)§b\\)".toPattern()
+ private val notePattern = "^(§7§7Note: |§f[^§])".toRegex()
+
+ private var selectedClass = ""
+
+ @SubscribeEvent
+ fun onRenderItemTip(event: RenderItemTipEvent) {
+ if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return
+ if (!config.floorAsStackSize) return
+
+ val itemName = event.stack.name?.removeColor() ?: ""
+ val invName = InventoryUtils.openInventoryName()
+
+ if (invName == "Select Floor") {
+ if (itemName == "Any") {
+ event.stackTip = "A"
+ } else if (itemName == "Entrance") {
+ event.stackTip = "E"
+ } else if (itemName.startsWith("Floor ")) {
+ event.stackTip = itemName.split(' ').last().romanToDecimalIfNecessary().toString()
+ }
+ } else if (itemName.startsWith("The Catacombs - ") || itemName.startsWith("MM Catacombs -")) {
+ val floor = itemName.split(" - ").last().removeColor()
+ val floorNum = floor.split(' ').last().romanToDecimalIfNecessary().toString()
+ val isMasterMode = itemName.contains("MM ")
+
+ event.stackTip = if (floor.contains("Entrance")) {
+ "E"
+ } else if (isMasterMode) {
+ "M${floorNum}"
+ } else {
+ "F${floorNum}"
+ }
+ } else if (itemName.endsWith("'s Party")) {
+ val floor = event.stack.getLore().find { it.startsWith("§7Floor: ") } ?: return
+ val dungeon = event.stack.getLore().find { it.startsWith("§7Dungeon: ") } ?: return
+ val floorNum = floor.split(' ').last().romanToDecimalIfNecessary().toString()
+ val isMasterMode = dungeon.contains("Master Mode")
+
+ event.stackTip = if (floor.contains("Entrance")) {
+ "E"
+ } else if (isMasterMode) {
+ "M${floorNum}"
+ } else {
+ "F${floorNum}"
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return
+ if (event.inventoryName != "Catacombs Gate") return
+
+ val lore = event.inventoryItems[45]?.getLore() ?: return
+
+ if (lore[0] == "§7View and select a dungeon class.") {
+ selectedClass = lore[2].split(" ").last().removeColor()
+ }
+ }
+
+ @SubscribeEvent
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (event.gui !is GuiChest) return
+
+ val chest = event.gui.inventorySlots as ContainerChest
+ val inventoryName = chest.getInventoryName()
+ if (inventoryName != "Party Finder") return
+
+ for (slot in chest.inventorySlots) {
+ if (slot == null) continue
+ if (slot.slotNumber != slot.slotIndex) continue
+ if (slot.stack == null) continue
+
+ val itemName = slot.stack.name ?: continue
+ if (!itemName.endsWith(" Party")) continue
+
+ if (config.markIneligibleGroups && slot.stack.getLore().any { ineligiblePattern.matches(it) }) {
+ slot highlight LorenzColor.DARK_RED
+ continue
+ }
+
+ if (config.markPaidCarries) {
+ val note = slot.stack.getLore().filter { notePattern.containsMatchIn(it) }.joinToString(" ")
+
+ if (pricePattern.containsMatchIn(note) && carryPattern.containsMatchIn(note)) {
+ slot highlight LorenzColor.RED
+ continue