Posted January 23, 20169 yr nigths i have a custom villager and this one can atack but like it is a vainilla villager extended it has no attackDamage value in their atributes this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D); so i have to set the damage manually to 2.0F in mi own atackAsMob method the trouble whith ths method is, i dont know hot to get the damge cause by tool/weapon held by the custom villager soo a esmeral sword do same damage than bare hands, make swict whith values asigne by mi dont sounds like a good idea // ################################################################################################################# // se ejecuta cuando hace ataque fisico normal auna criatura @Override public boolean attackEntityAsMob(Entity targetP_) { float attackDamage = 2.0F; boolean flag = targetP_.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage); if (flag) { this.func_174815_a(this, targetP_); } this.swingItem(); return false;// flag; } this seams not to be what i need MercenaryModItems.espada_acero_acero.getDamage(stack); ###?? how dou you get the damage a weapons deal when atack a mob ??
January 23, 20169 yr Author i have something public boolean attackAsMob(Entity targetP_) { ItemStack weapon = this.getHeldItem(); float swordDamageDeal = 0.0F; if (weapon != null){ if (weapon.getItem() instanceof ItemSword) { ItemSword espada = (ItemSword) weapon.getItem() ; swordDamageDeal = espada.getDamageVsEntity(); } } boolean flag = targetP_.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage + swordDamageDeal); if (flag) { this.func_174815_a(this, targetP_); } this.swingItem(); return flag;// ; } this gets the damage caused but oinly if sword i dont get how to get it for axes pickaxes spades and hoes or the stick
January 24, 20169 yr If you extend EntityLivingBase, your entity's attack damage attribute should already include any modifiers from the held item. Just use what mobs use: float damage = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); If you want to make sure, print out the damage to the console and try it with and without various items equipped. http://i.imgur.com/NdrFdld.png[/img]
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.