From a4845abc45dfd3d96ec4e3a748aa75f422085e63 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 10 Feb 2012 11:58:58 -0800 Subject: [PATCH] Possible fix for negative XP bug. --- src/main/java/com/gmail/nossr50/Combat.java | 31 +++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index 4e5388c92..1083be8c0 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -83,8 +83,6 @@ public class Combat Unarmed.disarmProcCheck(attacker, defender); } - - //Modify the event damage if Attacker is Berserk if(PPa.getBerserkMode()) event.setDamage(event.getDamage() + (event.getDamage() / 2)); @@ -110,12 +108,22 @@ public class Combat int hpLeft = defender.getHealth(), xpinc = 0; if(hpLeft < event.getDamage()) - xpinc = hpLeft; - else + { + if(hpLeft > 0) + xpinc = hpLeft; + else + xpinc = 0; + } else xpinc = event.getDamage(); int xp = (int) (xpinc * 2 * LoadProperties.pvpxprewardmodifier); + if(xp < 0) + { + //Debug messages here + xp = Math.abs(xp); //Temporary fix + } + if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)) PPa.addXP(SkillType.AXES, xp*10, attacker); if(m.isSwords(attacker.getItemInHand()) && mcPermissions.getInstance().swords(attacker)) @@ -411,12 +419,17 @@ public class Combat { LivingEntity le = (LivingEntity)entity; //Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the entity - int hpLeft = le.getHealth(), xpinc = 0; + int hpLeft = le.getHealth(), xpinc = 0; - if(hpLeft < event.getDamage()) - xpinc = hpLeft; - else - xpinc = event.getDamage(); + if(hpLeft < event.getDamage()) + { + if(hpLeft > 0) + xpinc = hpLeft; + else + xpinc = 0; + } + else + xpinc = event.getDamage(); if(entity instanceof Animals) {