aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-05-29 13:58:57 -0700
committerGitHub <[email protected]>2024-05-29 22:58:57 +0200
commita31dc90741ed9c121a13a3c124c9ebf5bafd0da7 (patch)
tree81963bd94fe7772ee08bd21710230de21b6b25da /patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
parented85aac53cfd93d29fa24e6071dbdddd0e49624b (diff)
downloadPaper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.tar.gz
Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.zip
Several fixes and new api for experience merging/stacking (#9242)
Diffstat (limited to 'patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch')
-rw-r--r--patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch b/patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
new file mode 100644
index 0000000000..23927dc5e5
--- /dev/null
+++ b/patches/server/0756-Add-a-consumer-parameter-to-ProjectileSource-launchP.patch
@@ -0,0 +1,69 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: MelnCat <[email protected]>
+Date: Mon, 19 Sep 2022 14:16:10 -0700
+Subject: [PATCH] Add a consumer parameter to ProjectileSource#launchProjectile
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+index 382b4f0854284a561325dde141000434a9ddd885..eaeacf28295a5f1af37c8733f36066a69d858cc3 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+@@ -561,8 +561,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+ }
+
+ @Override
+- @SuppressWarnings("unchecked")
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
++ // Paper start - launchProjectile consumer
++ return this.launchProjectile(projectile, velocity, null);
++ }
++
++ @Override
++ @SuppressWarnings("unchecked")
++ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<? super T> function) {
++ // Paper end - launchProjectile consumer
+ Preconditions.checkState(!this.getHandle().generation, "Cannot launch projectile during world generation");
+
+ net.minecraft.world.level.Level world = ((CraftWorld) this.getWorld()).getHandle();
+@@ -649,6 +656,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+ if (velocity != null) {
+ ((T) launch.getBukkitEntity()).setVelocity(velocity);
+ }
++ // Paper start - launchProjectile consumer
++ if (function != null) {
++ function.accept((T) launch.getBukkitEntity());
++ }
++ // Paper end - launchProjectile consumer
+
+ world.addFreshEntity(launch);
+ return (T) launch.getBukkitEntity();
+diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
+index faab60e735aca230cb4c0b7db21e6a9a237daf6e..89401fc942c151941790b1152a35357aa51fcdba 100644
+--- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
++++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
+@@ -55,6 +55,13 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
+
+ @Override
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
++ // Paper start - launchProjectile consumer
++ return this.launchProjectile(projectile, velocity, null);
++ }
++
++ @Override
++ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<? super T> function) {
++ // Paper end - launchProjectile consumer
+ Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
+ // Copied from BlockDispenser.dispense()
+ BlockSource sourceblock = new BlockSource((ServerLevel) this.dispenserBlock.getLevel(), this.dispenserBlock.getBlockPos(), this.dispenserBlock.getBlockState(), this.dispenserBlock);
+@@ -145,6 +152,11 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
+ if (velocity != null) {
+ ((T) launch.getBukkitEntity()).setVelocity(velocity);
+ }
++ // Paper start
++ if (function != null) {
++ function.accept((T) launch.getBukkitEntity());
++ }
++ // Paper end
+
+ world.addFreshEntity(launch);
+ return (T) launch.getBukkitEntity();