Skip to content

Commit

Permalink
bye variable
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion committed Feb 22, 2025
1 parent 197d6ab commit cf243d4
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ServerLevel level,
LivingEntity shooter,
InteractionHand hand,
@@ -51,6 +_,25 @@
@@ -51,6 +_,24 @@
boolean isCrit,
@Nullable LivingEntity target
) {
Expand All @@ -43,12 +43,11 @@
+ ) {
+ List<ItemStack> projectileItems = unrealizedDrawResult.projectileStacks();
+ boolean atLeastOneShootBowEventUncancelled = false;
+ int crossbowRemovals = 0;
+ // Paper end - prevent item consumption for cancelled events
float f = EnchantmentHelper.processProjectileSpread(level, weapon, shooter, 0.0F);
float f1 = projectileItems.size() == 1 ? 0.0F : 2.0F * f / (projectileItems.size() - 1);
float f2 = (projectileItems.size() - 1) % 2 * f1 / 2.0F;
@@ -62,18 +_,51 @@
@@ -62,18 +_,50 @@
float f4 = f2 + f3 * ((i + 1) / 2) * f1;
f3 = -f3;
int i1 = i;
Expand Down Expand Up @@ -87,11 +86,10 @@
+ if (event.shouldConsumeItem()) {
+ if (weapon.is(net.minecraft.world.item.Items.CROSSBOW)) {
+ List<ItemStack> newProjectiles = new java.util.ArrayList<>(weapon.get(DataComponents.CHARGED_PROJECTILES).getItems());
+ newProjectiles.remove(i-crossbowRemovals);
+ newProjectiles.remove(i - (projectileItems.size() - newProjectiles.size()));
+ weapon.set(DataComponents.CHARGED_PROJECTILES, net.minecraft.world.item.component.ChargedProjectiles.of(newProjectiles));
+ crossbowRemovals++;
+ } else if (level.shouldConsumeArrow) {
+ unrealizedDrawResult.consumeProjectilesFromPlayerInventory(i); // Paper - improve shoot bow - correctly prevent item consumption
+ unrealizedDrawResult.consumeProjectilesFromPlayerInventory(i);
+ // Paper end - prevent item consumption for cancelled events
+ }
+ }
Expand Down

0 comments on commit cf243d4

Please sign in to comment.