aboutsummaryrefslogtreecommitdiffhomepage
path: root/paper-server/patches/unapplied/net/minecraft/world/item/TridentItem.java.patch
blob: a23995cfe31c36157cf6676d0c3006168b5b8194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- 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()) {