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
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
|
2021-06-16 00:24:12 +02:00
|
|
|
index 28e32cdac5b8c51dfcef14b585860f3181e814f3..5bfebe072ec722e7d6f3161d5d6cc709a9b80032 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
|
2021-06-16 00:24:12 +02:00
|
|
|
@@ -39,6 +39,7 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
|
2021-06-12 11:01:04 +02:00
|
|
|
public int lifetime;
|
|
|
|
@Nullable
|
2021-06-16 00:24:12 +02:00
|
|
|
public LivingEntity attachedToEntity;
|
2021-06-12 11:01:04 +02:00
|
|
|
+ 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.setUUID("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 d336b44f9486ddc93b57938413d8dec4503710fa..35f3f3887c0696b757553af9a5997506c97b24c0 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
|
|
@@ -222,6 +222,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 409b3c50b87cafba69259ab2232ef607bfce755a..10385dcb851bb435821afba322ed11f59e7ad3e6 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
|
|
@@ -46,6 +46,7 @@ public class FireworkRocketItem extends Item {
|
|
|
|
Vec3 vec3 = context.getClickLocation();
|
|
|
|
Direction direction = context.getClickedFace();
|
|
|
|
FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(level, context.getPlayer(), vec3.x + (double)direction.getStepX() * 0.15D, vec3.y + (double)direction.getStepY() * 0.15D, vec3.z + (double)direction.getStepZ() * 0.15D, itemStack);
|
|
|
|
+ fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper
|
|
|
|
level.addFreshEntity(fireworkRocketEntity);
|
|
|
|
itemStack.shrink(1);
|
|
|
|
}
|
|
|
|
@@ -59,6 +60,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 3a1c3d20ecc3612421e346edbbb74ab47f16a137..be86114eac3975b82ca74d4d6ed3f0402a642e8a 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
|
|
|
|
@@ -78,4 +78,17 @@ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.entity.LivingEntity getBoostedEntity() {
|
|
|
|
+ net.minecraft.world.entity.LivingEntity boostedEntity = getHandle().attachedToEntity;
|
|
|
|
+ return boostedEntity != null ? (org.bukkit.entity.LivingEntity) boostedEntity.getBukkitEntity() : null;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|