diff options
author | Brady <thatgravyboat@gmail.com> | 2024-06-08 06:48:29 -0230 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-08 11:18:29 +0200 |
commit | f9cafb766115d5342f7d7e1f8b9e3a56504f0273 (patch) | |
tree | cd325dbd48a4f8cde6f7e3c74e49cf0ebef99cad /src/main/java/at/hannibal2/skyhanni/features/misc | |
parent | f677ce0fa1cab31feccab6eff2e5c35e2524d8a3 (diff) | |
download | skyhanni-f9cafb766115d5342f7d7e1f8b9e3a56504f0273.tar.gz skyhanni-f9cafb766115d5342f7d7e1f8b9e3a56504f0273.tar.bz2 skyhanni-f9cafb766115d5342f7d7e1f8b9e3a56504f0273.zip |
Backend: Packet Events (#2025)
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
3 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt index 2fab8893a..0e891f444 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt @@ -1,9 +1,10 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MobUtils.isDefaultValue @@ -31,8 +32,8 @@ object FixGhostEntities { recentlySpawnedEntities = ArrayDeque() } - @SubscribeEvent - fun onReceiveCurrentShield(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnSkyblock = true) + fun onReceiveCurrentShield(event: PacketReceivedEvent) { if (!isEnabled()) return val packet = event.packet @@ -69,5 +70,5 @@ object FixGhostEntities { } } - fun isEnabled() = LorenzUtils.inSkyBlock && config.fixGhostEntities + fun isEnabled() = config.fixGhostEntities } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 206215760..7f0775889 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -1,15 +1,16 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -28,7 +29,6 @@ import at.hannibal2.skyhanni.utils.TimeUtils.timerColor import at.hannibal2.skyhanni.utils.Timer import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.minutes @@ -220,8 +220,9 @@ object NonGodPotEffectDisplay { } } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + // TODO use TablistFooterUpdateEvent instead + @HandleEvent(onlyOnSkyblock = true, priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { val packet = event.packet if (!checkFooter) return if (packet is S47PacketPlayerListHeaderFooter) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt index 1c37e92ff..0c6521e9c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -1,16 +1,16 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer @@ -79,8 +79,8 @@ object TpsCounter { display = "" } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (!config.tpsDisplay) return hasPacketReceived = true } |