mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Call PlayerLaunchProjectileEvent for trident (#8027)
This commit is contained in:
parent
857ece0812
commit
4400eb6600
2 changed files with 38 additions and 1 deletions
|
@ -21,7 +21,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a player shoots a projectile
|
||||
+ * Called when a player shoots a projectile.
|
||||
+ * <p>
|
||||
+ * Notably this event is not called for arrows as the player does not launch them, rather shoots them with the help
|
||||
+ * of a bow or crossbow. A plugin may listen to {@link org.bukkit.event.entity.EntityShootBowEvent} for these actions
|
||||
+ * instead.
|
||||
+ */
|
||||
+public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
|
|
|
@ -274,3 +274,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
|
||||
@@ -0,0 +0,0 @@ public class TridentItem extends Item implements Vanishable {
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
- if (!world.addFreshEntity(entitythrowntrident)) {
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) entitythrowntrident.getBukkitEntity());
|
||||
+ if (!event.callEvent() || !world.addFreshEntity(entitythrowntrident)) {
|
||||
+ // Paper end
|
||||
if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
}
|
||||
return;
|
||||
}
|
||||
-
|
||||
+ if (event.shouldConsume()) { // Paper
|
||||
stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastBreakEvent(user.getUsedItemHand());
|
||||
});
|
||||
+ } // Paper
|
||||
entitythrowntrident.tridentItem = stack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
// CraftBukkit end
|
||||
|
||||
world.playSound((Player) null, (Entity) entitythrowntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||
- if (!entityhuman.getAbilities().instabuild) {
|
||||
+ if (event.shouldConsume() && !entityhuman.getAbilities().instabuild) { // Paper
|
||||
entityhuman.getInventory().removeItem(stack);
|
||||
}
|
||||
// CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
|
|
Loading…
Reference in a new issue