aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0224-PlayerElytraBoostEvent.patch
blob: fde7853fade173e9958c8e9ce5d70c56c1dedf42 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 21 Jul 2018 01:59:59 -0500
Subject: [PATCH] PlayerElytraBoostEvent


diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
index 766af1f45b14654d3655a06ae0bfb0d4cfbdff7a..e927eaaaf79cd5cdc150a9db10d730c7b17601fc 100644
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
@@ -59,12 +59,19 @@ public class FireworkRocketItem extends Item {
             if (!world.isClientSide) {
                 FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user);
                 fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
-                world.addFreshEntity(fireworkRocketEntity);
-                if (!user.getAbilities().instabuild) {
+                // Paper start
+                com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity());
+                if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) {
+                    user.awardStat(Stats.ITEM_USED.get(this));
+                    if (event.shouldConsume() && !user.getAbilities().instabuild) {
                     itemStack.shrink(1);
+                    } else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+                } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
+                    ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+                    // Paper end
                 }
 
-                user.awardStat(Stats.ITEM_USED.get(this));
+                // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - move up
             }
 
             return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide());