Fix mind-controlled entities not attacking any more after their initial target is killed

This problem arose as a result of the previous bugfix a4695bc
This commit is contained in:
Electroblob
2018-02-23 12:39:44 +00:00
parent db9812eac9
commit d4c9242b14
@@ -193,11 +193,14 @@ public class MindControl extends Spell {
public static void onLivingUpdateEvent(LivingUpdateEvent event){ public static void onLivingUpdateEvent(LivingUpdateEvent event){
// This was added because something got changed in the AI classes which means LivingSetAttackTargetEvent doesn't // This was added because something got changed in the AI classes which means LivingSetAttackTargetEvent doesn't
// get fired when I want it to... so I'm firing it myself. // get fired when I want it to... so I'm firing it myself.
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) && event.getEntityLiving() instanceof EntityLiving
&& event.getEntityLiving() instanceof EntityLiving // Detects when the mind controlled entity has just killed its previous target
&& ((EntityLiving)event.getEntityLiving()).getAttackTarget() != null && ((EntityLiving)event.getEntityLiving()).getAttackTarget() != null
&& !((EntityLiving)event.getEntityLiving()).getAttackTarget().isEntityAlive()) && !((EntityLiving)event.getEntityLiving()).getAttackTarget().isEntityAlive()){
((EntityLiving)event.getEntityLiving()).setAttackTarget(null); // Causes the event to be fired // Causes the event to be fired (I know it makes no sense to target itself, but that bypasses the null
// check that was added at the start of the method below, and the target is instantly reassigned anyway)
((EntityLiving)event.getEntityLiving()).setAttackTarget(event.getEntityLiving());
}
} }
@SubscribeEvent @SubscribeEvent