2021-06-12 11:01:04 +02:00
|
|
|
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
|
|
|
|
|
2022-11-20 00:53:20 +01:00
|
|
|
== AT ==
|
|
|
|
public net.minecraft.world.entity.projectile.FireworkRocketEntity attachedToEntity
|
2021-06-12 11:01:04 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
2024-06-13 17:45:43 +02:00
|
|
|
index f525fafc638c7252c99b6d98cf579be11ca5463e..6671796d292fbc922a94271136f5a7a4bbdedaca 100644
|
2021-06-12 11:01:04 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
2024-04-24 03:25:14 +02:00
|
|
|
@@ -42,6 +42,7 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
|
2021-06-12 11:01:04 +02:00
|
|
|
public int lifetime;
|
|
|
|
@Nullable
|
2022-12-07 19:52:24 +01:00
|
|
|
public LivingEntity attachedToEntity;
|
2024-04-12 21:14:06 +02:00
|
|
|
+ @Nullable public java.util.UUID spawningEntity; // Paper
|
2021-06-12 11:01:04 +02:00
|
|
|
|
|
|
|
public FireworkRocketEntity(EntityType<? extends FireworkRocketEntity> type, Level world) {
|
|
|
|
super(type, world);
|
2024-04-24 03:25:14 +02:00
|
|
|
@@ -299,6 +300,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
|
|
|
|
nbt.putInt("LifeTime", this.lifetime);
|
|
|
|
nbt.put("FireworksItem", this.getItem().save(this.registryAccess()));
|
2021-06-12 11:01:04 +02:00
|
|
|
nbt.putBoolean("ShotAtAngle", (Boolean) this.entityData.get(FireworkRocketEntity.DATA_SHOT_AT_ANGLE));
|
|
|
|
+ // Paper start
|
|
|
|
+ if (this.spawningEntity != null) {
|
2021-06-17 23:39:36 +02:00
|
|
|
+ nbt.putUUID("SpawningEntity", this.spawningEntity);
|
2021-06-12 11:01:04 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-04-24 03:25:14 +02:00
|
|
|
@@ -315,7 +321,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
|
2021-06-12 11:01:04 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-04-24 03:25:14 +02:00
|
|
|
private List<FireworkExplosion> getExplosions() {
|
2021-06-12 11:01:04 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
2024-04-24 03:25:14 +02:00
|
|
|
index c797fc980577d77e18cd5ea660e4c42ca0f21747..65f23bfb2de91be7560800ff87eab7ad88cb1849 100644
|
2021-06-12 11:01:04 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
2024-04-24 03:25:14 +02:00
|
|
|
@@ -147,7 +147,11 @@ public class CrossbowItem extends ProjectileWeaponItem {
|
|
|
|
@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) {
|
2021-06-12 11:01:04 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
2024-04-24 03:25:14 +02:00
|
|
|
index da89ccaf91e2baa7caa15681c113bc283f40cd21..38b33eb92d21d0099285a304c6e064bbf56db4eb 100644
|
2021-06-12 11:01:04 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
2024-04-24 03:25:14 +02:00
|
|
|
@@ -42,6 +42,7 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
2024-04-16 21:44:59 +02:00
|
|
|
vec3.z + (double)direction.getStepZ() * 0.15,
|
2024-04-12 21:14:06 +02:00
|
|
|
itemStack
|
|
|
|
);
|
2021-06-12 11:01:04 +02:00
|
|
|
+ fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper
|
|
|
|
level.addFreshEntity(fireworkRocketEntity);
|
|
|
|
itemStack.shrink(1);
|
|
|
|
}
|
2024-04-24 03:25:14 +02:00
|
|
|
@@ -55,6 +56,7 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
2021-06-12 11:01:04 +02:00
|
|
|
ItemStack itemStack = user.getItemInHand(hand);
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user);
|
|
|
|
+ fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
|
|
|
|
world.addFreshEntity(fireworkRocketEntity);
|
2024-04-24 03:25:14 +02:00
|
|
|
itemStack.consume(1, user);
|
|
|
|
user.awardStat(Stats.ITEM_USED.get(this));
|
2021-06-12 11:01:04 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
2023-12-05 18:20:55 +01:00
|
|
|
index 5ae87c370e47c545cef27a36e40da137e1ec656b..c9e15a9d82dee935293b2e7e233f5b9b2d822448 100644
|
2021-06-12 11:01:04 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
2023-08-14 01:32:51 +02:00
|
|
|
@@ -129,4 +129,11 @@ public class CraftFirework extends CraftProjectile implements Firework {
|
2021-06-12 11:01:04 +02:00
|
|
|
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
|
|
|
|
}
|