Added ownership to the Sentient Specter and improved its AI. Also enabled it to use a bow.

This commit is contained in:
WayofTime 2016-08-15 17:09:01 -04:00
parent bc37851bd6
commit 38f4ea6bac
7 changed files with 691 additions and 16 deletions

View file

@ -0,0 +1,59 @@
package WayofTime.bloodmagic.entity.ai;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget;
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
public class EntityAIOwnerHurtByTarget extends EntityAITarget
{
EntitySentientSpecter theDefendingTameable;
EntityLivingBase theOwnerAttacker;
private int timestamp;
public EntityAIOwnerHurtByTarget(EntitySentientSpecter theDefendingTameableIn)
{
super(theDefendingTameableIn, false);
this.theDefendingTameable = theDefendingTameableIn;
this.setMutexBits(1);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.theDefendingTameable.isTamed())
{
return false;
} else
{
EntityLivingBase owner = this.theDefendingTameable.getOwner();
if (owner == null)
{
return false;
} else
{
this.theOwnerAttacker = owner.getAITarget();
int i = owner.getRevengeTimer();
return i != this.timestamp && this.isSuitableTarget(this.theOwnerAttacker, false) && this.theDefendingTameable.shouldAttackEntity(this.theOwnerAttacker, owner);
}
}
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
this.taskOwner.setAttackTarget(this.theOwnerAttacker);
EntityLivingBase owner = this.theDefendingTameable.getOwner();
if (owner != null)
{
this.timestamp = owner.getRevengeTimer();
}
super.startExecuting();
}
}