Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EntitySentryGun extends EntityGolem implements IRangedAttackMob {
- public EntitySentryGun(World par1) {
- super(par1);
- this.setSize(0.4F, 1.8F);
- this.isImmuneToFire = true;
- this.tasks.addTask(1, new EntityAIArrowAttack(this, 0.25F, 10, 60));
- this.tasks.addTask(2, new EntityAIWander(this, 0.0F));
- this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityMob.class, 6F));
- this.tasks.addTask(4, new EntityAILookIdle(this));
- this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true, false, IMob.mobSelector));
- }
- @Override
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0F);
- this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0D);
- this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D); // no knockback
- }
- public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) {
- EntityArrow entityarrow = new EntityArrow(this.worldObj, this, par1EntityLivingBase, 1.6F, (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4));
- entityarrow.setDamage(4.0D);
- this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
- this.worldObj.spawnEntityInWorld(entityarrow);
- }
- @Override
- public boolean getCanSpawnHere()
- {
- return true;
- }
- @Override
- public boolean isWet()
- {
- return false;
- }
- @Override
- public boolean isPushedByWater ()
- {
- return false;
- }
- @Override
- public boolean canBePushed() {
- return false;
- }
- public boolean isAIEnabled()
- {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment