summaryrefslogtreecommitdiff
path: root/src/api/java/ic2/api/item/ICustomDamageItem.java
blob: 4470fa0db2f348095cdaf590c722d36d41a9119a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ic2.api.item;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;

/**
 * ICustomDamageItem allows items to have custom damage handling without the massive overhead of
 * Item.getDamage() / Item.setDamage(), which turn ItemStack.getItemDamage into virtual calls.
 *
 * The custom damage value is typically stored in the item stacks nbt data.
 *
 * If an Item implements ICusomDamageItem, the normal ItemStack damage won't be changed by IC2.
 * It's up to the implementer to potentially manipulate it for suitable visual effect on the
 * rendered damage bar or to provide a suitable item renderer.
 *
 * Item.isDamageable() still applies.
 *
 * @author Player
 */
public interface ICustomDamageItem {
	/**
	 * Retrieve the custom damage value for the supplied item stack.
	 *
	 * @param stack ItemStack to be queried.
	 * @return Custom damage value.
	 */
	int getCustomDamage(ItemStack stack);

	/**
	 * Retrieve the maximum custom damage value for the supplied item stack.
	 * @param stack ItemStack to be queried.
	 * @return Custom damage value limit.
	 */
	int getMaxCustomDamage(ItemStack stack);

	/**
	 * Set the custom damage value for the supplied item stack.
	 *
	 * @param stack ItemStack to be manipulated.
	 * @param damage New damage value.
	 */
	void setCustomDamage(ItemStack stack, int damage);

	/**
	 * Increase the custom damage value for the supplied item stack.
	 *
	 * It's up to the implementation to not apply any damage, e.g. based on some randomness or
	 * properties of src.
	 *
	 * @param stack ItemStack to be manipulated.
	 * @param damage Extra damage to be applied.
	 * @param src Entity damaging the item, may be null.
	 * @return true if damage was applied.
	 */
	boolean applyCustomDamage(ItemStack stack, int damage, EntityLivingBase src);
}