Fixed a bug where Tree Feller only rewarded 1 XP per block

This commit is contained in:
nossr50 2019-08-23 13:08:04 -06:00
parent 40118d570c
commit 77ffee2515
2 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,5 @@
Version 2.1.103 Version 2.1.103
Fixed a bug where Tree Feller was only rewarding 1 XP per log broken no matter the circumstances
Fixed an issue with salvage checking the incorrect level requirement Fixed an issue with salvage checking the incorrect level requirement
Updated Italian locale (thanks Leomixer17) Updated Italian locale (thanks Leomixer17)
Fixed grammar in one of the Salvage strings (thanks QuantumToasted) Fixed grammar in one of the Salvage strings (thanks QuantumToasted)

View File

@ -266,6 +266,7 @@ public class WoodcuttingManager extends SkillManager {
int processedLogCount = 0; int processedLogCount = 0;
for (BlockState blockState : treeFellerBlocks) { for (BlockState blockState : treeFellerBlocks) {
int beforeXP = xp;
Block block = blockState.getBlock(); Block block = blockState.getBlock();
if (!EventUtils.simulateBlockBreak(block, player, true)) { if (!EventUtils.simulateBlockBreak(block, player, true)) {
@ -295,12 +296,21 @@ public class WoodcuttingManager extends SkillManager {
blockState.setType(Material.AIR); blockState.setType(Material.AIR);
blockState.update(true); blockState.update(true);
processedLogCount+=1;
//Update only when XP changes
processedLogCount = updateProcessedLogCount(xp, processedLogCount, beforeXP);
} }
applyXpGain(xp, XPGainReason.PVE); applyXpGain(xp, XPGainReason.PVE);
} }
private int updateProcessedLogCount(int xp, int processedLogCount, int beforeXP) {
if(beforeXP != xp)
processedLogCount+=1;
return processedLogCount;
}
/** /**
* Retrieves the experience reward from logging via Tree Feller * Retrieves the experience reward from logging via Tree Feller
* Experience is reduced per log processed so far * Experience is reduced per log processed so far
@ -318,8 +328,8 @@ public class WoodcuttingManager extends SkillManager {
return 0; return 0;
if(ExperienceConfig.getInstance().isTreeFellerXPReduced()) { if(ExperienceConfig.getInstance().isTreeFellerXPReduced()) {
int reducedXP = 1 + (woodCount * 5); int reducedXP = rawXP - (woodCount * 5);
rawXP = Math.max(1, rawXP - reducedXP); rawXP = Math.max(1, reducedXP);
return rawXP; return rawXP;
} else { } else {
return ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, blockState.getType()); return ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, blockState.getType());