Guest User

Untitled

a guest
Jun 19th, 2014
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. public class EntitySentryGun extends EntityGolem implements IRangedAttackMob {
  2.     public EntitySentryGun(World par1) {
  3.         super(par1);
  4.             this.setSize(0.4F, 1.8F);
  5.         this.isImmuneToFire = true;    
  6.             this.tasks.addTask(1, new EntityAIArrowAttack(this, 0.25F, 10, 60));
  7.             this.tasks.addTask(2, new EntityAIWander(this, 0.0F));
  8.             this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityMob.class, 6F));
  9.             this.tasks.addTask(4, new EntityAILookIdle(this));
  10.         this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true, false, IMob.mobSelector));     
  11.     }
  12.    
  13.     @Override
  14.     protected void applyEntityAttributes()
  15.     {
  16.         super.applyEntityAttributes();
  17.         this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0F);
  18.         this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0D);
  19.         this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D); // no knockback
  20.     }
  21.  
  22.    
  23.     public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) {
  24.         EntityArrow entityarrow = new EntityArrow(this.worldObj, this, par1EntityLivingBase, 1.6F, (float) (14 -    this.worldObj.difficultySetting.getDifficultyId() * 4));
  25.         entityarrow.setDamage(4.0D);
  26.         this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
  27.         this.worldObj.spawnEntityInWorld(entityarrow);
  28.     }
  29.  
  30.    
  31.     @Override
  32.     public boolean getCanSpawnHere()
  33.     {
  34.         return true;
  35.     }
  36.    
  37.     @Override
  38.     public boolean isWet()
  39.     {
  40.         return false;
  41.     }
  42.    
  43.     @Override
  44.     public boolean isPushedByWater ()
  45.     {
  46.         return false;
  47.     }
  48.        
  49.    
  50.     @Override
  51.     public boolean canBePushed() {
  52.         return false;
  53.     }
  54.    
  55.     public boolean isAIEnabled()
  56.     {
  57.         return true;
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment