PDC & Items
The Persistent Data Container (PDC) allows plugins to store custom NBT data safely on Entities, Chunks, and ItemStacks without risking corruption during Vanilla serialization.
1. Modifying ItemStacks
use potato_api::item::{ItemStack, Material};
use potato_api::text::Component;
let mut sword = ItemStack::new(Material::DiamondSword, 1);
let meta = sword.item_meta_mut();
meta.set_display_name(Component::text("§cExcalibur"));
meta.set_custom_model_data(Some(105));2. Using the Persistent Data Container
use potato_api::pdc::{NamespacedKey, PersistentDataType};
let key = NamespacedKey::new("my_plugin", "kills");
// Writing to PDC
entity.persistent_data_container().set(&key, PersistentDataType::Integer, 42);
// Reading from PDC
if let Some(kills) = entity.persistent_data_container().get(&key, PersistentDataType::Integer) {
println!("Entity has {} kills", kills);
}