Remove attack target as soon as mind control wears off, fixes mind controlled entities continuing to attack a target that dies after the mind control wears off
This commit is contained in:
@@ -24,6 +24,7 @@ import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.PotionEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@@ -214,4 +215,12 @@ public class MindControl extends SpellRay {
|
||||
processTargeting(event.getEntity().world, (EntityLiving)event.getEntityLiving(), event.getTarget());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPotionExpiryEvent(PotionEvent.PotionExpiryEvent event){
|
||||
if(event.getPotionEffect() != null && event.getPotionEffect().getPotion() == WizardryPotions.mind_control
|
||||
&& event.getEntity() instanceof EntityLiving){
|
||||
((EntityLiving)event.getEntity()).setAttackTarget(null); // End effect
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user