Posted May 7, 201411 yr So I have a mob, and in it I have the attackEntityFrom method, but it isn't being called. Is there a place I need to reference it? Mob class- public class EntityDemon extends EntityMob{ public EntityDemon(World par1World) { super(par1World); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(), false)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true)); this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue())); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.setSize(1.2F, 2.5F); // TODO Auto-generated constructor stub } protected String getLivingSound(){ return "eternisles:EntityDemonLiving"; } protected String getDeathSound(){ return "eternisles:EntityDemonDeath"; } protected String getHurtSound(){ return "eternisles:EntityDemonHurt"; } protected Entity findPlayerToAttack(){ EntityPlayer entityPlayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D); return entityPlayer != null && this.canEntityBeSeen(entityPlayer) ? entityPlayer : null; } public void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(30.0D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(52.0D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.9D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.55D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); } @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, new Integer(100)); } @Override protected boolean isAIEnabled() { return true; } public boolean attackEntityFrom(DamageSource par1DamageSource, int par2){ Entity entity; entity = par1DamageSource.getSourceOfDamage(); if (par1DamageSource.isProjectile() || entity instanceof EntityArrow || entity instanceof EntityThrowable){ return false; } return super.attackEntityFrom(par1DamageSource, par2); }
May 7, 201411 yr ALWAYS add @Override to methods you intend to override, you would see the signature of the method is wrong the int parameter is now a float Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
May 7, 201411 yr Author ALWAYS add @Override to methods you intend to override, you would see the signature of the method is wrong the int parameter is now a float Silly me, thank you.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.