aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0118-Firework-API-s.patch
blob: c562b8781186a334c9ab70e0bd2c96dd038c37b8 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 28 Dec 2016 07:18:33 +0100
Subject: [PATCH] Firework API's

== AT ==
public net.minecraft.world.entity.projectile.FireworkRocketEntity attachedToEntity

diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
index 9d637e005205a32fa5406ba47de7cd2b22ead9cf..813c4a52c8ddd70e252125ebfd3654346c71f13c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
@@ -40,6 +40,7 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
     public int lifetime;
     @Nullable
     public LivingEntity attachedToEntity;
+    @Nullable public java.util.UUID spawningEntity; // Paper
 
     public FireworkRocketEntity(EntityType<? extends FireworkRocketEntity> type, Level world) {
         super(type, world);
@@ -315,6 +316,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
         }
 
         nbt.putBoolean("ShotAtAngle", (Boolean) this.entityData.get(FireworkRocketEntity.DATA_SHOT_AT_ANGLE));
+        // Paper start
+        if (this.spawningEntity != null) {
+            nbt.putUUID("SpawningEntity", this.spawningEntity);
+        }
+        // Paper end
     }
 
     @Override
@@ -331,7 +337,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
         if (nbt.contains("ShotAtAngle")) {
             this.entityData.set(FireworkRocketEntity.DATA_SHOT_AT_ANGLE, nbt.getBoolean("ShotAtAngle"));
         }
-
+        // Paper start
+        if (nbt.hasUUID("SpawningEntity")) {
+            this.spawningEntity = nbt.getUUID("SpawningEntity");
+        }
+        // Paper end
     }
 
     @Override
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
index ac7371882d15746e9353865635d0bb716f890c53..ba570f1c9654e1004e068a1efe2118f36c954505 100644
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
@@ -217,6 +217,7 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
 
             if (flag1) {
                 object = new FireworkRocketEntity(world, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15000000596046448D, shooter.getZ(), true);
+                ((FireworkRocketEntity) object).spawningEntity = shooter.getUUID(); // Paper
             } else {
                 object = CrossbowItem.getArrow(world, shooter, crossbow, projectile);
                 if (creative || simulated != 0.0F) {
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
index b342d23692ffd38b6eec66838162e9012f29ac09..3749cfca8f007973d1a2206d8f2ba15283a550e1 100644
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
@@ -53,6 +53,7 @@ public class FireworkRocketItem extends Item {
                 vec3.z + (double)direction.getStepZ() * 0.15,
                 itemStack
             );
+            fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper
             level.addFreshEntity(fireworkRocketEntity);
             itemStack.shrink(1);
         }
@@ -66,6 +67,7 @@ public class FireworkRocketItem extends Item {
             ItemStack itemStack = user.getItemInHand(hand);
             if (!world.isClientSide) {
                 FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user);
+                fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
                 world.addFreshEntity(fireworkRocketEntity);
                 if (!user.getAbilities().instabuild) {
                     itemStack.shrink(1);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
index 5ae87c370e47c545cef27a36e40da137e1ec656b..c9e15a9d82dee935293b2e7e233f5b9b2d822448 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
@@ -129,4 +129,11 @@ public class CraftFirework extends CraftProjectile implements Firework {
     public void setShotAtAngle(boolean shotAtAngle) {
         this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_SHOT_AT_ANGLE, shotAtAngle);
     }
+
+    // Paper start
+    @Override
+    public java.util.UUID getSpawningEntity() {
+        return getHandle().spawningEntity;
+    }
+    // Paper end
 }