SPIGOT-7601: Add AbstractArrow#getItem

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-03-30 12:17:57 +11:00
parent 7afeda6ff8
commit 064114e718

View file

@ -5,8 +5,10 @@ import net.minecraft.core.BlockPosition;
import net.minecraft.world.entity.projectile.EntityArrow;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@ -118,6 +120,18 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
getHandle().setShotFromCrossbow(shotFromCrossbow);
}
@Override
public ItemStack getItem() {
return CraftItemStack.asBukkitCopy(getHandle().pickupItemStack);
}
@Override
public void setItem(ItemStack item) {
Preconditions.checkArgument(item != null, "ItemStack cannot be null");
getHandle().pickupItemStack = CraftItemStack.asNMSCopy(item);
}
@Override
public EntityArrow getHandle() {
return (EntityArrow) entity;