diff options
author | Ronald Inglett <71849533+inglettronald@users.noreply.github.com> | 2023-07-18 06:39:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-18 06:39:39 -0500 |
commit | 8b1b2d19b3af2462ddad000c7d71cd6c702e4560 (patch) | |
tree | 957b67b0d18e8b33bb4c1f6222e5ffb41ccf0e91 /src/main/kotlin/com/dulkirfabric/features | |
parent | d68c8bb34fe41d47777c4771364d2b94b4fdbdf1 (diff) | |
parent | 25fb78ace82779fa6e5b45fc20fa428570c63a59 (diff) | |
download | DulkirMod-Fabric-8b1b2d19b3af2462ddad000c7d71cd6c702e4560.tar.gz DulkirMod-Fabric-8b1b2d19b3af2462ddad000c7d71cd6c702e4560.tar.bz2 DulkirMod-Fabric-8b1b2d19b3af2462ddad000c7d71cd6c702e4560.zip |
Merge pull request #3 from romangraef/dududuudududud
DUDUDUDUDUDUDUDUDUDUDUDUDUDU
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/features/IPhoneAlarm.kt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/features/IPhoneAlarm.kt b/src/main/kotlin/com/dulkirfabric/features/IPhoneAlarm.kt new file mode 100644 index 0000000..4dcdc69 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/IPhoneAlarm.kt @@ -0,0 +1,36 @@ +package com.dulkirfabric.features + +import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.ClientTickEvent +import com.dulkirfabric.util.SoundUtil +import com.dulkirfabric.util.TimeMark +import meteordevelopment.orbit.EventHandler +import net.minecraft.client.sound.SoundInstance +import net.minecraft.util.math.BlockPos +import java.time.Duration + +object IPhoneAlarm { + var lastPosition: BlockPos? = null + var lastMoved = TimeMark.farPast() + val soundInstances = mutableListOf<SoundInstance>() + + @EventHandler + fun onTick(event: ClientTickEvent) { + if (DulkirConfig.configOptions.alarmTimeout <= 0) return + val p = mc.player ?: return + val lastPosition = this.lastPosition + this.lastPosition = p.blockPos + if (lastPosition != this.lastPosition) { + lastMoved = TimeMark.now() + SoundUtil.stop(soundInstances) + soundInstances.clear() + } else { + if (lastMoved.timePassed() > Duration.ofSeconds(DulkirConfig.configOptions.alarmTimeout.toLong())) { + soundInstances.add(SoundUtil.playIPhoneAlarm()) + lastMoved = TimeMark.ago(Duration.ofSeconds(4L)) + } + } + } + +}
\ No newline at end of file |