Iterate through the durability damage with Unbreaking check

This commit is contained in:
TfT_02 2012-12-30 23:46:21 +01:00
parent 34027ee7c4
commit 3668249267
3 changed files with 15 additions and 13 deletions

1
.gitignore vendored
View File

@ -24,7 +24,6 @@
/world /world
# Mac filesystem dust # Mac filesystem dust
/.DS_Store
*.DS_Store *.DS_Store
# intellij # intellij

View File

@ -40,7 +40,7 @@ public class Axes {
final int MAX_LEVEL = advancedConfig.getBonusDamageAxesMaxBonusLevel(); final int MAX_LEVEL = advancedConfig.getBonusDamageAxesMaxBonusLevel();
final int INCREASE_LEVEL = MAX_LEVEL / MAX_BONUS; final int INCREASE_LEVEL = MAX_LEVEL / MAX_BONUS;
/* Add 1 DMG for every 50 skill levels */ /* Add 1 DMG for every 50 skill levels (default value) */
int bonus = (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) INCREASE_LEVEL); int bonus = (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) INCREASE_LEVEL);
if (bonus > MAX_BONUS) { if (bonus > MAX_BONUS) {
@ -129,11 +129,12 @@ public class Axes {
Player targetPlayer = (Player) target; Player targetPlayer = (Player) target;
short durabilityDamage = 1; //Start with 1 durability damage short durabilityDamage = 1; //Start with 1 durability damage
/* Every 30 Skill Levels you gain 1 durability damage */ /* Every 50 Skill Levels you gain 1 durability damage (default values) */
int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel(); int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
float impactMaxDamage = (float) advancedConfig.getArmorImpactMaxDurabilityDamage() / 100F; float impactMaxDamage = (float) advancedConfig.getArmorImpactMaxDurabilityDamage() / 100F;
short maxDurability; short maxDurability;
durabilityDamage += (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel); int lowerdamage = 0;
durabilityDamage += (int) (((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel));
if (!hasArmor(targetPlayer)) { if (!hasArmor(targetPlayer)) {
applyGreaterImpact(attacker, target, event); applyGreaterImpact(attacker, target, event);
@ -141,15 +142,18 @@ public class Axes {
else { else {
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) { for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
if(Math.random() * 100 > 75) { if(Math.random() * 100 > 75) {
if (armor.containsEnchantment(Enchantment.DURABILITY)) { for (int i = 0; i <= durabilityDamage; i ++) {
int level = armor.getEnchantmentLevel(Enchantment.DURABILITY); if (armor.containsEnchantment(Enchantment.DURABILITY)) {
if (random.nextInt(level + 1) > 0) { int level = armor.getEnchantmentLevel(Enchantment.DURABILITY);
return; if (random.nextInt(level + 1) > 0) {
} lowerdamage++;
}
}
} }
int newDurabilityDamage = durabilityDamage - lowerdamage;
maxDurability = (short) (armor.getType().getMaxDurability() * impactMaxDamage); maxDurability = (short) (armor.getType().getMaxDurability() * impactMaxDamage);
if (durabilityDamage > maxDurability) durabilityDamage = (short) maxDurability; if (newDurabilityDamage > maxDurability) newDurabilityDamage = (short) maxDurability;
armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece armor.setDurability((short) (armor.getDurability() + newDurabilityDamage)); //Damage armor piece
} }
} }
targetPlayer.updateInventory(); targetPlayer.updateInventory();

View File

@ -504,9 +504,8 @@ public class WoodCutting {
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled, int level) { private static int durabilityLossCalulate(ArrayList<Block> toBeFelled, int level) {
int durabilityLoss = 0; int durabilityLoss = 0;
for (Block x : toBeFelled) { for (Block x : toBeFelled) {
if (random.nextInt(level + 1) > 0) {}//Don't add durabilityLoss, because Unbreaking enchantment does it work. if (random.nextInt(level + 1) > 0) {}//Don't add durabilityLoss, because Unbreaking enchantment does it's work.
else if (x.getType().equals(Material.LOG) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(x))) { else if (x.getType().equals(Material.LOG) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(x))) {
durabilityLoss++;
durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage(); durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
} }
} }