Advertisement
Guest User

Untitled

a guest
Oct 29th, 2017
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. package lolmod.entitys.ai;
  2.  
  3. import lolmod.entitys.EntityNeutral;
  4. import net.minecraft.entity.EntityLivingBase;
  5. import net.minecraft.entity.ai.EntityAITarget;
  6. import net.minecraft.entity.player.EntityPlayer;
  7.  
  8. public class EntityAINeutralHurtByTarget extends EntityAITarget {
  9.  
  10.     public EntityAINeutralHurtByTarget(EntityNeutral theDefendingTameableIn) {
  11.         super(theDefendingTameableIn, false);
  12.         this.setMutexBits(1);
  13.     }
  14.  
  15.     /**
  16.      * Returns whether the EntityAIBase should begin execution.
  17.      */
  18.     @Override
  19.     public boolean shouldExecute() {
  20.         System.out.println(this.taskOwner.getRevengeTarget());
  21.         if(this.taskOwner.getDistance(this.taskOwner.getHomePosition().getX(), this.taskOwner.getHomePosition().getY(), this.taskOwner.getHomePosition().getZ())>5)
  22.             return false;
  23.         if(((EntityNeutral) this.taskOwner).getPatienceBar()<=0)
  24.             return false;
  25.         if(this.taskOwner.getRevengeTarget()==null)
  26.             return false;
  27.         return true;
  28.     }
  29.  
  30.     @Override
  31.     public boolean shouldContinueExecuting() {
  32.         System.out.println(super.shouldContinueExecuting());
  33.         System.out.println(this.shouldExecute());
  34.         return super.shouldContinueExecuting() && this.shouldExecute();
  35.     }
  36.  
  37.     @Override
  38.     protected boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) {
  39.         return target instanceof EntityPlayer && this.taskOwner.getDistance(target.posX, target.posY, target.posZ)<15;
  40.     }
  41.  
  42.     @Override
  43.     public void updateTask() {
  44.         if(this.taskOwner.getDistance(this.taskOwner.getHomePosition().getX(), this.taskOwner.getHomePosition().getY(), this.taskOwner.getHomePosition().getZ())>5) {
  45.             this.taskOwner.setAttackTarget(null);
  46.             ((EntityNeutral) this.taskOwner).setPatienceBar(((EntityNeutral) this.taskOwner).getPatienceBar()-20);
  47.         }
  48.         if(this.taskOwner.getRevengeTarget()!=this.taskOwner.getAttackTarget()) {
  49.             this.taskOwner.setAttackTarget(this.taskOwner.getRevengeTarget());
  50.             ((EntityNeutral) this.taskOwner).setPatienceBar(((EntityNeutral) this.taskOwner).getPatienceBar()-20);
  51.         }
  52.         if(((EntityNeutral) this.taskOwner).getPatienceBar()<=0 && this.taskOwner.getHealth()>0)
  53.             this.taskOwner.setHealth(this.taskOwner.getMaxHealth());
  54.     }
  55.  
  56.     /**
  57.      * Execute a one shot task or start executing a continuous task
  58.      */
  59.     @Override
  60.     public void startExecuting() {
  61.         System.out.println("setting attack target");
  62.         this.taskOwner.setAttackTarget(this.taskOwner.getRevengeTarget());
  63.         super.startExecuting();
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement