From 04eefaef791134506b03f1f9c44570835a533e22 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 9 Nov 2024 15:58:24 -0800 Subject: [PATCH] Fixed ricocheted arrows missing some data after bouncing Fixes #5093 --- Changelog.txt | 1 + .../nossr50/skills/crossbows/CrossbowsManager.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 1a2c3a712..a328372db 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ Version 2.2.027 + Fixed Ricocheted arrows losing some data after a ricochet Fixed concurrency issue with Folia regarding locale strings Fixed concurrency issue with Folia regarding COTW summons diff --git a/src/main/java/com/gmail/nossr50/skills/crossbows/CrossbowsManager.java b/src/main/java/com/gmail/nossr50/skills/crossbows/CrossbowsManager.java index 1858f6368..20b602501 100644 --- a/src/main/java/com/gmail/nossr50/skills/crossbows/CrossbowsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/crossbows/CrossbowsManager.java @@ -64,10 +64,17 @@ public class CrossbowsManager extends SkillManager { // Spawn new arrow with the reflected direction Arrow spawnedArrow = originalArrow.getWorld().spawnArrow(origin, reflectedDirection, 1, 1); + // copy some properties from the old arrow + spawnedArrow.setShooter(originalArrowShooter); + spawnedArrow.setCritical(originalArrow.isCritical()); + spawnedArrow.setPierceLevel(originalArrow.getPierceLevel()); + spawnedArrow.setPickupStatus(originalArrow.getPickupStatus()); + spawnedArrow.setKnockbackStrength(originalArrow.getKnockbackStrength()); + + // copy metadata from old arrow ProjectileUtils.copyArrowMetadata(pluginRef, originalArrow, spawnedArrow); originalArrow.remove(); - // copy metadata from old arrow - spawnedArrow.setShooter(originalArrowShooter); + // add important metadata to new arrow spawnedArrow.setMetadata(MetadataConstants.METADATA_KEY_BOUNCE_COUNT, new FixedMetadataValue(pluginRef, bounceCount + 1)); spawnedArrow.setMetadata(MetadataConstants.METADATA_KEY_SPAWNED_ARROW,