From 376404aa6ec7ffe3bea6fb3a99f43139dcbfd307 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 7 Jun 2024 22:09:36 -0230 Subject: Backend: Custom event bus (#2008) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal --- .../features/event/UniqueGiftingOpportunitiesFeatures.kt | 10 ++++++---- .../at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt | 14 +++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/event') diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt index 7f312d656..e24a66594 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.event import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.WinterAPI import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent @@ -22,6 +23,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.player.EntityPlayer @@ -73,16 +75,16 @@ object UniqueGiftingOpportunitiesFeatures { analyzeArmorStand(entity) } - @SubscribeEvent - fun onEntityJoinWorld(event: EntityEnterWorldEvent) { + @HandleEvent + fun onEntityJoinWorld(event: EntityEnterWorldEvent) { playerColor(event) val entity = event.entity as? EntityArmorStand ?: return analyzeArmorStand(entity) } - private fun playerColor(event: EntityEnterWorldEvent) { + private fun playerColor(event: EntityEnterWorldEvent) { if (event.entity is EntityOtherPlayerMP) { - val entity = event.entity as EntityOtherPlayerMP + val entity = event.entity if (entity.isNPC() || isIronman(entity) || isBingo(entity)) return RenderLivingEntityHelper.setEntityColor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt index 4b1cde2d4..a8c440efe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.event.diana +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.data.PetAPI @@ -8,12 +9,10 @@ import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object DianaAPI { @@ -33,13 +32,10 @@ object DianaAPI { private fun hasSpadeInInventory() = InventoryUtils.getItemsInOwnInventory().any { it.isDianaSpade } - @SubscribeEvent - fun onJoinWorld(event: EntityEnterWorldEvent) { - if (!LorenzUtils.inSkyBlock) return - - val entity = event.entity - if (entity is EntityOtherPlayerMP && entity.name == "Minos Inquisitor") { - InquisitorFoundEvent(entity).postAndCatch() + @HandleEvent(onlyOnSkyblock = true) + fun onJoinWorld(event: EntityEnterWorldEvent) { + if (event.entity.name == "Minos Inquisitor") { + InquisitorFoundEvent(event.entity).postAndCatch() } } } -- cgit