mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 18:12:09 +01:00
51 lines
3.7 KiB
Diff
51 lines
3.7 KiB
Diff
--- a/net/minecraft/world/item/TridentItem.java
|
|
+++ b/net/minecraft/world/item/TridentItem.java
|
|
@@ -86,18 +86,37 @@
|
|
if (world instanceof ServerLevel) {
|
|
ServerLevel worldserver = (ServerLevel) world;
|
|
|
|
- stack.hurtWithoutBreaking(1, entityhuman);
|
|
+ // itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down
|
|
if (f == 0.0F) {
|
|
- ThrownTrident entitythrowntrident = (ThrownTrident) Projectile.spawnProjectileFromRotation(ThrownTrident::new, worldserver, stack, entityhuman, 0.0F, 2.5F, 1.0F);
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
|
+ Projectile.Delayed<ThrownTrident> tridentDelayed = Projectile.spawnProjectileFromRotationDelayed(ThrownTrident::new, worldserver, stack, entityhuman, 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) entityhuman.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
|
|
+ if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) {
|
|
+ ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ ThrownTrident entitythrowntrident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent
|
|
+ if (event.shouldConsume()) stack.hurtWithoutBreaking(1, entityhuman); // Paper - PlayerLaunchProjectileEvent
|
|
+ entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved
|
|
+ // CraftBukkit end
|
|
|
|
if (entityhuman.hasInfiniteMaterials()) {
|
|
entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
|
- } else {
|
|
+ } else if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent
|
|
entityhuman.getInventory().removeItem(stack);
|
|
}
|
|
|
|
world.playSound((Player) null, (Entity) entitythrowntrident, (SoundEvent) holder.value(), SoundSource.PLAYERS, 1.0F, 1.0F);
|
|
return true;
|
|
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
|
+ } else {
|
|
+ stack.hurtWithoutBreaking(1, entityhuman);
|
|
+ // CraftBukkkit end
|
|
}
|
|
}
|
|
|
|
@@ -112,6 +131,7 @@
|
|
f3 *= f / f6;
|
|
f4 *= f / f6;
|
|
f5 *= f / f6;
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, stack, f3, f4, f5); // CraftBukkit
|
|
entityhuman.push((double) f3, (double) f4, (double) f5);
|
|
entityhuman.startAutoSpinAttack(20, 8.0F, stack);
|
|
if (entityhuman.onGround()) {
|