/
TraitJagged.java
43 lines (31 loc) · 1.34 KB
/
TraitJagged.java
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
package slimeknights.tconstruct.tools.traits;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.TextFormatting;
import java.util.List;
import slimeknights.tconstruct.library.Util;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
public class TraitJagged extends AbstractTrait {
public TraitJagged() {
super("jagged", TextFormatting.AQUA);
}
private double calcBonus(ItemStack tool) {
int durability = ToolHelper.getCurrentDurability(tool);
int maxDurability = ToolHelper.getMaxDurability(tool);
// old tcon jagged formula
return Math.log((maxDurability - durability) / 72d + 1d) * 2;
}
@Override
public float damage(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, float newDamage, boolean isCritical) {
newDamage += calcBonus(tool);
return super.damage(tool, player, target, damage, newDamage, isCritical);
}
@Override
public List<String> getExtraInfo(ItemStack tool, NBTTagCompound modifierTag) {
String loc = String.format(LOC_Extra, getModifierIdentifier());
return ImmutableList.of(Util.translateFormatted(loc, Util.df.format(calcBonus(tool))));
}
}