Make owned entities inherit their owner's allies (as well as their own - if, for example, you summon a mob that then summons its own mob, that mob will no longer attack you)

This commit is contained in:
Electroblob77
2020-07-06 23:02:03 +01:00
parent 9aac386ec9
commit a1a5af034d
@@ -108,6 +108,9 @@ public final class AllyDesignationSystem {
*/
public static boolean isValidTarget(Entity attacker, Entity target){
// Owned entities inherit their owner's allies
if(attacker instanceof IEntityOwnable && !isValidTarget(((IEntityOwnable)attacker).getOwner(), target)) return false;
// Always return false if the target is null
if(target == null) return false;
@@ -195,6 +198,12 @@ public final class AllyDesignationSystem {
* generally used to determine targets for healing or other group buffs. */
public static boolean isAllied(EntityLivingBase allyOf, EntityLivingBase possibleAlly){
// Owned entities inherit their owner's allies
if(allyOf instanceof IEntityOwnable){
Entity owner = ((IEntityOwnable)allyOf).getOwner();
if(owner instanceof EntityLivingBase && isAllied((EntityLivingBase)owner, possibleAlly)) return true;
}
if(allyOf instanceof EntityPlayer && possibleAlly instanceof EntityPlayer
&& isPlayerAlly((EntityPlayer)allyOf, (EntityPlayer)possibleAlly)){
return true;