Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lolmod.entitys.ai;
- import lolmod.entitys.EntityNeutral;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.ai.EntityAITarget;
- import net.minecraft.entity.player.EntityPlayer;
- public class EntityAINeutralHurtByTarget extends EntityAITarget {
- public EntityAINeutralHurtByTarget(EntityNeutral theDefendingTameableIn) {
- super(theDefendingTameableIn, false);
- this.setMutexBits(1);
- }
- /**
- * Returns whether the EntityAIBase should begin execution.
- */
- @Override
- public boolean shouldExecute() {
- System.out.println(this.taskOwner.getRevengeTarget());
- if(this.taskOwner.getDistance(this.taskOwner.getHomePosition().getX(), this.taskOwner.getHomePosition().getY(), this.taskOwner.getHomePosition().getZ())>5)
- return false;
- if(((EntityNeutral) this.taskOwner).getPatienceBar()<=0)
- return false;
- if(this.taskOwner.getRevengeTarget()==null)
- return false;
- return true;
- }
- @Override
- public boolean shouldContinueExecuting() {
- System.out.println(super.shouldContinueExecuting());
- System.out.println(this.shouldExecute());
- return super.shouldContinueExecuting() && this.shouldExecute();
- }
- @Override
- protected boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) {
- return target instanceof EntityPlayer && this.taskOwner.getDistance(target.posX, target.posY, target.posZ)<15;
- }
- @Override
- public void updateTask() {
- if(this.taskOwner.getDistance(this.taskOwner.getHomePosition().getX(), this.taskOwner.getHomePosition().getY(), this.taskOwner.getHomePosition().getZ())>5) {
- this.taskOwner.setAttackTarget(null);
- ((EntityNeutral) this.taskOwner).setPatienceBar(((EntityNeutral) this.taskOwner).getPatienceBar()-20);
- }
- if(this.taskOwner.getRevengeTarget()!=this.taskOwner.getAttackTarget()) {
- this.taskOwner.setAttackTarget(this.taskOwner.getRevengeTarget());
- ((EntityNeutral) this.taskOwner).setPatienceBar(((EntityNeutral) this.taskOwner).getPatienceBar()-20);
- }
- if(((EntityNeutral) this.taskOwner).getPatienceBar()<=0 && this.taskOwner.getHealth()>0)
- this.taskOwner.setHealth(this.taskOwner.getMaxHealth());
- }
- /**
- * Execute a one shot task or start executing a continuous task
- */
- @Override
- public void startExecuting() {
- System.out.println("setting attack target");
- this.taskOwner.setAttackTarget(this.taskOwner.getRevengeTarget());
- super.startExecuting();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement