From d4c9242b14fb5da686eeaa22cae5226ee1e6343e Mon Sep 17 00:00:00 2001 From: Electroblob <35599699+Electroblob77@users.noreply.github.com> Date: Fri, 23 Feb 2018 12:39:44 +0000 Subject: [PATCH] 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 --- .../java/electroblob/wizardry/spell/MindControl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/electroblob/wizardry/spell/MindControl.java b/src/main/java/electroblob/wizardry/spell/MindControl.java index 75bd8139..188daf82 100644 --- a/src/main/java/electroblob/wizardry/spell/MindControl.java +++ b/src/main/java/electroblob/wizardry/spell/MindControl.java @@ -193,11 +193,14 @@ public class MindControl extends Spell { public static void onLivingUpdateEvent(LivingUpdateEvent event){ // 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. - if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) - && event.getEntityLiving() instanceof EntityLiving + if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) && 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().isEntityAlive()) - ((EntityLiving)event.getEntityLiving()).setAttackTarget(null); // Causes the event to be fired + && !((EntityLiving)event.getEntityLiving()).getAttackTarget().isEntityAlive()){ + // 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