From 7426c0370ee1b5e58d40d0910fe17783fc67eb28 Mon Sep 17 00:00:00 2001 From: LemonCaramel Date: Fri, 31 Dec 2021 15:54:23 +0900 Subject: [PATCH] Fix EntityLoadCrossbowEvent Sync Issue (#5739) --- patches/api/Add-EntityLoadCrossbowEvent.patch | 4 ---- patches/server/Add-EntityLoadCrossbowEvent.patch | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/patches/api/Add-EntityLoadCrossbowEvent.patch b/patches/api/Add-EntityLoadCrossbowEvent.patch index 9eedb3e1b2..1c0b760838 100644 --- a/patches/api/Add-EntityLoadCrossbowEvent.patch +++ b/patches/api/Add-EntityLoadCrossbowEvent.patch @@ -89,10 +89,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Set whether or not to cancel the crossbow being loaded. If canceled, the + * projectile that would be loaded into the crossbow will not be consumed. + * -+ * If set to false, and this event is pertaining to a player entity, -+ * it's recommended that a call to {@link Player#updateInventory()} is made -+ * as the client may think the server still loaded an item into the crossbow. -+ * + * @param cancel true if you wish to cancel this event + */ + @Override diff --git a/patches/server/Add-EntityLoadCrossbowEvent.patch b/patches/server/Add-EntityLoadCrossbowEvent.patch index 0121d4fd88..099ef63b54 100644 --- a/patches/server/Add-EntityLoadCrossbowEvent.patch +++ b/patches/server/Add-EntityLoadCrossbowEvent.patch @@ -16,7 +16,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // 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; ++ if (!event.callEvent() || !tryLoadProjectiles(user, stack, event.shouldConsumeItem())) { ++ if (user instanceof ServerPlayer player) player.containerMenu.sendAllDataToRemote(); ++ return; ++ } + // Paper end CrossbowItem.setCharged(stack, true); SoundSource soundcategory = user instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE;