aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0481-Player-elytra-boost-API.patch
blob: c389d60dee4efe68bbd3b5eb97bb3b84dd587e83 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Trigary <trigary0@gmail.com>
Date: Tue, 14 Apr 2020 12:05:22 +0200
Subject: [PATCH] Player elytra boost API


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index c21710e895fc614d06f2de6dbfa60c1571c157f8..01e7b92cef00cda4c4bb10f42501876d7a7c54a1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -617,6 +617,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
         }
         throw new RuntimeException("Unknown settings type");
     }
+
+    @Override
+    public org.bukkit.entity.Firework boostElytra(ItemStack firework) {
+        Preconditions.checkState(this.isGliding(), "Player must be gliding");
+        Preconditions.checkArgument(firework != null, "firework == null");
+        Preconditions.checkArgument(firework.getType() == ItemType.FIREWORK_ROCKET, "Firework must be Material.FIREWORK_ROCKET");
+
+        net.minecraft.world.item.ItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(firework);
+        net.minecraft.world.level.Level world = ((CraftWorld) getWorld()).getHandle();
+        net.minecraft.world.entity.projectile.FireworkRocketEntity entity = new net.minecraft.world.entity.projectile.FireworkRocketEntity(world, item, getHandle());
+        return world.addFreshEntity(entity)
+            ? (org.bukkit.entity.Firework) entity.getBukkitEntity()
+            : null;
+    }
     // Paper end
 
     @Override