From 1e9ec27588c0905a67c021052d5c64ce35a686f9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 14 Aug 2022 16:53:36 +0200 Subject: [PATCH] More ThrownPotion API --- patches/api/More-Projectile-API.patch | 15 ++++++++++++ patches/server/More-Projectile-API.patch | 31 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/patches/api/More-Projectile-API.patch b/patches/api/More-Projectile-API.patch index 516024adc2..ac1d7983f2 100644 --- a/patches/api/More-Projectile-API.patch +++ b/patches/api/More-Projectile-API.patch @@ -3,6 +3,7 @@ From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Wed, 26 May 2021 19:34:43 -0400 Subject: [PATCH] More Projectile API +Co-authored-by: Nassim Jahnke diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -99,6 +100,15 @@ diff --git a/src/main/java/org/bukkit/entity/ThrownPotion.java b/src/main/java/o index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/ThrownPotion.java +++ b/src/main/java/org/bukkit/entity/ThrownPotion.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + /** + * Represents a thrown potion bottle + */ +-public interface ThrownPotion extends Projectile { ++public interface ThrownPotion extends ThrowableProjectile { // Paper - extend ThrowableProjectile + + /** + * Returns the effects that are applied by this potion. @@ -0,0 +0,0 @@ public interface ThrownPotion extends Projectile { /** @@ -131,5 +141,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param meta potion meta + */ + void setPotionMeta(@NotNull org.bukkit.inventory.meta.PotionMeta meta); ++ ++ /** ++ * Splashes the potion at its current location. ++ */ ++ void splash(); + // Paper end } diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index cb36945f19..c1d45bdddd 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -3,7 +3,33 @@ From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 22 Jun 2021 23:41:11 -0400 Subject: [PATCH] More Projectile API +Co-authored-by: Nassim Jahnke +diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java +@@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie + @Override + protected void onHit(HitResult hitResult) { + super.onHit(hitResult); ++ // Paper start - More projectile API ++ this.splash(hitResult); ++ } ++ public void splash(@org.jetbrains.annotations.Nullable HitResult hitResult) { ++ // Paper end - More projectile API + if (!this.level.isClientSide) { + ItemStack itemstack = this.getItem(); + Potion potionregistry = PotionUtils.getPotion(itemstack); +@@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie + if (this.isLingering()) { + this.makeAreaOfEffectCloud(itemstack, potionregistry); + } else { +- this.applySplash(list, hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null); ++ this.applySplash(list, hitResult != null && hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null); // Paper - nullable hitResult + } + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -159,6 +185,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + CraftItemStack.applyMetaToItem(item, meta); + this.getHandle().setItem(item); // Reset item + } ++ ++ @Override ++ public void splash() { ++ this.getHandle().splash(null); ++ } + // Paper end @Override public net.minecraft.world.entity.projectile.ThrownPotion getHandle() {