mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
aa52bf9e33
Mojang made some changes to priorities in 1.17 and it seems that these changes conflict with the changes made in this patch, which in some cases appears to cause excessive rescheduling of tasks. This, however, is not confirmed as such but seems to be the behavior that we're seeing to cause this issue, if mojang has adopted the changes we suggested, then a good chunk of this patch may be unneeded, but, this needs a much better look than I'm currently able to do
39 lines
2.5 KiB
Diff
39 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: JRoy <joshroy126@gmail.com>
|
|
Date: Wed, 7 Oct 2020 12:04:01 -0400
|
|
Subject: [PATCH] Add EntityLoadCrossbowEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
index 35f3f3887c0696b757553af9a5997506c97b24c0..77562d7c7248835532f2d9582cce6ef6725a12a6 100644
|
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
@@ -90,7 +90,11 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
|
|
int j = this.getUseDuration(stack) - remainingUseTicks;
|
|
float f = CrossbowItem.getPowerForTime(j, stack);
|
|
|
|
- if (f >= 1.0F && !CrossbowItem.isCharged(stack) && CrossbowItem.tryLoadProjectiles(user, stack)) {
|
|
+ // Paper start - EntityLoadCrossbowEvent
|
|
+ if (f >= 1.0F && !CrossbowItem.isCharged(stack) /*&& CrossbowItem.tryLoadProjectiles(entityliving, itemstack)*/) {
|
|
+ final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(user.getBukkitLivingEntity(), stack.asBukkitMirror(), user.getUsedItemHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND);
|
|
+ if (!event.callEvent() || !tryLoadProjectiles(user, stack, event.shouldConsumeItem())) return;
|
|
+ // Paper end
|
|
CrossbowItem.setCharged(stack, true);
|
|
SoundSource soundcategory = user instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE;
|
|
|
|
@@ -100,9 +104,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
|
|
}
|
|
|
|
private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack projectile) {
|
|
+ // Paper start
|
|
+ return CrossbowItem.tryLoadProjectiles(shooter, projectile, true);
|
|
+ }
|
|
+ private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack projectile, boolean consume) {
|
|
+ // Paper end
|
|
int i = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.MULTISHOT, projectile);
|
|
int j = i == 0 ? 1 : 3;
|
|
- boolean flag = shooter instanceof Player && ((Player) shooter).getAbilities().instabuild;
|
|
+ boolean flag = !consume || shooter instanceof Player && ((Player) shooter).getAbilities().instabuild; // Paper - add consume
|
|
ItemStack itemstack1 = shooter.getProjectile(projectile);
|
|
ItemStack itemstack2 = itemstack1.copy();
|
|
|