--- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java @@ -87,19 +_,35 @@ .orElse(SoundEvents.TRIDENT_THROW); player.awardStat(Stats.ITEM_USED.get(this)); if (level instanceof ServerLevel serverLevel) { - stack.hurtWithoutBreaking(1, player); + // stack.hurtWithoutBreaking(1, player); // CraftBukkit - moved down if (tridentSpinAttackStrength == 0.0F) { - ThrownTrident thrownTrident = Projectile.spawnProjectileFromRotation( + Projectile.Delayed tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent ThrownTrident::new, serverLevel, stack, player, 0.0F, 2.5F, 1.0F ); + // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity()); + if (!event.callEvent() || !tridentDelayed.attemptSpawn()) { + // CraftBukkit start + // Paper end - PlayerLaunchProjectileEvent + player.containerMenu.sendAllDataToRemote(); + return false; + } + ThrownTrident thrownTrident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent + if (event.shouldConsume()) stack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent + thrownTrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved + // CraftBukkit end if (player.hasInfiniteMaterials()) { thrownTrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; - } else { + } else if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent player.getInventory().removeItem(stack); } level.playSound(null, thrownTrident, holder.value(), SoundSource.PLAYERS, 1.0F, 1.0F); return true; + // CraftBukkit start - SPIGOT-5458 also need in this branch :( + } else { + stack.hurtWithoutBreaking(1, player); + // CraftBukkit end } } @@ -113,6 +_,7 @@ f *= tridentSpinAttackStrength / squareRoot; f1 *= tridentSpinAttackStrength / squareRoot; f2 *= tridentSpinAttackStrength / squareRoot; + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(player, stack, f, f1, f2); // CraftBukkit player.push(f, f1, f2); player.startAutoSpinAttack(20, 8.0F, stack); if (player.onGround()) {