diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-23 13:00:01 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-23 13:00:01 +0200 |
commit | 51616771a0ebb98b7b63703562ad334ac418d1a6 (patch) | |
tree | 34bbc0bb1bc55840b482b88aa1b1953275d5354a /src/main/java/at/hannibal2/skyhanni/features | |
parent | 57b351f66232fd7323234ab3e407729667c40143 (diff) | |
download | skyhanni-51616771a0ebb98b7b63703562ad334ac418d1a6.tar.gz skyhanni-51616771a0ebb98b7b63703562ad334ac418d1a6.tar.bz2 skyhanni-51616771a0ebb98b7b63703562ad334ac418d1a6.zip |
added display to show last time a minion was cleared
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt index 7bf198f1a..4e67ebeae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt @@ -1,8 +1,12 @@ package at.hannibal2.skyhanni.features.minion import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex +import at.hannibal2.skyhanni.utils.RenderUtils.drawString import net.minecraft.client.Minecraft import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.world.WorldEvent @@ -14,11 +18,22 @@ import java.awt.Color class MinionHelper { - var lastLocation: LorenzVec? = null + var lastClickedEntity: LorenzVec? = null var lastMinion: LorenzVec? = null var lastMinionOpened = 0L var minionInventoryOpen = false + var lastCoinsRecived = 0L + val minions = mutableMapOf<LorenzVec, Long>() + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + for (minion in SkyHanniMod.feature.hidden.minions) { + val vec = LorenzVec.decodeFromString(minion.key) + minions[vec] = minion.value + } + } + @SubscribeEvent fun onClick(event: InputEvent.MouseInputEvent) { if (!LorenzUtils.inSkyblock) return @@ -31,7 +46,7 @@ class MinionHelper { if (eventButton == 1) { val entity = minecraft.pointedEntity if (entity != null) { - lastLocation = entity.getLorenzVec().add(-0.5, 0.0, -0.5) + lastClickedEntity = entity.getLorenzVec() } } } @@ -49,7 +64,7 @@ class MinionHelper { if (loc != null) { val time = SkyHanniMod.feature.minions.lastOpenedMinionTime * 1_000 if (lastMinionOpened + time > System.currentTimeMillis()) { - event.drawWaypointFilled(loc, color) + event.drawWaypointFilled(loc.add(-0.5, 0.0, -0.5), color, true) } } } @@ -57,9 +72,9 @@ class MinionHelper { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (InventoryUtils.currentlyOpenInventory().contains("Minion")) { - if (lastLocation != null) { - lastMinion = lastLocation - lastLocation = null + if (lastClickedEntity != null) { + lastMinion = lastClickedEntity + lastClickedEntity = null minionInventoryOpen = true lastMinionOpened = 0 } @@ -67,15 +82,52 @@ class MinionHelper { if (minionInventoryOpen) { minionInventoryOpen = false lastMinionOpened = System.currentTimeMillis() + + val duration = System.currentTimeMillis() - lastCoinsRecived + if (duration < 2_000) { + val loc = lastMinion + if (loc != null) { + minions[loc] = System.currentTimeMillis() + SkyHanniMod.feature.hidden.minions[loc.encodeToString()] = System.currentTimeMillis() + } + } } } } @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { - lastLocation = null + lastClickedEntity = null lastMinion = null lastMinionOpened = 0L minionInventoryOpen = false } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyblock) return + + if (event.message.matchRegex("§aYou received §r§6(.*) coins§r§a!")) { + lastCoinsRecived = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun onWorldRender(event: RenderWorldLastEvent) { + if (!LorenzUtils.inSkyblock) return + if (!SkyHanniMod.feature.minions.emptiedTimeDisplay) return + if (LorenzUtils.skyBlockIsland != "Private Island") return + + val playerLocation = LocationUtils.playerLocation() + for (minion in minions) { + val location = minion.key + if (playerLocation.distance(location) < SkyHanniMod.feature.minions.emptiedTimeDistance) { + val duration = System.currentTimeMillis() - minion.value + val format = StringUtils.formatDuration(duration / 1000) + + val text = "§eLast emptied: $format" + event.drawString(location.add(0.0, 2.0, 0.0), text, true) + } + } + } }
\ No newline at end of file |