aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/Ledger.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-02 16:01:38 +0200
committerLinnea Gräf <nea@nea.moe>2024-04-02 16:01:38 +0200
commit3e0198e3a803d2dd46988ba0ac445412c7da8390 (patch)
tree6f08cebe11894769ead7ce7473b27dbdf21523d5 /src/main/kotlin/moe/nea/ledger/Ledger.kt
parent8d26a206297071775e88b99d4b38efcc5577af0a (diff)
downloadLocalTransactionLedger-3e0198e3a803d2dd46988ba0ac445412c7da8390.tar.gz
LocalTransactionLedger-3e0198e3a803d2dd46988ba0ac445412c7da8390.tar.bz2
LocalTransactionLedger-3e0198e3a803d2dd46988ba0ac445412c7da8390.zip
Add bits stuff
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/Ledger.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/Ledger.kt27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/Ledger.kt b/src/main/kotlin/moe/nea/ledger/Ledger.kt
index 0164f3b..1fc7954 100644
--- a/src/main/kotlin/moe/nea/ledger/Ledger.kt
+++ b/src/main/kotlin/moe/nea/ledger/Ledger.kt
@@ -1,11 +1,15 @@
package moe.nea.ledger
+import net.minecraft.client.Minecraft
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.common.MinecraftForge
+import net.minecraftforge.event.entity.EntityJoinWorldEvent
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import org.apache.logging.log4j.LogManager
@Mod(modid = "ledger", useMetadata = true)
@@ -52,9 +56,32 @@ class Ledger {
BazaarDetection(ledger, ids),
BazaarOrderDetection(ledger, ids),
AuctionHouseDetection(ledger, ids),
+ BitsDetection(ledger),
+ BitsShop(ledger),
).forEach(MinecraftForge.EVENT_BUS::register)
}
+ var lastJoin = -1L
+
+ @SubscribeEvent
+ fun worldSwitchEvent(event: EntityJoinWorldEvent) {
+ if (event.entity == Minecraft.getMinecraft().thePlayer) {
+ lastJoin = System.currentTimeMillis()
+ }
+ }
+
+ @SubscribeEvent
+ fun tickEvent(event: ClientTickEvent) {
+ if (event.phase == TickEvent.Phase.END
+ && lastJoin > 0
+ && System.currentTimeMillis() - lastJoin > 10_000
+ && Minecraft.getMinecraft().thePlayer != null
+ ) {
+ lastJoin = -1
+ MinecraftForge.EVENT_BUS.post(LateWorldLoadEvent())
+ }
+ }
+
@SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST)
fun onChat(event: ClientChatReceivedEvent) {
if (event.type != 2.toByte())