aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-16 07:46:51 +0100
committerGitHub <noreply@github.com>2024-03-16 07:46:51 +0100
commit27d3c80d806b6eec64efa48bc55143c2e76489f4 (patch)
tree361a3d946ede49ec7f001205b7055465b8bf5569 /src/main/java/at/hannibal2/skyhanni
parent95cb1d7c7be44a6b7f9611e6420ff6b50146a830 (diff)
downloadskyhanni-27d3c80d806b6eec64efa48bc55143c2e76489f4.tar.gz
skyhanni-27d3c80d806b6eec64efa48bc55143c2e76489f4.tar.bz2
skyhanni-27d3c80d806b6eec64efa48bc55143c2e76489f4.zip
Fix: Entity Render Event (#1179)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt30
2 files changed, 28 insertions, 6 deletions
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 6b9e11ec7..5dcef3b70 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
@@ -180,7 +180,9 @@ class SummoningMobManager {
if (!entity.hasCustomName()) return
if (entity.isDead) return
- event.isCanceled = entity in summoningMobNametags
+ if (entity in summoningMobNametags) {
+ event.cancel()
+ }
}
@SubscribeEvent
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
+}