From f9cafb766115d5342f7d7e1f8b9e3a56504f0273 Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 8 Jun 2024 06:48:29 -0230 Subject: Backend: Packet Events (#2025) Co-authored-by: Cal --- .../features/combat/mobs/ArachneSpawnTimer.kt | 112 ++++++++++++++++++++ .../skyhanni/features/combat/mobs/SpawnTimers.kt | 113 --------------------- .../dungeon/DungeonShadowAssassinNotification.kt | 11 +- .../event/diana/GriffinBurrowParticleFinder.kt | 9 +- .../event/diana/InquisitorWaypointShare.kt | 8 +- .../skyhanni/features/garden/GardenAPI.kt | 8 +- .../features/garden/pests/PestParticleWaypoint.kt | 9 +- .../visitor/HighlightVisitorsOutsideOfGarden.kt | 7 +- .../features/garden/visitor/VisitorListener.kt | 6 +- .../skyhanni/features/misc/FixGhostEntities.kt | 9 +- .../features/misc/NonGodPotEffectDisplay.kt | 9 +- .../hannibal2/skyhanni/features/misc/TpsCounter.kt | 8 +- 12 files changed, 157 insertions(+), 152 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt new file mode 100644 index 000000000..2fee0577e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt @@ -0,0 +1,112 @@ +package at.hannibal2.skyhanni.features.combat.mobs + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +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.isInIsland +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import at.hannibal2.skyhanni.utils.toLorenzVec +import net.minecraft.network.play.server.S2APacketParticles +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds + +@SkyHanniModule +object ArachneSpawnTimer { + + private val config get() = SkyHanniMod.feature.combat.mobs + + private val patternGroup = RepoPattern.group("combat.mobs.spawntime.arachne") + private val arachneFragmentPattern by patternGroup.pattern( + "fragment", + "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$" + ) + private val arachneCrystalPattern by patternGroup.pattern( + "crystal", + "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$" + ) + + private val arachneAltarLocation = LorenzVec(-283f, 51f, -179f) + private var arachneSpawnTime = SimpleTimeMark.farPast() + private var saveNextTickParticles = false + private var particleCounter = 0 + private var lastTickTime = SimpleTimeMark.farPast() + private var searchTime = SimpleTimeMark.farPast() + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + searchTime = SimpleTimeMark.farPast() + lastTickTime = SimpleTimeMark.farPast() + particleCounter = 0 + saveNextTickParticles = false + arachneSpawnTime = SimpleTimeMark.farPast() + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEnabled()) return + if (arachneSpawnTime.isInPast()) return + val countDown = arachneSpawnTime.timeUntil() + + val format = countDown.format(showMilliSeconds = true) + event.drawDynamicText(arachneAltarLocation, "§b$format", 1.5) + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + val message = event.message.removeColor().lowercase() + + if (arachneFragmentPattern.matches(message) || arachneCrystalPattern.matches(message)) { + if (arachneCrystalPattern.matches(message)) { + saveNextTickParticles = true + searchTime = SimpleTimeMark.now() + particleCounter = 0 + lastTickTime = SimpleTimeMark.farPast() + } else arachneSpawnTime = SimpleTimeMark.now() + 19.seconds + } + } + + @HandleEvent(onlyOnIsland = IslandType.SPIDER_DEN, priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { + if (!saveNextTickParticles) return + if (searchTime.passedSince() < 3.seconds) return + + if (particleCounter == 0 && lastTickTime.isFarPast()) lastTickTime = SimpleTimeMark.now() + + if (lastTickTime.passedSince() > 60.milliseconds) { + arachneSpawnTime = if (particleCounter <= 20) { + SimpleTimeMark.now() + 21.seconds + } else { + SimpleTimeMark.now() + 37.seconds + } + saveNextTickParticles = false + return + } + + val packet = event.packet + if (packet is S2APacketParticles) { + val location = packet.toLorenzVec().round(2) + if (arachneAltarLocation.distance(location) > 30) return + if (packet.particleType == EnumParticleTypes.REDSTONE && packet.particleSpeed == 1.0f) { + particleCounter += 1 + } + } + } + + fun isEnabled() = + IslandType.SPIDER_DEN.isInIsland() && LorenzUtils.skyBlockArea == "Arachne's Sanctuary" && config.showArachneSpawnTimer +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt deleted file mode 100644 index 528ae4401..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt +++ /dev/null @@ -1,113 +0,0 @@ -package at.hannibal2.skyhanni.features.combat.mobs - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.RegexUtils.matches -import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.TimeUtils.format -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import at.hannibal2.skyhanni.utils.toLorenzVec -import net.minecraft.network.play.server.S2APacketParticles -import net.minecraft.util.EnumParticleTypes -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.Duration.Companion.seconds - -@SkyHanniModule -object SpawnTimers { - - private val config get() = SkyHanniMod.feature.combat.mobs - - private val patternGroup = RepoPattern.group("combat.mobs.spawntime.arachne") - private val arachneFragmentPattern by patternGroup.pattern( - "fragment", - "^☄ [a-z0-9_]{2,22} placed an arachne's calling! something is awakening! \\(4/4\\)\$" - ) - private val arachneCrystalPattern by patternGroup.pattern( - "crystal", - "^☄ [a-z0-9_]{2,22} placed an arachne crystal! something is awakening!$" - ) - - private val arachneAltarLocation = LorenzVec(-283f, 51f, -179f) - private var arachneSpawnTime = SimpleTimeMark.farPast() - private var saveNextTickParticles = false - private var particleCounter = 0 - private var lastTickTime = SimpleTimeMark.farPast() - private var searchTime = SimpleTimeMark.farPast() - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - searchTime = SimpleTimeMark.farPast() - lastTickTime = SimpleTimeMark.farPast() - particleCounter = 0 - saveNextTickParticles = false - arachneSpawnTime = SimpleTimeMark.farPast() - } - - @SubscribeEvent - fun onRenderWorld(event: LorenzRenderWorldEvent) { - if (!isEnabled()) return - if (arachneSpawnTime.isInPast()) return - val countDown = arachneSpawnTime.timeUntil() - - val format = countDown.format(showMilliSeconds = true) - event.drawDynamicText(arachneAltarLocation, "§b$format", 1.5) - } - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!isEnabled()) return - val message = event.message.removeColor().lowercase() - - if (arachneFragmentPattern.matches(message) || arachneCrystalPattern.matches(message)) { - if (arachneCrystalPattern.matches(message)) { - saveNextTickParticles = true - searchTime = SimpleTimeMark.now() - particleCounter = 0 - lastTickTime = SimpleTimeMark.farPast() - } else arachneSpawnTime = SimpleTimeMark.now() + 19.seconds - } - } - - // All this to detect "quickspawn" vs regular arachne spawn - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { - if (!saveNextTickParticles) return - if (searchTime.passedSince() < 3.seconds) return - - if (particleCounter == 0 && lastTickTime.isFarPast()) lastTickTime = SimpleTimeMark.now() - - if (lastTickTime.passedSince() > 60.milliseconds) { - arachneSpawnTime = if (particleCounter <= 20) { - SimpleTimeMark.now() + 21.seconds - } else { - SimpleTimeMark.now() + 37.seconds - } - saveNextTickParticles = false - return - } - - val packet = event.packet - if (packet is S2APacketParticles) { - val location = packet.toLorenzVec().round(2) - if (arachneAltarLocation.distance(location) > 30) return - if (packet.particleType == EnumParticleTypes.REDSTONE && packet.particleSpeed == 1.0f) { - particleCounter += 1 - } - } - } - - fun isEnabled() = - IslandType.SPIDER_DEN.isInIsland() && LorenzUtils.skyBlockArea == "Arachne's Sanctuary" && config.showArachneSpawnTimer -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt index f3378011e..d96e4559f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt @@ -1,21 +1,22 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.TitleManager -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorWorldBoarderPacket import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraft.network.play.server.S44PacketWorldBorder -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @SkyHanniModule object DungeonShadowAssassinNotification { private val config get() = SkyHanniMod.feature.dungeon - @SubscribeEvent - fun onWorldBoarderChange(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onWorldBoarderChange(event: PacketReceivedEvent) { if (!isEnabled()) return if (DungeonAPI.dungeonFloor?.contains("3") == true && DungeonAPI.inBossRoom) return @@ -29,5 +30,5 @@ object DungeonShadowAssassinNotification { } } - private fun isEnabled() = DungeonAPI.inDungeon() && config.shadowAssassinJumpNotifier + private fun isEnabled() = config.shadowAssassinJumpNotifier } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index e017bd7dd..80d6ea0e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -1,13 +1,15 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.BurrowDetectEvent import at.hannibal2.skyhanni.events.BurrowDugEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt @@ -18,7 +20,6 @@ import at.hannibal2.skyhanni.utils.TimeLimitedSet import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.init.Blocks import net.minecraft.network.play.server.S2APacketParticles -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds @@ -57,8 +58,8 @@ object GriffinBurrowParticleFinder { } } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.HUB, priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (!isEnabled()) return if (!config.burrowsSoopyGuess) return val packet = event.packet diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 268eacf0e..d9539fe15 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -2,13 +2,14 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.diana.InquisitorFoundEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy @@ -29,7 +30,6 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.network.play.server.S02PacketChat -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher import kotlin.time.Duration.Companion.seconds @@ -221,8 +221,8 @@ object InquisitorWaypointShare { HypixelCommands.partyChat("x: $x, y: $y, z: $z ") } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onFirstChatEvent(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.HUB, priority = HandleEvent.LOW, receiveCancelled = true) + fun onFirstChatEvent(event: PacketReceivedEvent) { if (!isEnabled()) return val packet = event.packet if (packet !is S02PacketChat) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 46d694131..d648acc29 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.ProfileStorageData @@ -12,8 +13,8 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay @@ -88,9 +89,8 @@ object GardenAPI { "BINGHOE" ) - @SubscribeEvent - fun onSendPacket(event: PacketEvent.SendEvent) { - if (!inGarden()) return + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onSendPacket(event: PacketSentEvent) { if (event.packet !is C09PacketHeldItemChange) return checkItemInHand() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt index a4363a50e..5b9cbf220 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt @@ -3,13 +3,14 @@ package at.hannibal2.skyhanni.features.garden.pests import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.garden.pests.PestUpdateEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled @@ -120,10 +121,10 @@ object PestParticleWaypoint { ++particles } - @SubscribeEvent - fun onFireWorkSpawn(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onFireWorkSpawn(event: PacketReceivedEvent) { if (event.packet !is S0EPacketSpawnObject) return - if (!GardenAPI.inGarden() || !config.hideParticles) return + if (!config.hideParticles) return val fireworkId = 76 if (event.packet.type == fireworkId) event.cancel() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt index 729f9d847..54adcebad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -1,11 +1,12 @@ package at.hannibal2.skyhanni.features.garden.visitor +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig.VisitorBlockBehaviour import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenVisitor -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -89,8 +90,8 @@ object HighlightVisitorsOutsideOfGarden { private fun isVisitorNearby(location: LorenzVec) = EntityUtils.getEntitiesNearby(location, 2.0).any { isVisitor(it) } - @SubscribeEvent - fun onClickEntity(event: PacketEvent.SendEvent) { + @HandleEvent(onlyOnSkyblock = true) + fun onClickEntity(event: PacketSentEvent) { if (!shouldBlock) return val world = Minecraft.getMinecraft().theWorld ?: return val player = Minecraft.getMinecraft().thePlayer ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index 577c014b4..31f8db263 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -8,12 +8,12 @@ import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorRenderEvent import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.ACCEPT_SLOT import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.INFO_SLOT @@ -55,8 +55,8 @@ object VisitorListener { } // TODO make event - @SubscribeEvent - fun onSendEvent(event: PacketEvent.SendEvent) { + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onSendEvent(event: PacketSentEvent) { val packet = event.packet if (packet !is C02PacketUseEntity) return 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 } -- cgit