Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exceptions when shooting entities through worlds on folia #5024

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable;
import org.bukkit.entity.LivingEntity;

Expand Down Expand Up @@ -44,6 +45,7 @@ public void run() {
damage = Math.min(damage, ExperienceConfig.getInstance().getCombatHPCeiling());
}

mcMMOPlayer.beginXpGain(primarySkillType, (int) (damage * baseXp), xpGainReason, XPGainSource.SELF);
final double finalDamage = damage;
mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), task -> mcMMOPlayer.beginXpGain(primarySkillType, (int) (finalDamage * baseXp), xpGainReason, XPGainSource.SELF));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ public void attackTarget(LivingEntity target) {
double range = 5;
Player player = getPlayer();

if (!target.getWorld().equals(player.getWorld()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would a player's world not equal their targets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to shoot an arrow through a nether portal and hit an entity on the other side of it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for that information!

return;

for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity.getType() != EntityType.WOLF) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ public static void processCombatXP(@NotNull McMMOPlayer mcMMOPlayer,
baseXP *= multiplier;

if (baseXP > 0) {
mcMMO.p.getFoliaLib().getImpl().runAtEntity(mcMMOPlayer.getPlayer(), new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
mcMMO.p.getFoliaLib().getImpl().runAtEntity(target, new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason));
}
}

Expand Down
Loading