Permalink
Browse files

Iterate through the durability damage with Unbreaking check

  • Loading branch information...
1 parent 34027ee commit 366824926706d035c7520ac35eb87f28a03d2063 @TfT-02 TfT-02 committed Dec 30, 2012
View
1 .gitignore
@@ -24,7 +24,6 @@
/world
# Mac filesystem dust
-/.DS_Store
*.DS_Store
# intellij
View
24 src/main/java/com/gmail/nossr50/skills/combat/Axes.java
@@ -40,7 +40,7 @@ public static void axesBonus(Player attacker, EntityDamageByEntityEvent event) {
final int MAX_LEVEL = advancedConfig.getBonusDamageAxesMaxBonusLevel();
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);
if (bonus > MAX_BONUS) {
@@ -129,27 +129,31 @@ public static void impact(Player attacker, LivingEntity target, EntityDamageByEn
Player targetPlayer = (Player) target;
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();
float impactMaxDamage = (float) advancedConfig.getArmorImpactMaxDurabilityDamage() / 100F;
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)) {
applyGreaterImpact(attacker, target, event);
}
else {
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
if(Math.random() * 100 > 75) {
- if (armor.containsEnchantment(Enchantment.DURABILITY)) {
- int level = armor.getEnchantmentLevel(Enchantment.DURABILITY);
- if (random.nextInt(level + 1) > 0) {
- return;
- }
+ for (int i = 0; i <= durabilityDamage; i ++) {
+ if (armor.containsEnchantment(Enchantment.DURABILITY)) {
+ int level = armor.getEnchantmentLevel(Enchantment.DURABILITY);
+ if (random.nextInt(level + 1) > 0) {
+ lowerdamage++;
+ }
+ }
}
+ int newDurabilityDamage = durabilityDamage - lowerdamage;
maxDurability = (short) (armor.getType().getMaxDurability() * impactMaxDamage);
- if (durabilityDamage > maxDurability) durabilityDamage = (short) maxDurability;
- armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
+ if (newDurabilityDamage > maxDurability) newDurabilityDamage = (short) maxDurability;
+ armor.setDurability((short) (armor.getDurability() + newDurabilityDamage)); //Damage armor piece
}
}
targetPlayer.updateInventory();
View
3 src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java
@@ -504,9 +504,8 @@ public static void leafBlower(Player player, Block block) {
private static int durabilityLossCalulate(ArrayList<Block> toBeFelled, int level) {
int durabilityLoss = 0;
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))) {
- durabilityLoss++;
durabilityLoss = durabilityLoss + Config.getInstance().getAbilityToolDamage();
}
}

0 comments on commit 3668249

Please sign in to comment.