aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-21 23:51:37 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-21 23:51:37 +0200
commitad5e66f4b03ae80cd4f4cf6268495e6b4db901de (patch)
tree5faca09b5f11dc17309aef3ada27a6194e8ace4e /src/main/java/at/hannibal2
parent9dcb17f1d853796620817e036c53a67ae4635125 (diff)
downloadskyhanni-ad5e66f4b03ae80cd4f4cf6268495e6b4db901de.tar.gz
skyhanni-ad5e66f4b03ae80cd4f4cf6268495e6b4db901de.tar.bz2
skyhanni-ad5e66f4b03ae80cd4f4cf6268495e6b4db901de.zip
added useful stuff
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemBlink.kt31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt6
5 files changed, 63 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index 6a9bc3d2b..580954dc2 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -29,6 +29,7 @@ class HypixelData {
var bingo = false
var profileName = ""
+ var joinedWorld = 0L
fun readSkyBlockArea(): String {
return ScoreboardData.sidebarLinesFormatted
@@ -43,6 +44,7 @@ class HypixelData {
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Load) {
skyBlock = false
+ joinedWorld = System.currentTimeMillis()
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 6fb6887c3..5aa1a4128 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -21,7 +21,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
-import io.github.moulberry.notenoughupdates.util.SBInfo
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraft.entity.Entity
@@ -399,7 +398,7 @@ class GardenVisitorFeatures {
}
}
if (visitors.keys.removeIf {
- val time = System.currentTimeMillis() - SBInfo.getInstance().joinedWorld
+ val time = System.currentTimeMillis() - LorenzUtils.lastWorldSwitch
val removed = it !in visitorsInTab && time > 2_000
if (removed) {
logger.log("Removed old visitor: '$it'")
@@ -410,16 +409,28 @@ class GardenVisitorFeatures {
}
for (name in visitorsInTab) {
if (!visitors.containsKey(name)) {
- visitors[name] = Visitor(name, status = VisitorStatus.NEW)
- logger.log("New visitor detected: '$name'")
- if (config.visitorNotificationTitle) {
- TitleUtils.sendTitle("§eNew Visitor", 5_000)
- }
- if (config.visitorNotificationChat) {
- val displayName = GardenVisitorColorNames.getColoredName(name)
- LorenzUtils.chat("§e[SkyHanni] $displayName §eis visiting your garden!")
- }
- updateDisplay()
+ addVisitor(name)
+ }
+ }
+ }
+
+ private fun addVisitor(name: String) {
+ visitors[name] = Visitor(name, status = VisitorStatus.NEW)
+ logger.log("New visitor detected: '$name'")
+
+ if (config.visitorNotificationTitle) {
+ TitleUtils.sendTitle("§eNew Visitor", 5_000)
+ }
+ if (config.visitorNotificationChat) {
+ val displayName = GardenVisitorColorNames.getColoredName(name)
+ LorenzUtils.chat("§e[SkyHanni] $displayName §eis visiting your garden!")
+ }
+ updateDisplay()
+
+ if (System.currentTimeMillis() > LorenzUtils.lastWorldSwitch + 2_000) {
+ if (name.removeColor().contains("Jerry")) {
+ logger.log("Jerry!")
+ ItemBlink.setBlink(NEUItems.getItemStackOrNull("JERRY;4"), 5_000)
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemBlink.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemBlink.kt
new file mode 100644
index 000000000..8afc2a2b7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemBlink.kt
@@ -0,0 +1,31 @@
+package at.hannibal2.skyhanni.utils
+
+import net.minecraft.item.Item
+import net.minecraft.item.ItemStack
+
+object ItemBlink {
+ private val offsets = mutableMapOf<Item, Long>()
+ private var lastOffset = 0L
+ private var endOfBlink = 0L
+ private var blinkItem: ItemStack? = null
+
+ fun setBlink(item: ItemStack?, durationMillis: Long) {
+ endOfBlink = System.currentTimeMillis() + durationMillis
+ blinkItem = item
+ }
+
+ fun ItemStack.checkBlinkItem(): ItemStack {
+ val stack = blinkItem ?: return this
+ if (System.currentTimeMillis() > endOfBlink) return this
+
+ val offset: Long = if (!offsets.containsKey(item)) {
+ lastOffset += 200
+ val number = lastOffset % 1000
+ offsets[item] = number
+ number
+ } else {
+ offsets[item]!!
+ }
+ return if ((offset + System.currentTimeMillis()) % 1000 > 500) stack else this
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 526d2a3c7..8047cc61a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -51,6 +51,9 @@ object LorenzUtils {
val isBingoProfile: Boolean
get() = inSkyBlock && HypixelData.bingo
+ val lastWorldSwitch: Long
+ get() = HypixelData.joinedWorld
+
const val DEBUG_PREFIX = "[SkyHanni Debug] §7"
private val log = LorenzLogger("chat/mod_sent")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 71bcc2f09..b34462e3e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.utils.ItemBlink.checkBlinkItem
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import io.github.moulberry.notenoughupdates.NEUManager
@@ -122,7 +123,8 @@ object NEUItems {
fun isVanillaItem(item: ItemStack) = manager.auctionManager.isVanillaItem(item.getInternalName())
fun ItemStack.renderOnScreen(x: Float, y: Float, scaleMultiplier: Double = 1.0) {
- val isSkull = item === Items.skull
+ val item = checkBlinkItem()
+ val isSkull = item.item === Items.skull
val baseScale = (if (isSkull) 0.8f else 0.6f)
val finalScale = baseScale * scaleMultiplier
@@ -144,7 +146,7 @@ object NEUItems {
GlStateManager.scale(finalScale, finalScale, 1.0)
RenderHelper.enableGUIStandardItemLighting()
- Minecraft.getMinecraft().renderItem.renderItemIntoGUI(this, 0, 0)
+ Minecraft.getMinecraft().renderItem.renderItemIntoGUI(item, 0, 0)
RenderHelper.disableStandardItemLighting()
GlStateManager.popMatrix()