aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorBrady <thatgravyboat@gmail.com>2024-06-07 22:09:36 -0230
committerGitHub <noreply@github.com>2024-06-08 02:39:36 +0200
commit376404aa6ec7ffe3bea6fb3a99f43139dcbfd307 (patch)
treeb615e1d84b1b030713df1cfb004cdd564c350fd2 /src/main/java/at/hannibal2/skyhanni/features
parent79d0cd3af5b2acf11fc63bc3aa6743f784a3a0f6 (diff)
downloadskyhanni-376404aa6ec7ffe3bea6fb3a99f43139dcbfd307.tar.gz
skyhanni-376404aa6ec7ffe3bea6fb3a99f43139dcbfd307.tar.bz2
skyhanni-376404aa6ec7ffe3bea6fb3a99f43139dcbfd307.zip
Backend: Custom event bus (#2008)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt10
5 files changed, 26 insertions, 29 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
index 58455cee7..6ee7979fa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.combat.damageindicator
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory
import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.NameVisibility
@@ -48,6 +49,7 @@ import com.google.gson.JsonArray
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
@@ -849,8 +851,8 @@ class DamageIndicatorManager {
return maxHealth.getOrDefault(entity.uniqueID!!, 0L)
}
- @SubscribeEvent
- fun onEntityJoin(event: EntityEnterWorldEvent) {
+ @HandleEvent
+ fun onEntityJoin(event: EntityEnterWorldEvent<Entity>) {
mobFinder?.handleNewEntity(event.entity)
}
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<Entity>) {
playerColor(event)
val entity = event.entity as? EntityArmorStand ?: return
analyzeArmorStand(entity)
}
- private fun playerColor(event: EntityEnterWorldEvent) {
+ private fun playerColor(event: EntityEnterWorldEvent<Entity>) {
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<EntityOtherPlayerMP>) {
+ if (event.entity.name == "Minos Inquisitor") {
+ InquisitorFoundEvent(event.entity).postAndCatch()
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
index 89beae6aa..f48309bb0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.fishing
+import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent
@@ -55,17 +56,15 @@ object FishingAPI {
var wearingTrophyArmor = false
- @SubscribeEvent
- fun onJoinWorld(event: EntityEnterWorldEvent) {
- if (!LorenzUtils.inSkyBlock || !holdingRod) return
- val entity = event.entity ?: return
- if (entity !is EntityFishHook) return
- if (entity.angler != Minecraft.getMinecraft().thePlayer) return
+ @HandleEvent(onlyOnSkyblock = true)
+ fun onJoinWorld(event: EntityEnterWorldEvent<EntityFishHook>) {
+ if (!holdingRod) return
+ if (event.entity.angler != Minecraft.getMinecraft().thePlayer) return
lastCastTime = SimpleTimeMark.now()
- bobber = entity
+ bobber = event.entity
bobberHasTouchedWater = false
- FishingBobberCastEvent(entity).postAndCatch()
+ FishingBobberCastEvent(event.entity).postAndCatch()
}
private fun resetBobber() {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
index 6e2211f58..b4a7e5804 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.fishing
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
@@ -48,13 +49,10 @@ object FishingHookDisplay {
armorStand = null
}
- @SubscribeEvent
- fun onJoinWorld(event: EntityEnterWorldEvent) {
+ @HandleEvent
+ fun onJoinWorld(event: EntityEnterWorldEvent<EntityArmorStand>) {
if (!isEnabled()) return
- val entity = event.entity
- if (entity !is EntityArmorStand) return
-
- potentialArmorStands.add(entity)
+ potentialArmorStands.add(event.entity)
}
@SubscribeEvent