Jump to content

How does ArmorProperties work?


Jordor

Recommended Posts

Hello modders!!

 

I was messing around with ISpecialArmor. Armor properties accept 3 parameters: priority, ratio and max.

 

priority is self explanatory.

ratio is also quite easy (it a double). In the code it seems that all 4 pieces share the same ratio, meaning that 0.25 ratio on each piece grants a 100% absorption of damage when all 4 pieces are equipped.

max is an int, and seems to be, again in the code, the maximum amount of damage that can be absorbed by the piece.

 

 

Let's say a Slime (giant) attacks me and deals 2 hearts:

- is that 4 damage points?

- if all 4 pieces absorb 0.25, do they take 1 point (0.5 hearts) each?

 

i've been trying to work with an armor but it does not seem to be absorbing anything.

 

here is the relevant code (skills[2] takes a value of 1 in this case).

 

 

 

@Override

public ArmorProperties getProperties(EntityLivingBase player,

ItemStack armor, DamageSource source, double damage, int slot) {

 

ArmorProperties properties = new ArmorProperties(0, 0, 0);

 

NBTTagCompound compound = armor.getTagCompound();

 

if (compound != null) {

int[] skills = compound.getIntArray("skills");

int Shield = compound.getInteger("Shield");

 

if (armor.getItem() == AncientCraft.CorruptChestplate) {

 

if (Shield > 0) {

properties = new ArmorProperties(0, 1, 200);

if (damage > 0) {

Shield--;

}

} else {

properties = new ArmorProperties(0, 0.25, skills[2]);

}

 

} else {

properties = new ArmorProperties(0, 0.25, skills[2]);

}

 

compound.setInteger("Shield", Shield);

}

 

return properties;

 

}

 

 

 

 

Link to comment
Share on other sites

After walking through the interface, it looks like each piece is assigned an absorption ratio less than one, and if the sum of the pieces adds up to one, then all damage is absorbed. To make sure that some damage leaks through, assign absorption ratios that add to less than one (e.g. 0.2 for each of four standard pieces, adding to 80% absorption with 20% reaching the wearer).

 

You probably don't want your armor to ever add up to more than one, because then the pieces would take excess damage on themselves, reducing entity damage to a negative number, and that neg would be rectified to zero in the calling method (but the excess damage to the armor would remain).

 

I suggest that you lower your shield's absorption ratio significantly.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

After walking through the interface, it looks like each piece is assigned an absorption ratio less than one, and if the sum of the pieces adds up to one, then all damage is absorbed. To make sure that some damage leaks through, assign absorption ratios that add to less than one (e.g. 0.2 for each of four standard pieces, adding to 80% absorption with 20% reaching the wearer).

 

You probably don't want your armor to ever add up to more than one, because then the pieces would take excess damage on themselves, reducing entity damage to a negative number, and that neg would be rectified to zero in the calling method (but the excess damage to the armor would remain).

 

I suggest that you lower your shield's absorption ratio significantly.

 

Thanks for answering.

 

You may have noticed also that the interface provides a method called "damageArmor" that says how to damage the armor instead of vanilla way. That resolves the excess damage you are talking about. Explanation: Shield absorbs ALL damage once every once in a while. Damage armor damages the itemStack only 1 point.

 

Code here

 

 

@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack,
		DamageSource source, int damage, int slot) {
	if (stack != null) {

		NBTTagCompound compound = stack.getTagCompound();

		if (compound != null) {

			int durability = compound.getInteger("structure");

			if (durability > 0) {
				durability--;
			} else {
				stack.damageItem(1, entity);
			}

			compound.setInteger("structure", durability);

		}
	}
}

 

 

The problem is when i place a 0.2 or 0.25, no damage is absorbed and thus, it is dealt to the player, even with the 4 pieces on him (getting attacked by a giant slime).

 

i'm trying to see why this happens right now xD.

Link to comment
Share on other sites

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.