blob: 3ccb2cb0eecec025735c2b03e5dcf2abc34b0af1 (
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
|
package gtPlusPlus.xmod.ic2.item;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import ic2.api.item.ICustomDamageItem;
import ic2.core.util.StackUtil;
public class IC2_ItemGradualInteger
extends IC2_ItemGradual
implements ICustomDamageItem
{
private final int maxDmg;
public IC2_ItemGradualInteger(final String internalName, final int maxdmg)
{
super(internalName);
this.maxDmg = maxdmg;
}
@Override
public int getCustomDamage(final ItemStack stack)
{
final NBTTagCompound nbt = StackUtil.getOrCreateNbtData(stack);
return nbt.getInteger("advDmg");
}
@Override
public int getMaxCustomDamage(final ItemStack stack)
{
return this.maxDmg;
}
@Override
public void setCustomDamage(final ItemStack stack, final int damage)
{
final NBTTagCompound nbt = StackUtil.getOrCreateNbtData(stack);
nbt.setInteger("advDmg", 0);
final int maxStackDamage = stack.getMaxDamage();
if (maxStackDamage > 2) {
//stack.setItemDamage(1 + (int)Util.map(damage, this.maxDmg, maxStackDamage - 2));
}
}
@Override
public boolean applyCustomDamage(final ItemStack stack, final int damage, final EntityLivingBase src)
{
this.setCustomDamage(stack, this.getCustomDamage(stack) + damage);
return true;
}
}
|