Trying to cast to EntityLiving
PaperTriangle opened this issue ยท 2 comments
Check instanceof Entity before trying to cast to EntityLiving.
java.lang.ClassCastException: net.minecraft.entity.projectile.FireballEntity cannot be cast to net.minecraft.entity.LivingEntity
at com.majruszs_difficulty.events.when_damaged.WhenDamagedEvent.onAttack(WhenDamagedEvent.java:33) ~[majruszs_difficulty:1.0] {re:classloading}
at net.minecraftforge.eventbus.ASMEventHandler_395_WhenDamagedEvent_onAttack_LivingHurtEvent.invoke(.dynamic) ~[?:?] {}
at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-3.0.5-service.jar:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:297) ~[eventbus-3.0.5-service.jar:?] {}
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:343) ~[forge:?] {re:classloading,re:mixin}
at net.minecraft.entity.LivingEntity.func_70665_d(LivingEntity.java:1472) ~[?:?]
It looks like Entities that are not an EntityLiving can show up in this event through event.getSource().getTrueSource().
I have also experienced this it seems to be any projectile that is shot from a not Living entity like dispenser to a Living Entity like a player.
Attached are the crash reports from the server.
crash-2021-01-16_02.36.49-server.txt
crash-2021-01-16_02.45.39-server.txt