aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java
blob: 9ffc80349488ecf752b964e5a8262480499d58a3 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package gtPlusPlus.xmod.gregtech.api.energy;

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

/**
 * This interface specifies a manager to handle the various tasks for electric
 * items.
 *
 * The default implementation does the following: - store and retrieve the
 * charge - handle charging, taking amount, tier, transfer limit,
 * canProvideEnergy and simulate into account - replace item IDs if appropriate
 * (getChargedItemId() and getEmptyItemId()) - update and manage the damage
 * value for the visual charge indicator
 *
 * @note If you're implementing your own variant (ISpecialElectricItem), you can
 *       delegate to the default implementations through
 *       ElectricItem.rawManager. The default implementation is designed to
 *       minimize its dependency on its own constraints/structure and delegates
 *       most work back to the more atomic features in the gateway manager.
 */
public interface IC2ElectricItemManager {
	/**
	 * Determine if the specified electric item has at least a specific amount
	 * of EU. This is supposed to be used in the item code during operation, for
	 * example if you want to implement your own electric item. BatPacks are not
	 * taken into account.
	 *
	 * @param itemStack
	 *            electric item's stack
	 * @param amount
	 *            minimum amount of energy required
	 * @return true if there's enough energy
	 */
	boolean canUse(ItemStack stack, double amount);

	/**
	 * Charge an item with a specified amount of energy.
	 *
	 * @param itemStack
	 *            electric item's stack
	 * @param amount
	 *            amount of energy to charge in EU
	 * @param tier
	 *            tier of the charging device, has to be at least as high as the
	 *            item to charge
	 * @param ignoreTransferLimit
	 *            ignore the transfer limit specified by getTransferLimit()
	 * @param simulate
	 *            don't actually change the item, just determine the return
	 *            value
	 * @return Energy transferred into the electric item
	 */
	double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate);

	/**
	 * Charge an item from the BatPack a player is wearing. This is supposed to
	 * be used in the item code during operation, for example if you want to
	 * implement your own electric item. use() already contains this
	 * functionality.
	 *
	 * @param itemStack
	 *            electric item's stack
	 * @param entity
	 *            entity holding the item
	 */
	void chargeFromArmor(ItemStack stack, EntityLivingBase entity);

	/**
	 * Discharge an item by a specified amount of energy
	 *
	 * @param itemStack
	 *            electric item's stack
	 * @param amount
	 *            amount of energy to discharge in EU
	 * @param tier
	 *            tier of the discharging device, has to be at least as high as
	 *            the item to discharge
	 * @param ignoreTransferLimit
	 *            ignore the transfer limit specified by getTransferLimit()
	 * @param externally
	 *            use the supplied item externally, i.e. to power something else
	 *            as if it was a battery
	 * @param simulate
	 *            don't actually discharge the item, just determine the return
	 *            value
	 * @return Energy retrieved from the electric item
	 */
	double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally,
			boolean simulate);

	/**
	 * Determine the charge level for the specified item.
	 *
	 * @param itemStack
	 *            ItemStack containing the electric item
	 * @return charge level in EU
	 */
	double getCharge(ItemStack stack);

	/**
	 * Get the tool tip to display for electric items.
	 *
	 * @param itemStack
	 *            ItemStack to determine the tooltip for
	 * @return tool tip string or null for none
	 */
	String getToolTip(ItemStack stack);

	/**
	 * Try to retrieve a specific amount of energy from an Item, and if
	 * applicable, a BatPack. This is supposed to be used in the item code
	 * during operation, for example if you want to implement your own electric
	 * item.
	 *
	 * @param itemStack
	 *            electric item's stack
	 * @param amount
	 *            amount of energy to discharge in EU
	 * @param entity
	 *            entity holding the item
	 * @return true if the operation succeeded
	 */
	boolean use(ItemStack stack, double amount, EntityLivingBase entity);

	// TODO: add tier getter
}