aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt9
2 files changed, 37 insertions, 0 deletions
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