From 2053f3bd83fd0d540e3c2036c4aa6f4b7eb3c8c3 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 15 Jun 2024 16:40:29 +0200 Subject: [PATCH] Update AbstractArrow item method implementations for 1.20.6 (#10885) --- patches/api/More-Projectile-API.patch | 18 +++++++++++++----- patches/server/More-Projectile-API.patch | 11 +++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/patches/api/More-Projectile-API.patch b/patches/api/More-Projectile-API.patch index bb6f431343..b46ed7ac11 100644 --- a/patches/api/More-Projectile-API.patch +++ b/patches/api/More-Projectile-API.patch @@ -25,10 +25,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * Sets the ItemStack which will be picked up from this arrow. * * @param item ItemStack set to be picked up -+ * @deprecated until 1.20.5 when the behavior is more defined ++ * @deprecated use {@link #getItemStack()} */ @ApiStatus.Experimental -+ @Deprecated // Paper - remove in 1.20.5 ++ @Deprecated(forRemoval = true, since = "1.20.4") // Paper public void setItem(@NotNull ItemStack item); /** @@ -39,12 +39,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Paper start - more projectile API + /** -+ * Gets the ItemStack for this arrow. ++ * Gets the {@link ItemStack} for this arrow. This stack is used ++ * for both visuals on the arrow and the stack that could be picked up. + * + * @return The ItemStack, as if a player picked up the arrow + */ -+ @NotNull -+ org.bukkit.inventory.ItemStack getItemStack(); ++ @NotNull ItemStack getItemStack(); ++ ++ /** ++ * Sets the {@link ItemStack} for this arrow. This stack is used for both ++ * visuals on the arrow and the stack that could be picked up. ++ * ++ * @param stack the arrow stack ++ */ ++ void setItemStack(@NotNull ItemStack stack); + + /** + * Sets the amount of ticks this arrow has been alive in the world diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index 73da568dc1..3fdeea1126 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -12,6 +12,7 @@ public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ public net.minecraft.world.entity.projectile.ShulkerBullet currentMoveDirection public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps public net.minecraft.world.entity.projectile.AbstractArrow soundEvent +public net/minecraft/world/entity/projectile/AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR public net.minecraft.world.entity.projectile.Projectile hasBeenShot @@ -207,8 +208,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Paper start + @Override -+ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() { -+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.getHandle().getPickupItem()); ++ public CraftItemStack getItemStack() { ++ return CraftItemStack.asCraftMirror(this.getHandle().getPickupItem()); ++ } ++ ++ @Override ++ public void setItemStack(final ItemStack stack) { ++ Preconditions.checkArgument(stack != null, "ItemStack cannot be null"); ++ this.getHandle().setPickupItemStack(CraftItemStack.asNMSCopy(stack)); + } + + @Override