1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-03-27 08:50:35 +01:00

Cancel PlayerLaunchProjectileEvent properly for enderpearls ()

This commit is contained in:
Lulu13022002 2025-03-08 23:02:10 +01:00 committed by GitHub
parent df96f8a0fa
commit 2565497897
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
+ }