PaperMC/patches/server/0214-PlayerElytraBoostEvent.patch

34 lines
2.3 KiB
Diff
Raw Normal View History

2021-06-12 23:31:35 +02:00
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 7c627d27300247db9122ab2081049345ef306073..6e6c9477b70b0e1ab36bca9fa91806a283ebedd1 100644
2021-06-12 23:31:35 +02:00
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
2023-03-14 19:59:51 +01:00
@@ -61,12 +61,19 @@ public class FireworkRocketItem extends Item {
2021-06-12 23:31:35 +02:00
if (!world.isClientSide) {
FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user);
fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
- world.addFreshEntity(fireworkRocketEntity);
- if (!user.getAbilities().instabuild) {
+ // Paper start - PlayerElytraBoostEvent
2021-06-12 23:31:35 +02:00
+ 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 - PlayerElytraBoostEvent
2021-06-12 23:31:35 +02:00
}
- user.awardStat(Stats.ITEM_USED.get(this));
+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - PlayerElytraBoostEvent; move up
2021-06-12 23:31:35 +02:00
}
return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide());