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:
@@ -108,6 +108,9 @@ public final class AllyDesignationSystem {
|
|||||||
*/
|
*/
|
||||||
public static boolean isValidTarget(Entity attacker, Entity target){
|
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
|
// Always return false if the target is null
|
||||||
if(target == null) return false;
|
if(target == null) return false;
|
||||||
|
|
||||||
@@ -195,6 +198,12 @@ public final class AllyDesignationSystem {
|
|||||||
* generally used to determine targets for healing or other group buffs. */
|
* generally used to determine targets for healing or other group buffs. */
|
||||||
public static boolean isAllied(EntityLivingBase allyOf, EntityLivingBase possibleAlly){
|
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
|
if(allyOf instanceof EntityPlayer && possibleAlly instanceof EntityPlayer
|
||||||
&& isPlayerAlly((EntityPlayer)allyOf, (EntityPlayer)possibleAlly)){
|
&& isPlayerAlly((EntityPlayer)allyOf, (EntityPlayer)possibleAlly)){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user