Skip to content

Commit

Permalink
fix thrown tridents not getting XP or subskill benefits
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed Mar 31, 2024
1 parent 86a5d14 commit cf49fc7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
@@ -1,3 +1,6 @@
Version 2.2.002
Fixed bug where thrown tridents did not grant XP or benefit from subskills

Version 2.2.001
Fixed Crossbow's Powered shot showing the text for the wrong skill from the locale when using /crossbows command

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.2.001</version>
<version>2.2.002-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>
Expand Down
49 changes: 45 additions & 4 deletions src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
Expand Up @@ -111,7 +111,7 @@ private static void printFinalDamageDebug(@NotNull Player player, @NotNull Entit
}
}
}
private static void processTridentCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
private static void processTridentCombatMelee(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) {
return;
}
Expand All @@ -127,10 +127,40 @@ private static void processTridentCombat(@NotNull LivingEntity target, @NotNull

TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();

if (tridentsManager.canActivateAbility()) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.TRIDENTS);
// if (tridentsManager.canActivateAbility()) {
// mcMMOPlayer.checkAbilityActivation(PrimarySkillType.TRIDENTS);
// }

if (SkillUtils.canUseSubskill(player, SubSkillType.TRIDENTS_IMPALE)) {
boostedDamage += (tridentsManager.impaleDamageBonus() * mcMMOPlayer.getAttackStrength());
}

if(canUseLimitBreak(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
}

event.setDamage(boostedDamage);
processCombatXP(mcMMOPlayer, target, PrimarySkillType.TRIDENTS);

printFinalDamageDebug(player, event, mcMMOPlayer);
}

private static void processTridentCombatRanged(@NotNull Trident trident, @NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) {
return;
}

double boostedDamage = event.getDamage();

McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);

//Make sure the profiles been loaded
if(mcMMOPlayer == null) {
return;
}

TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();

if (SkillUtils.canUseSubskill(player, SubSkillType.TRIDENTS_IMPALE)) {
boostedDamage += (tridentsManager.impaleDamageBonus() * mcMMOPlayer.getAttackStrength());
}
Expand Down Expand Up @@ -465,7 +495,7 @@ else if (ItemUtils.isTrident(heldItem)) {
}

if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.TRIDENTS)) {
processTridentCombat(target, player, event);
processTridentCombatMelee(target, player, event);
}
}
}
Expand All @@ -481,6 +511,17 @@ else if (entityType == EntityType.WOLF) {
}
}
}
else if (painSource instanceof Trident trident) {
ProjectileSource projectileSource = trident.getShooter();

if (projectileSource instanceof Player player) {
if (!Misc.isNPCEntityExcludingVillagers(player)) {
if(mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TRIDENTS, target)) {
processTridentCombatRanged(trident, target, player, event);
}
}
}
}
else if (painSource instanceof Arrow arrow) {
ProjectileSource projectileSource = arrow.getShooter();
boolean isCrossbow = arrow.isShotFromCrossbow();
Expand Down

0 comments on commit cf49fc7

Please sign in to comment.