mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-27 08:50:35 +01:00
Cancel PlayerLaunchProjectileEvent properly for enderpearls (#12223)
This commit is contained in:
parent
df96f8a0fa
commit
2565497897
1 changed files with 6 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/world/item/EnderpearlItem.java
|
||||
+++ b/net/minecraft/world/item/EnderpearlItem.java
|
||||
@@ -21,22 +_,38 @@
|
||||
@@ -21,22 +_,42 @@
|
||||
@Override
|
||||
public InteractionResult use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack itemInHand = player.getItemInHand(hand);
|
||||
|
@ -39,7 +39,11 @@
|
|||
+ );
|
||||
+ player.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ } else {
|
||||
+ // Paper end - PlayerLaunchProjectileEvent
|
||||
+ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
|
||||
+ serverPlayer.deregisterEnderPearl(thrownEnderpearl.projectile());
|
||||
+ serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundCooldownPacket(player.getCooldowns().getCooldownGroup(itemInHand), 0)); // prevent visual desync of cooldown on the slot
|
||||
+ }
|
||||
+ // Paper end - PlayerLaunchProjectileEvent
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
|
|
Loading…
Add table
Reference in a new issue