Jump to content

Recommended Posts

Posted

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 ??

 

 

Posted

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

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.