diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index 70b0990cf3..91715aeb75 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -10,7 +10,15 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { -@@ -84,7 +87,29 @@ +@@ -42,6 +45,7 @@ + public int lifetime; + @Nullable + public LivingEntity attachedToEntity; ++ @Nullable public java.util.UUID spawningEntity; // Paper + + public FireworkRocketEntity(EntityType type, Level world) { + super(type, world); +@@ -84,7 +88,29 @@ this.setOwner(entity); } @@ -40,7 +48,7 @@ protected void defineSynchedData(SynchedEntityData.Builder builder) { builder.define(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, FireworkRocketEntity.getDefaultItem()); builder.define(FireworkRocketEntity.DATA_ATTACHED_TO_TARGET, OptionalInt.empty()); -@@ -152,7 +177,7 @@ +@@ -152,7 +178,7 @@ } if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != HitResult.Type.MISS) { @@ -49,7 +57,7 @@ this.hasImpulse = true; } -@@ -172,7 +197,11 @@ +@@ -172,7 +198,11 @@ if (world instanceof ServerLevel) { ServerLevel worldserver = (ServerLevel) world; @@ -62,7 +70,7 @@ } } -@@ -182,7 +211,7 @@ +@@ -182,7 +212,7 @@ world.broadcastEntityEvent(this, (byte) 17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(world); @@ -71,7 +79,7 @@ } @Override -@@ -191,7 +220,11 @@ +@@ -191,7 +221,11 @@ Level world = this.level(); if (world instanceof ServerLevel worldserver) { @@ -84,7 +92,7 @@ } } -@@ -205,7 +238,11 @@ +@@ -205,7 +239,11 @@ if (world instanceof ServerLevel worldserver) { if (this.hasExplosion()) { @@ -97,3 +105,28 @@ } } +@@ -287,6 +325,11 @@ + nbt.putInt("LifeTime", this.lifetime); + nbt.put("FireworksItem", this.getItem().save(this.registryAccess())); + 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 +@@ -303,7 +346,11 @@ + 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 + } + + private List getExplosions() { diff --git a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch new file mode 100644 index 0000000000..0af1232366 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/item/CrossbowItem.java ++++ b/net/minecraft/world/item/CrossbowItem.java +@@ -164,7 +164,11 @@ + @Override + protected Projectile createProjectile(Level world, LivingEntity shooter, ItemStack weaponStack, ItemStack projectileStack, boolean critical) { + if (projectileStack.is(Items.FIREWORK_ROCKET)) { +- return new FireworkRocketEntity(world, projectileStack, shooter, shooter.getX(), shooter.getEyeY() - 0.15F, shooter.getZ(), true); ++ // Paper start ++ FireworkRocketEntity entity = new FireworkRocketEntity(world, projectileStack, shooter, shooter.getX(), shooter.getEyeY() - 0.15F, shooter.getZ(), true); ++ entity.spawningEntity = shooter.getUUID(); // Paper ++ return entity; ++ // Paper end + } else { + Projectile projectile = super.createProjectile(world, shooter, weaponStack, projectileStack, critical); + if (projectile instanceof AbstractArrow abstractArrow) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch new file mode 100644 index 0000000000..d36c81e68f --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/FireworkRocketItem.java ++++ b/net/minecraft/world/item/FireworkRocketItem.java +@@ -43,7 +43,7 @@ + itemStack + ), + serverLevel, +- itemStack ++ itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid + ); + itemStack.shrink(1); + } +@@ -56,7 +56,7 @@ + if (user.isFallFlying()) { + ItemStack itemStack = user.getItemInHand(hand); + if (world instanceof ServerLevel serverLevel) { +- Projectile.spawnProjectile(new FireworkRocketEntity(world, itemStack, user), serverLevel, itemStack); ++ Projectile.spawnProjectile(new FireworkRocketEntity(world, itemStack, user), serverLevel, itemStack, f -> f.spawningEntity = user.getUUID()); // Paper - firework api - assign spawning entity uuid + itemStack.consume(1, user); + user.awardStat(Stats.ITEM_USED.get(this)); + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 5ae87c370e..c9e15a9d82 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/paper-server/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 }