diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-03-07 21:46:17 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 11:46:17 +0100 |
commit | 7facd340b6e51d862a9e32977e56a7b0f69f3da0 (patch) | |
tree | 977d9d9c01518f660ed1b461e1ff2d3fc51d2612 /src/main/java/at/hannibal2/skyhanni | |
parent | 1181ef837104b4a5f68de6cf5793b21ad7573e03 (diff) | |
download | skyhanni-7facd340b6e51d862a9e32977e56a7b0f69f3da0.tar.gz skyhanni-7facd340b6e51d862a9e32977e56a7b0f69f3da0.tar.bz2 skyhanni-7facd340b6e51d862a9e32977e56a7b0f69f3da0.zip |
Backend: Use less forge events (#1085)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
27 files changed, 189 insertions, 95 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 80a9341d2..a33df78e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -366,6 +366,7 @@ import at.hannibal2.skyhanni.test.command.CopyNearbyParticlesCommand import at.hannibal2.skyhanni.test.hotswap.HotswapSupport import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityOutlineRenderer +import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging @@ -461,6 +462,7 @@ class SkyHanniMod { loadModule(UtilsPatterns) loadModule(PetAPI) loadModule(BossbarData) + loadModule(EntityUtils) loadModule(ChatUtils) // APIs diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 4650bda6d..915acf214 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -112,7 +112,10 @@ object ChatManager { val original = event.message val message = LorenzUtils.stripVanillaMessage(original.formattedText) - if (message.startsWith("§f{\"server\":\"")) return + if (message.startsWith("§f{\"server\":\"")) { + HypixelData.checkForLocraw(message) + return + } val key = IdentityCharacteristics(original) val chatEvent = LorenzChatEvent(message, original) if (!isSoopyMessage(event.message)) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 8cce72bba..b206eb565 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -24,8 +24,6 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonObject import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.client.Minecraft -import net.minecraftforge.client.event.ClientChatReceivedEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent import kotlin.concurrent.thread @@ -34,10 +32,6 @@ import kotlin.time.Duration.Companion.seconds class HypixelData { private val patternGroup = RepoPattern.group("data.hypixeldata") - private val lobbyTypePattern by patternGroup.pattern( - "lobbytype", - "(?<lobbyType>.*lobby)\\d+" - ) private val islandNamePattern by patternGroup.pattern( "islandname", "(?:§.)*(Area|Dungeon): (?:§.)*(?<island>.*)" @@ -55,6 +49,10 @@ class HypixelData { "serverid.tablist", " Server: §r§8(?<serverid>\\S+)" ) + private val lobbyTypePattern by patternGroup.pattern( + "lobbytype", + "(?<lobbyType>.*lobby)\\d+" + ) var hypixelLive = false var hypixelAlpha = false @@ -115,6 +113,36 @@ class HypixelData { return serverId } + + // This code is modified from NEU, and depends on NEU (or another mod) sending /locraw. + private val jsonBracketPattern = "^\\{.+}".toPattern() + + //todo convert to proper json object + fun checkForLocraw(message: String) { + jsonBracketPattern.matchMatcher(message.removeColor()) { + try { + val obj: JsonObject = gson.fromJson(group(), JsonObject::class.java) + if (obj.has("server")) { + locrawData = obj + locraw.keys.forEach { key -> + locraw[key] = obj[key]?.asString ?: "" + } + inLimbo = locraw["server"] == "limbo" + inLobby = locraw["lobbyname"] != "" + + if (inLobby) { + locraw["lobbyname"]?.let { + lobbyTypePattern.matchMatcher(it) { + locraw["lobbytype"] = group("lobbyType") + } + } + } + } + } catch (e: Exception) { + ErrorManager.logErrorWithData(e, "Failed to parse locraw data") + } + } + } } private var loggerIslandChange = LorenzLogger("debug/island_change") @@ -313,34 +341,4 @@ class HypixelData { return scoreboardTitle.contains("SKYBLOCK") || scoreboardTitle.contains("SKIBLOCK") // April 1st jokes are so funny } - - // This code is modified from NEU, and depends on NEU (or another mod) sending /locraw. - private val jsonBracketPattern = "^\\{.+}".toPattern() - - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onChatMessage(event: ClientChatReceivedEvent) { - jsonBracketPattern.matchMatcher(event.message.unformattedText) { - try { - val obj: JsonObject = gson.fromJson(group(), JsonObject::class.java) - if (obj.has("server")) { - locrawData = obj - locraw.keys.forEach { key -> - locraw[key] = obj[key]?.asString ?: "" - } - inLimbo = locraw["server"] == "limbo" - inLobby = locraw["lobbyname"] != "" - - if (inLobby) { - locraw["lobbyname"]?.let { - lobbyTypePattern.matchMatcher(it) { - locraw["lobbytype"] = group("lobbyType") - } - } - } - } - } catch (e: Exception) { - ErrorManager.logErrorWithData(e, "Failed to parse locraw data") - } - } - } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiKeyPressEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiKeyPressEvent.kt new file mode 100644 index 000000000..1c420d743 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiKeyPressEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.client.gui.inventory.GuiContainer + +class GuiKeyPressEvent(val guiContainer: GuiContainer) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/SkyHanniRenderEntityEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SkyHanniRenderEntityEvent.kt new file mode 100644 index 000000000..289e661f1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/SkyHanniRenderEntityEvent.kt @@ -0,0 +1,54 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.client.renderer.entity.RendererLivingEntity +import net.minecraft.entity.EntityLivingBase +import net.minecraftforge.fml.common.eventhandler.Cancelable + +@Cancelable +open class SkyHanniRenderEntityEvent<T : EntityLivingBase>( + val entity: T, + val renderer: RendererLivingEntity<out T>, + val x: Double, + val y: Double, + val z: Double +) : LorenzEvent() { + class Pre<T : EntityLivingBase>( + entity: T, + renderer: RendererLivingEntity<out T>, + x: Double, + y: Double, + z: Double + ) : SkyHanniRenderEntityEvent<T>(entity, renderer, x, y, z) + + class Post<T : EntityLivingBase>( + entity: T, + renderer: RendererLivingEntity<out T>, + x: Double, + y: Double, + z: Double + ) : SkyHanniRenderEntityEvent<T>(entity, renderer, x, y, z) + + open class Specials<T : EntityLivingBase>( + entity: T, + renderer: RendererLivingEntity<out T>, + x: Double, + y: Double, + z: Double + ) : SkyHanniRenderEntityEvent<T>(entity, renderer, x, y, z) { + class Pre<T : EntityLivingBase>( + entity: T, + renderer: RendererLivingEntity<out T>, + x: Double, + y: Double, + z: Double + ) : Specials<T>(entity, renderer, x, y, z) + + class Post<T : EntityLivingBase>( + entity: T, + renderer: RendererLivingEntity<out T>, + x: Double, + y: Double, + z: Double + ) : Specials<T>(entity, renderer, x, y, z) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt index 7b2684c40..4931449ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt @@ -2,17 +2,17 @@ package at.hannibal2.skyhanni.features.combat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class HideDamageSplash { @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderDamage(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderDamage(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.combat.hideDamageSplash) return @@ -25,4 +25,4 @@ class HideDamageSplash { fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "misc.hideDamageSplash", "combat.hideDamageSplash") } -}
\ No newline at end of file +} 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 274e64f9d..563917cd3 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 @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield @@ -53,7 +54,6 @@ import net.minecraft.entity.monster.EntityEnderman import net.minecraft.entity.monster.EntityMagmaCube import net.minecraft.entity.monster.EntityZombie import net.minecraft.entity.passive.EntityWolf -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -857,7 +857,7 @@ class DamageIndicatorManager { private val dummyDamageCache = mutableListOf<UUID>() @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { val entity = event.entity val entityData = data.values.find { diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt index aa861a29b..dc05046ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt @@ -1,10 +1,10 @@ package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -13,7 +13,7 @@ class AshfangMinisNametagHider { private val config get() = SkyHanniMod.feature.combat.mobs @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!LorenzUtils.inSkyBlock) return if (!config.hideNameTagArachneMinis) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt index ff3b4fac3..7671ef5a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -11,9 +12,7 @@ import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.item.ItemStack -import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.net.URLEncoder @@ -58,11 +57,10 @@ object WikiManager { } @SubscribeEvent - fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { + fun onKeybind(event: GuiKeyPressEvent) { if (!LorenzUtils.inSkyBlock) return - val gui = event.gui as? GuiContainer ?: return - if (NEUItems.neuHasFocus()) return // because good heavens if this worked on neuitems... - val stack = gui.slotUnderMouse?.stack ?: return + if (NEUItems.neuHasFocus()) return + val stack = event.guiContainer.slotUnderMouse?.stack ?: return if (!config.wikiKeybind.isKeyHeld()) return wikiTheItem(stack, config.menuOpenWiki) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt index a298aff40..0d22b81be 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt @@ -1,17 +1,17 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DungeonBossHideDamageSplash { @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!LorenzUtils.inDungeons) return if (!SkyHanniMod.feature.dungeon.damageSplashBoss) return if (!DungeonAPI.inBossRoom) return @@ -20,4 +20,4 @@ class DungeonBossHideDamageSplash { event.isCanceled = true } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt index 4447db0b4..7b47adfda 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt @@ -3,10 +3,10 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -30,7 +30,7 @@ class TerracottaPhase { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (isActive() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) { event.isCanceled = true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index 586906554..e1a02630a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -68,6 +68,10 @@ class GardenOptimalSpeed { @SubscribeEvent fun onGuiOpen(event: GuiOpenEvent) { + if (!isRancherOverlayEnabled()) return + val gui = event.gui + if (gui !is GuiEditSign) return + if (!gui.isRancherSign()) return rancherOverlayList = CropType.entries.map { crop -> listOf(crop.icon, Renderable.link("${crop.cropName} - ${crop.getOptimalSpeed()}") { LorenzUtils.setTextIntoSign("${crop.getOptimalSpeed()}") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 11669cece..d63127c87 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SackDataUpdateEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptedEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent @@ -63,7 +64,6 @@ import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.item.ItemStack import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.round @@ -593,7 +593,7 @@ class GardenVisitorFeatures { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!config.coloredName) return val entity = event.entity val entityId = entity.entityId 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 dac868528..85fb441ab 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 @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent @@ -29,7 +30,6 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.entity.item.EntityArmorStand import net.minecraft.network.play.client.C02PacketUseEntity -import net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -119,10 +119,10 @@ class VisitorListener { } @SubscribeEvent - fun onKeybind(event: KeyboardInputEvent.Post) { + fun onKeybind(event: GuiKeyPressEvent) { if (!VisitorAPI.inInventory) return if (!config.acceptHotkey.isKeyHeld()) return - val inventory = event.gui as? AccessorGuiContainer ?: return + val inventory = event.guiContainer as? AccessorGuiContainer ?: return inventory as GuiContainer val slot = inventory.inventorySlots.getSlot(29) inventory.handleMouseClick_skyhanni(slot, slot.slotIndex, 0, 0) diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index b908acefc..bbb9ae874 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.MinionCloseEvent import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.events.MinionStorageOpenEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt import at.hannibal2.skyhanni.utils.ChatUtils @@ -51,7 +52,6 @@ import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.init.Blocks import net.minecraftforge.client.event.GuiScreenEvent -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -337,7 +337,7 @@ class MinionFeatures { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!enable()) return if (!config.hideMobsNametagNearby) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt index d8409416b..cd842f6bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.HideArmorConfig.ModeEntry +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.EntityUtils.hasPotionEffect @@ -13,7 +14,6 @@ import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.potion.Potion -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class HideArmor { @@ -38,7 +38,7 @@ class HideArmor { } @SubscribeEvent - fun onRenderLivingPre(event: RenderLivingEvent.Pre<EntityLivingBase>) { + fun onRenderLivingPre(event: SkyHanniRenderEntityEvent.Pre<EntityLivingBase>) { val entity = event.entity if (!shouldHideArmor(entity)) return val armorInventory = entity.getArmorInventory() ?: return @@ -56,7 +56,7 @@ class HideArmor { } @SubscribeEvent - fun onRenderLivingPost(event: RenderLivingEvent.Post<EntityLivingBase>) { + fun onRenderLivingPost(event: SkyHanniRenderEntityEvent.Post<EntityLivingBase>) { val entity = event.entity if (!shouldHideArmor(entity)) return val armorInventory = entity.getArmorInventory() ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt index 71ee70b55..aacec8be7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -17,8 +18,6 @@ import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import net.minecraft.client.gui.inventory.GuiContainer -import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AuctionHouseCopyUnderbidPrice { @@ -57,13 +56,11 @@ class AuctionHouseCopyUnderbidPrice { } @SubscribeEvent - fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { + fun onKeybind(event: GuiKeyPressEvent) { if (!config.copyUnderbidKeybind.isKeyHeld()) return if (!LorenzUtils.inSkyBlock) return if (!allowedInventoriesPattern.matches(InventoryUtils.openInventoryName())) return - - val gui = event.gui as? GuiContainer ?: return - val stack = gui.slotUnderMouse?.stack ?: return + val stack = event.guiContainer.slotUnderMouse?.stack ?: return val lore = stack.getLore() for (line in lore) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt index 3b08970cf..fa2f5c551 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt @@ -2,12 +2,12 @@ package at.hannibal2.skyhanni.features.misc.teleportpad import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -23,8 +23,8 @@ class TeleportPadCompactName { ) @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLivingB(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { - if (!IslandType.PRIVATE_ISLAND.isInIsland()) return + fun onRenderLivingB(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { + if (!IslandType.PRIVATE_ISLAND.isInIsland()) return if (!SkyHanniMod.feature.misc.teleportPad.compactName) return val entity = event.entity if (entity !is EntityArmorStand) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt index ad9f6e10e..be8595caa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderMobColoredEvent import at.hannibal2.skyhanni.events.ResetEntityHurtEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager @@ -18,7 +19,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityBlaze -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -102,7 +102,7 @@ class AshfangBlazes { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!isEnabled()) return if (!config.hide.fullNames) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt index 157c260fa..203557278 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt @@ -2,18 +2,18 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AshfangHideDamageIndicator { @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!isEnabled()) return if (DamageIndicatorManager.isDamageSplash(event.entity)) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt index 74505b19e..eab95363b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt @@ -1,11 +1,11 @@ package at.hannibal2.skyhanni.features.slayer import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern @@ -46,7 +46,7 @@ class HideMobNames { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.slayer.hideMobNames) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index 38022adf7..474afc6cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper @@ -40,7 +41,6 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.EnumParticleTypes -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds @@ -259,7 +259,7 @@ object VampireSlayerFeatures { } @SubscribeEvent - fun pre(event: RenderLivingEvent.Pre<EntityOtherPlayerMP>) { + fun pre(event: SkyHanniRenderEntityEvent.Pre<EntityOtherPlayerMP>) { if (!isEnabled()) return if (!config.seeThrough) return if (entityList.contains(event.entity) && event.entity.canBeSeen()) { @@ -268,7 +268,7 @@ object VampireSlayerFeatures { } @SubscribeEvent - fun pre(event: RenderLivingEvent.Post<EntityOtherPlayerMP>) { + fun post(event: SkyHanniRenderEntityEvent.Post<EntityOtherPlayerMP>) { if (!isEnabled()) return if (!config.seeThrough) return if (entityList.contains(event.entity) && event.entity.canBeSeen()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index dc971cd5b..93a79c4ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderMobColoredEvent import at.hannibal2.skyhanni.events.ResetEntityHurtEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils @@ -23,7 +24,6 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.EntityLiving import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -170,7 +170,7 @@ class SummoningMobManager { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) { if (!LorenzUtils.inSkyBlock) return if (!config.summoningMobHideNametag) return diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 137dc2f01..c6b734a78 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent @@ -47,9 +48,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import kotlinx.coroutines.launch import net.minecraft.client.Minecraft -import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.nbt.NBTTagCompound -import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.io.File @@ -412,10 +411,9 @@ class SkyHanniDebugsAndTests { } @SubscribeEvent - fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { + fun onKeybind(event: GuiKeyPressEvent) { if (!debugConfig.copyInternalName.isKeyHeld()) return - val gui = event.gui as? GuiContainer ?: return - val focussedSlot = gui.slotUnderMouse ?: return + val focussedSlot = event.guiContainer.slotUnderMouse ?: return val stack = focussedSlot.stack ?: return val internalName = stack.getInternalNameOrNull() ?: return val rawInternalName = internalName.asString() diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt index 304d4646f..44a147c07 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.test.command.CopyItemCommand.copyItemToClipboard import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemStackTypeAdapterFactory @@ -13,10 +14,8 @@ import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.fromJson import com.google.gson.GsonBuilder import com.google.gson.JsonElement -import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound -import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.io.InputStreamReader import java.io.Reader @@ -52,10 +51,9 @@ object TestExportTools { } @SubscribeEvent - fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { + fun onKeybind(event: GuiKeyPressEvent) { if (!config.copyItemDataCompressed.isKeyHeld() && !config.copyItemData.isKeyHeld()) return - val gui = event.gui as? GuiContainer ?: return - val stack = gui.slotUnderMouse?.stack ?: return + val stack = event.guiContainer.slotUnderMouse?.stack ?: return if (config.copyItemData.isKeyHeld()) { copyItemToClipboard(stack) return diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index 12a2129bf..108f42835 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo @@ -14,6 +15,8 @@ import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.potion.Potion import net.minecraft.util.AxisAlignedBB +import net.minecraftforge.client.event.RenderLivingEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object EntityUtils { @@ -157,4 +160,29 @@ object EntityUtils { fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().add(y = 0.5).canBeSeen(radius) fun getEntityByID(entityId: Int) = Minecraft.getMinecraft()?.thePlayer?.entityWorld?.getEntityByID(entityId) + + @SubscribeEvent + fun onEntityRender(event: RenderLivingEvent<*>) { + SkyHanniRenderEntityEvent(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch() + } + + @SubscribeEvent + fun onEntityRenderPre(event: RenderLivingEvent.Pre<*>) { + SkyHanniRenderEntityEvent.Pre(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch() + } + + @SubscribeEvent + fun onEntityRenderPost(event: RenderLivingEvent.Post<*>) { + SkyHanniRenderEntityEvent.Post(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch() + } + + @SubscribeEvent + fun onEntityRenderSpecialsPre(event: RenderLivingEvent.Specials.Pre<*>) { + SkyHanniRenderEntityEvent.Specials.Pre(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch() + } + + @SubscribeEvent + fun onEntityRenderSpecialsPost(event: RenderLivingEvent.Specials.Post<*>) { + SkyHanniRenderEntityEvent.Specials.Post(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch() + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt index 558a9b810..6dbd123b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.test.command.ErrorManager @@ -7,7 +8,9 @@ import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.moulconfig.internal.KeybindHelper import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiChat +import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.client.settings.KeyBinding +import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.apache.commons.lang3.SystemUtils import org.lwjgl.input.Keyboard @@ -35,6 +38,12 @@ object KeyboardManager { fun getModifierKeyName(): String = if (SystemUtils.IS_OS_MAC) "Command" else "Control" @SubscribeEvent + fun onGuiScreenKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { + val guiScreen = event.gui as? GuiContainer ?: return + GuiKeyPressEvent(guiScreen).postAndCatch() + } + + @SubscribeEvent fun onTick(event: LorenzTickEvent) { val currentScreen = Minecraft.getMinecraft().currentScreen val isConfigScreen = currentScreen is GuiScreenElementWrapper |