aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index 108f42835..3a86c8b54 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -16,6 +16,7 @@ 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.Event
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object EntityUtils {
@@ -163,26 +164,45 @@ object EntityUtils {
@SubscribeEvent
fun onEntityRender(event: RenderLivingEvent<*>) {
- SkyHanniRenderEntityEvent(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
+ val shEvent = SkyHanniRenderEntityEvent(event.entity, event.renderer, event.x, event.y, event.z)
+ if (shEvent.postAndCatch()) {
+ event.cancel()
+ }
}
@SubscribeEvent
fun onEntityRenderPre(event: RenderLivingEvent.Pre<*>) {
- SkyHanniRenderEntityEvent.Pre(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
+ val shEvent = SkyHanniRenderEntityEvent.Pre(event.entity, event.renderer, event.x, event.y, event.z)
+ if (shEvent.postAndCatch()) {
+ event.cancel()
+ }
}
@SubscribeEvent
fun onEntityRenderPost(event: RenderLivingEvent.Post<*>) {
- SkyHanniRenderEntityEvent.Post(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
+ val shEvent = SkyHanniRenderEntityEvent.Post(event.entity, event.renderer, event.x, event.y, event.z)
+ if (shEvent.postAndCatch()) {
+ event.cancel()
+ }
}
@SubscribeEvent
fun onEntityRenderSpecialsPre(event: RenderLivingEvent.Specials.Pre<*>) {
- SkyHanniRenderEntityEvent.Specials.Pre(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
+ val shEvent = SkyHanniRenderEntityEvent.Specials.Pre(event.entity, event.renderer, event.x, event.y, event.z)
+ if (shEvent.postAndCatch()) {
+ event.cancel()
+ }
}
@SubscribeEvent
fun onEntityRenderSpecialsPost(event: RenderLivingEvent.Specials.Post<*>) {
- SkyHanniRenderEntityEvent.Specials.Post(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
+ val shEvent = SkyHanniRenderEntityEvent.Specials.Post(event.entity, event.renderer, event.x, event.y, event.z)
+ if (shEvent.postAndCatch()) {
+ event.cancel()
+ }
}
}
+
+private fun Event.cancel() {
+ isCanceled = true
+}