diff --git a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt index e7e7fd2b5ac3..d0f26b33e812 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt @@ -1,20 +1,21 @@ package at.hannibal2.skyhanni.api +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraft.entity.Entity @SkyHanniModule object DataWatcherAPI { private const val DATA_VALUE_CUSTOM_NAME = 2 - @SubscribeEvent - fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent) { + @HandleEvent + fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent) { for (updatedEntry in event.updatedEntries) { if (updatedEntry.dataValueId == DATA_VALUE_CUSTOM_NAME) { - EntityCustomNameUpdateEvent(event.entity.customNameTag, event.entity).postAndCatch() + EntityCustomNameUpdateEvent(event.entity, event.entity.customNameTag).post() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index 04147ce7794c..0f6fc666fae5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -100,7 +100,7 @@ object EntityData { private fun postRenderNametag(entity: Entity, chatComponent: ChatComponentText) = nametagCache.getOrPut(entity) { val event = EntityDisplayNameEvent(entity, chatComponent) - event.postAndCatch() + event.post() event.chatComponent } diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt index 0d3fd839416b..ff46166c4f6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.EntityMoveEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -16,6 +17,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds @@ -68,9 +70,9 @@ object EntityMovementData { nextTeleport = null } - @SubscribeEvent - fun onPlayerMove(event: EntityMoveEvent) { - if (!LorenzUtils.inSkyBlock || event.entity != Minecraft.getMinecraft().thePlayer) return + @HandleEvent(onlyOnSkyblock = true) + fun onPlayerMove(event: EntityMoveEvent) { + if (!event.isLocalPlayer) return val nextData = nextTeleport ?: return @@ -99,7 +101,7 @@ object EntityMovementData { val distance = newLocation.distance(oldLocation) if (distance > 0.01) { entityLocation[entity] = newLocation - EntityMoveEvent(entity, oldLocation, newLocation, distance).postAndCatch() + EntityMoveEvent(entity, oldLocation, newLocation, distance).post() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt index 0d59fcdf2073..af9c7fd80d68 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt @@ -35,6 +35,7 @@ import at.hannibal2.skyhanni.utils.chat.Text.onClick import at.hannibal2.skyhanni.utils.chat.Text.send import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color import java.io.File @@ -329,9 +330,9 @@ object IslandGraphs { } } - @SubscribeEvent - fun onPlayerMove(event: EntityMoveEvent) { - if (currentIslandGraph != null && event.entity == Minecraft.getMinecraft().thePlayer) { + @HandleEvent(onlyOnSkyblock = true) + fun onPlayerMove(event: EntityMoveEvent) { + if (currentIslandGraph != null && event.isLocalPlayer) { hasMoved = true } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt index 13da59c430d9..b8f0e16c9b36 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt @@ -1,14 +1,13 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent import net.minecraft.client.renderer.culling.ICamera import net.minecraft.entity.Entity -import net.minecraftforge.fml.common.eventhandler.Cancelable -@Cancelable data class CheckRenderEntityEvent( val entity: T, val camera: ICamera, val camX: Double, val camY: Double, val camZ: Double, -) : LorenzEvent() +) : GenericSkyHanniEvent(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt index 05389c2d7f04..df2049517f5b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt @@ -1,9 +1,10 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent import net.minecraft.entity.DataWatcher import net.minecraft.entity.Entity -data class DataWatcherUpdatedEvent( - val entity: Entity, +data class DataWatcherUpdatedEvent( + val entity: T, val updatedEntries: List, -) : LorenzEvent() +) : GenericSkyHanniEvent(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt index 4b4b075e3ac3..4b2d97c3338d 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt @@ -1,8 +1,9 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent import net.minecraft.entity.Entity -data class EntityCustomNameUpdateEvent( +data class EntityCustomNameUpdateEvent( + val entity: T, val newName: String?, - val entity: Entity, -) : LorenzEvent() +) : GenericSkyHanniEvent(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt index efef208401b4..7ed391d6a3ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt @@ -1,13 +1,14 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent import net.minecraft.entity.Entity import net.minecraft.item.ItemStack -data class EntityEquipmentChangeEvent( - val entity: Entity, +data class EntityEquipmentChangeEvent( + val entity: T, val equipmentSlot: Int, val newItemStack: ItemStack?, -) : LorenzEvent() { +) : GenericSkyHanniEvent(entity.javaClass) { val isHead get() = equipmentSlot == EQUIPMENT_SLOT_HEAD val isChest get() = equipmentSlot == EQUIPMENT_SLOT_CHEST diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt index 68c913c1fda1..a27db36d3073 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt @@ -1,11 +1,15 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent import at.hannibal2.skyhanni.utils.LorenzVec +import net.minecraft.client.Minecraft import net.minecraft.entity.Entity -class EntityMoveEvent( - val entity: Entity, +class EntityMoveEvent( + val entity: T, val oldLocation: LorenzVec, val newLocation: LorenzVec, val distance: Double, -) : LorenzEvent() +) : GenericSkyHanniEvent(entity.javaClass) { + val isLocalPlayer by lazy { entity == Minecraft.getMinecraft().thePlayer } +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/entity/EntityDisplayNameEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityDisplayNameEvent.kt index c4d24eb0a2c9..2fa7272c212d 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/entity/EntityDisplayNameEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityDisplayNameEvent.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.events.entity -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent import net.minecraft.entity.Entity import net.minecraft.util.ChatComponentText -class EntityDisplayNameEvent(val entity: Entity, var chatComponent: ChatComponentText) : LorenzEvent() +class EntityDisplayNameEvent(val entity: T, var chatComponent: ChatComponentText) : GenericSkyHanniEvent(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt index 95dabce0ea56..a1b7142380ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.DamageIndicatorFinalBossEvent import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent @@ -15,6 +17,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityGuardian import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -91,8 +94,8 @@ object DungeonCleanEnd { } } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!shouldBlock()) return val entity = event.entity diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt index cac381aee2b5..8a976a7a8518 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.DungeonBossRoomEnterEvent import at.hannibal2.skyhanni.events.DungeonEnterEvent @@ -107,12 +108,9 @@ object DungeonCopilot { nextStep = step } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!DungeonAPI.inDungeon()) return - + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onCheckRender(event: CheckRenderEntityEvent) { val entity = event.entity - if (entity !is EntityArmorStand) return if (!searchForKey) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt index 42ccaded565a..ab7e0ed9928c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt @@ -1,8 +1,10 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.EntityMovementData +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.EntityMoveEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent @@ -42,10 +44,8 @@ object DungeonHideItems { private fun isSkeletonSkull(entity: EntityArmorStand): Boolean = entity.getStandHelmet()?.cleanName() == "Skeleton Skull" - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!DungeonAPI.inDungeon()) return - + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onCheckRender(event: CheckRenderEntityEvent) { val entity = event.entity if (entity is EntityItem) { @@ -170,12 +170,9 @@ object DungeonHideItems { } } - @SubscribeEvent - fun onEntityMove(event: EntityMoveEvent) { - if (!DungeonAPI.inDungeon()) return - + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onEntityMove(event: EntityMoveEvent) { val entity = event.entity - if (entity !is EntityArmorStand) return if (isSkeletonSkull(entity)) { movingSkeletonSkulls[entity] = System.currentTimeMillis() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index a372b5670ae2..26f04279f669 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -1,6 +1,8 @@ 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.mob.Mob import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent @@ -91,8 +93,8 @@ object DungeonLividFinder { lividArmorStandId = null } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!inLividBossRoom() || !config.hideWrong) return if (livid == null && lividArmorStandId == null) return // in case livid detection fails, don't hide anything if (event.entity.mob in fakeLivids) event.cancel() 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 1e0701457fa6..7dcc13110a7e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt @@ -80,10 +80,9 @@ object UniqueGiftingOpportunitiesFeatures { addGiftedPlayer(matchedPlayer.name) } - @SubscribeEvent - fun onEntityChangeName(event: EntityCustomNameUpdateEvent) { - val entity = event.entity as? EntityArmorStand ?: return - analyzeArmorStand(entity) + @HandleEvent(onlyOnSkyblock = true) + fun onEntityChangeName(event: EntityCustomNameUpdateEvent) { + analyzeArmorStand(event.entity) } @HandleEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index 997ff7fd7367..c8b6da4fd6d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -38,6 +38,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard @@ -179,10 +180,10 @@ object GriffinBurrowHelper { update() } - @SubscribeEvent - fun onPlayerMove(event: EntityMoveEvent) { + @HandleEvent + fun onPlayerMove(event: EntityMoveEvent) { if (!isEnabled()) return - if (event.distance > 10 && event.entity == Minecraft.getMinecraft().thePlayer) { + if (event.distance > 10 && event.isLocalPlayer) { update() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt index ec1cf149742d..86d2e46890a6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.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.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent @@ -28,13 +29,11 @@ object ChumBucketHider { reset() } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!LorenzUtils.inSkyBlock) return + @HandleEvent(onlyOnSkyblock = true) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!config.enabled.get()) return val entity = event.entity - if (entity !is EntityArmorStand) return if (entity in hiddenEntities) { event.cancel() 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 b4a7e5804b4b..d1f005ae490c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt @@ -55,8 +55,8 @@ object FishingHookDisplay { potentialArmorStands.add(event.entity) } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent + fun onCheckRender(event: CheckRenderEntityEvent) { if (!isEnabled()) return if (!config.hideArmorStand) 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 66d03745f372..5e65bc581f73 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 @@ -144,14 +144,13 @@ object VisitorListener { GardenVisitorFeatures.onTooltip(visitor, event.itemStack, event.toolTip) } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!GardenAPI.inGarden()) return + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!GardenAPI.onBarnPlot) return if (config.highlightStatus != VisitorConfig.HighlightMode.NAME && config.highlightStatus != VisitorConfig.HighlightMode.BOTH) return val entity = event.entity - if (entity is EntityArmorStand && entity.name == "§e§lCLICK") { + if (entity.name == "§e§lCLICK") { event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt index bf495c61aadc..ff5bdcacb66c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorJsonEntry import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorsJson import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer @@ -22,13 +23,11 @@ object ContributorManager { contributors = event.getConstant("Contributors").contributors.mapKeys { it.key.lowercase() } } - @SubscribeEvent - fun onRenderNametag(event: EntityDisplayNameEvent) { + @HandleEvent + fun onRenderNametag(event: EntityDisplayNameEvent) { if (!config.contributorNametags) return - (event.entity as? EntityPlayer)?.let { player -> - if (player.isRealPlayer()) getSuffix(event.entity.name)?.let { - event.chatComponent.appendSibling(ChatComponentText(" $it")) - } + if (event.entity.isRealPlayer()) getSuffix(event.entity.name)?.let { + event.chatComponent.appendSibling(ChatComponentText(" $it")) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt index 6fad15f8dff8..2660a6d41d16 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt @@ -1,22 +1,17 @@ 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.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.item.EntityXPOrb -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ExpOrbsOnGroundHider { - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!LorenzUtils.inSkyBlock) return + @HandleEvent(onlyOnSkyblock = true) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!SkyHanniMod.feature.misc.hideExpBottles) return - - if (event.entity is EntityXPOrb) { - event.cancel() - } + event.cancel() } } 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 11ffaa0f77fa..d3c0b752a17f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.CheckRenderEntityEvent 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.MobUtils.isDefaultValue import at.hannibal2.skyhanni.utils.compat.getWholeInventory import net.minecraft.entity.item.EntityArmorStand @@ -62,10 +61,9 @@ object FixGhostEntities { } } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!LorenzUtils.inSkyBlock || !config.hideTemporaryArmorstands) return - if (event.entity !is EntityArmorStand) return + @HandleEvent(onlyOnSkyblock = true) + fun onCheckRender(event: CheckRenderEntityEvent) { + if (!config.hideTemporaryArmorstands) return with(event.entity) { if (ticksExisted < 10 && isDefaultValue() && getWholeInventory().all { it == null }) event.cancel() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt index 8a47da6f72e5..d135a1f59100 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt @@ -1,6 +1,7 @@ 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.LorenzTickEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI @@ -9,6 +10,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.entity.Entity import net.minecraft.entity.boss.EntityWither import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -32,11 +34,12 @@ object HideFarEntities { .map { it.first }.toSet() } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent(onlyOnSkyblock = true) + fun onCheckRender(event: CheckRenderEntityEvent) { + if (!isEnabled()) return val entity = event.entity if (entity is EntityWither && entity.entityId < 0) return - if (isEnabled() && entity.entityId in ignored) { + if (entity.entityId in ignored) { event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt index 7714123c7f20..e347962079c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt @@ -32,7 +32,7 @@ import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.renderables.buildSearchBox import at.hannibal2.skyhanni.utils.renderables.toSearchable import kotlinx.coroutines.launch -import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -94,9 +94,9 @@ object IslandAreas { } } - @SubscribeEvent - fun onPlayerMove(event: EntityMoveEvent) { - if (isEnabled() && event.entity == Minecraft.getMinecraft().thePlayer) { + @HandleEvent(onlyOnSkyblock = true) + fun onPlayerMove(event: EntityMoveEvent) { + if (isEnabled() && event.isLocalPlayer) { hasMoved = true } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt index 410c69d0c960..aa36989a0e34 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt @@ -1,6 +1,7 @@ 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.EntityEquipmentChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent @@ -22,18 +23,18 @@ object LesserOrbHider { private val LESSER_TEXTURE by lazy { SkullTextureHolder.getTexture("") } - @SubscribeEvent - fun onArmorChange(event: EntityEquipmentChangeEvent) { + @HandleEvent(onlyOnSkyblock = true) + fun onArmorChange(event: EntityEquipmentChangeEvent) { val entity = event.entity val itemStack = event.newItemStack ?: return - if (entity is EntityArmorStand && event.isHand && itemStack.getSkullTexture() == LESSER_TEXTURE) { + if (event.isHand && itemStack.getSkullTexture() == LESSER_TEXTURE) { hiddenEntities.add(entity) } } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent + fun onCheckRender(event: CheckRenderEntityEvent) { if (!isEnabled()) return if (event.entity in hiddenEntities) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt index 1b1e0e24249d..6954a6b2f5e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc.pets import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils @@ -10,7 +11,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.chat.Text.asComponent import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object PetNametag { @@ -26,10 +26,9 @@ object PetNametag { "(?§8\\[§7Lv(?\\d+)§8]) (?§.)(?[\\w\\s]+)(?§. ✦)?", ) - @SubscribeEvent - fun onNameTagRender(event: EntityDisplayNameEvent) { + @HandleEvent + fun onNameTagRender(event: EntityDisplayNameEvent) { if (!isEnabled()) return - if (event.entity !is EntityArmorStand) return petNametagPattern.matchMatcher(event.chatComponent.unformattedText) { val start = group("start") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 274dc022fdb2..ec93e9a25b3d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc.trevor import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.TrevorTheTrapperConfig.TrackerEntry import at.hannibal2.skyhanni.data.IslandType @@ -327,12 +328,12 @@ object TrevorFeatures { } } - @SubscribeEvent(priority = EventPriority.HIGHEST) - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent(priority = HandleEvent.HIGHEST, onlyOnIsland = IslandType.THE_FARMING_ISLANDS) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!inTrapperDen) return if (!config.trapperTalkCooldown) return val entity = event.entity - if (entity is EntityArmorStand && entity.name == "§e§lCLICK") { + if (entity.name == "§e§lCLICK") { event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt index f63158cd7422..a136fc56a7bd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.nether.ashfang +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent @@ -32,11 +34,10 @@ object AshfangHider { event.cancel() } - @SubscribeEvent(priority = EventPriority.HIGH) - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent(priority = HandleEvent.HIGH, onlyOnIsland = IslandType.CRIMSON_ISLE) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!AshfangManager.active || !config.particles) return - val entity = event.entity as? EntityArmorStand ?: return - if (entity.getWholeInventory().any { it?.name == "Glowstone" }) event.cancel() + if (event.entity.getWholeInventory().any { it?.name == "Glowstone" }) event.cancel() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt index 69cc830d2baf..43d0ad1b2726 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.features.rift.area.dreadfarm +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.rift.RiftAPI @@ -38,9 +40,9 @@ object VoltHighlighter { private val CHARGE_TIME = 12.seconds private var chargingSince = mapOf() - @SubscribeEvent - fun onArmorChange(event: EntityEquipmentChangeEvent) { - if (!RiftAPI.inRift() || !config.voltWarning) return + @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) + fun onArmorChange(event: EntityEquipmentChangeEvent) { + if (!config.voltWarning) return val player = Minecraft.getMinecraft().thePlayer ?: return if (event.isHead && getVoltState(event.entity) == VoltState.DOING_LIGHTNING && event.entity.positionVector.squareDistanceTo(player.positionVector) <= LIGHTNING_DISTANCE * LIGHTNING_DISTANCE diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/CraftRoomHolographicMob.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/CraftRoomHolographicMob.kt index 4d54366bdd02..b40fcca93c1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/CraftRoomHolographicMob.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/CraftRoomHolographicMob.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.rift.area.mirrorverse import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent @@ -86,12 +88,12 @@ object CraftRoomHolographicMob { } } - @SubscribeEvent(receiveCanceled = true) - fun onPlayerRender(event: CheckRenderEntityEvent<*>) { - if (!RiftAPI.inRift() || !config.hidePlayers) return + @HandleEvent(receiveCancelled = true, onlyOnIsland = IslandType.THE_RIFT) + fun onPlayerRender(event: CheckRenderEntityEvent) { + if (!config.hidePlayers) return val entity = event.entity - if (entity is EntityOtherPlayerMP && craftRoomArea.isInside(entity.getLorenzVec())) { + if (craftRoomArea.isInside(entity.getLorenzVec())) { event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt index 7612490aaed5..f571d2b42630 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.rift.area.mirrorverse import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.jsonobjects.repo.DanceRoomInstructionsJson import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -157,13 +159,10 @@ object DanceRoomHelper { } } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (RiftAPI.inRift() && config.hidePlayers) { - val entity = event.entity - if (entity is EntityOtherPlayerMP && inRoom) { - event.cancel() - } + @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) + fun onCheckRender(event: CheckRenderEntityEvent) { + if (config.enabled && inRoom) { + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt index cd6f73078285..8d20ba6c256d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.mirrorverse +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ParkourHelper import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor +import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule @@ -32,8 +34,8 @@ object RiftLavaMazeParkour { updateConfig() } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent + fun onCheckRender(event: CheckRenderEntityEvent) { if (!isEnabled()) return if (!config.hidePlayers) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt index 9a6d668f973d..b77e099222a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.mirrorverse +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ParkourHelper import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor +import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule @@ -31,8 +33,8 @@ object RiftUpsideDownParkour { updateConfig() } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent + fun onCheckRender(event: CheckRenderEntityEvent) { if (!isEnabled()) return if (!config.hidePlayers) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt index d81ffc8a3319..f4d8cdaa63c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.mirrorverse +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import at.hannibal2.skyhanni.utils.ParkourHelper import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor +import net.minecraft.entity.Entity import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -33,8 +35,8 @@ object TubulatorParkour { updateConfig() } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent + fun onCheckRender(event: CheckRenderEntityEvent) { if (!isEnabled()) return if (!config.hidePlayers) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt index 9ed22283017e..a19607633734 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/RiftGunthersRace.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.westvillage +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent @@ -17,6 +18,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule @@ -108,8 +110,8 @@ object RiftGunthersRace { } } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent + fun onCheckRender(event: CheckRenderEntityEvent) { if (!isEnabled()) return if (!config.hidePlayers) return if (!RiftAPI.inRiftRace) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt index 69bb4559314b..8d060892a1cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt @@ -1,25 +1,24 @@ package at.hannibal2.skyhanni.features.rift.everywhere import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import net.minecraft.entity.passive.EntityHorse -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object RiftHorsezookaHider { private val HORSEZOOKA by lazy { "HORSEZOOKA".toInternalName() } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!RiftAPI.inRift()) return + @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) + fun onCheckRender(event: CheckRenderEntityEvent) { if (!SkyHanniMod.feature.rift.horsezookaHider) return - if (event.entity is EntityHorse && InventoryUtils.itemInHandId == HORSEZOOKA) { + if (InventoryUtils.itemInHandId == HORSEZOOKA) { event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt index b7d97adf4877..065331ec2939 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent @@ -44,13 +45,10 @@ object BlazeSlayerClearView { } } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { + @HandleEvent(onlyOnSkyblock = true) + fun onCheckRender(event: CheckRenderEntityEvent) { if (isEnabled()) { - val entity = event.entity - if (entity is EntityFireball) { - event.cancel() - } + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index 9d8a534511b9..7cae7db35eda 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.slayer.enderman import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent @@ -34,6 +35,7 @@ import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.compat.getStandHelmet import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityEnderman import net.minecraft.init.Blocks @@ -53,9 +55,8 @@ object EndermanSlayerFeatures { private val NUKEKUBI_SKULL_TEXTURE by lazy { SkullTextureHolder.getTexture("MOB_NUKEKUBI") } - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!IslandType.THE_END.isInIsland()) return + @HandleEvent(onlyOnIsland = IslandType.THE_END) + fun onCheckRender(event: CheckRenderEntityEvent) { val entity = event.entity if (entity in endermenWithBeacons || entity in flyingBeacons) return diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java index b8bb676db082..0e1c529df46f 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java @@ -26,7 +26,7 @@ private void onSendPacket(Packet packet, CallbackInfo ci) { @Inject(method = "handleEntityEquipment", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setCurrentItemOrArmor(ILnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) public void onEntityEquipment(S04PacketEntityEquipment packetIn, CallbackInfo ci, Entity entity) { - new EntityEquipmentChangeEvent(entity, packetIn.getEquipmentSlot(), packetIn.getItemStack()).postAndCatch(); + new EntityEquipmentChangeEvent(entity, packetIn.getEquipmentSlot(), packetIn.getItemStack()).post(); } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java index d9c530bfb8f6..08638b4d8c78 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java @@ -14,7 +14,7 @@ public class MixinRenderManager { @Inject(method = "shouldRender", at = @At("HEAD"), cancellable = true) private void shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ, CallbackInfoReturnable cir) { - if (new CheckRenderEntityEvent<>(entity, camera, camX, camY, camZ).postAndCatch()) { + if (new CheckRenderEntityEvent<>(entity, camera, camX, camY, camZ).post()) { cir.setReturnValue(false); } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java index bcc30f42dc47..f5f3555f5791 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java @@ -20,6 +20,6 @@ public class UpdateDataWatcherEventPatch { @Inject(method = "updateWatchedObjectsFromList", at = @At("TAIL")) public void onWhatever(List list, CallbackInfo ci) { - new DataWatcherUpdatedEvent(owner, list).postAndCatch(); + new DataWatcherUpdatedEvent(owner, list).post(); } }