mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Iterate through the durability damage with Unbreaking check
This commit is contained in:
parent
34027ee7c4
commit
3668249267
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,7 +24,6 @@
|
|||||||
/world
|
/world
|
||||||
|
|
||||||
# Mac filesystem dust
|
# Mac filesystem dust
|
||||||
/.DS_Store
|
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
|
|
||||||
# intellij
|
# intellij
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user