Update AbstractArrow item method implementations for 1.20.6 (#10885)

This commit is contained in:
Jake Potrebic 2024-06-15 16:40:29 +02:00
parent efb91589dc
commit 2053f3bd83
2 changed files with 22 additions and 7 deletions

View file

@ -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

View file

@ -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