mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
Fix EntityLoadCrossbowEvent Sync Issue (#5739)
This commit is contained in:
parent
04087a3e9a
commit
7426c0370e
2 changed files with 4 additions and 5 deletions
|
@ -89,10 +89,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * Set whether or not to cancel the crossbow being loaded. If canceled, the
|
+ * 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.
|
+ * 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
|
+ * @param cancel true if you wish to cancel this event
|
||||||
+ */
|
+ */
|
||||||
+ @Override
|
+ @Override
|
||||||
|
|
|
@ -16,7 +16,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start - EntityLoadCrossbowEvent
|
+ // Paper start - EntityLoadCrossbowEvent
|
||||||
+ if (f >= 1.0F && !CrossbowItem.isCharged(stack) /*&& CrossbowItem.tryLoadProjectiles(entityliving, itemstack)*/) {
|
+ 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);
|
+ 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
|
+ // Paper end
|
||||||
CrossbowItem.setCharged(stack, true);
|
CrossbowItem.setCharged(stack, true);
|
||||||
SoundSource soundcategory = user instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE;
|
SoundSource soundcategory = user instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE;
|
||||||
|
|
Loading…
Reference in a new issue