-
-
Notifications
You must be signed in to change notification settings - Fork 316
PluginAPI / Add NamespacedKey
and PersistentDataContainer
#1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…te macro persistent_data that annotates the field that holds the PDC
…n of the FromPersistentDataType for any PersistentDataType that might be added in the future
…exists and pumpkin is running in debug mode
if let Some(living) = self.get_living_entity() { | ||
living.write_nbt(nbt).await; | ||
living.write_nbt(&mut compound.clone()).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't use clone here, make write_nbt take ownership so the caller has to clone, making it clearer when clones are happening
if let Ok(ns_key) = NamespacedKey::new(namespace, key) { | ||
let value = match tag { | ||
NbtTag::Byte(b) => PersistentDataType::Bool(*b != 0), | ||
NbtTag::Short(s) => PersistentDataType::I32(i32::from(*s)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is a short 32 bits here? you already have a U16 type defined above
#[macro_export] | ||
macro_rules! ns_key { | ||
($value:expr) => { | ||
match ::pumpkin::plugin::persistence::NamespacedKey::new(env!("CARGO_PKG_NAME"), $value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, get the macro to generate a literal instead of calling new()
The idea behind this is genius |
@tn-lorenz Conflicts are getting more and more and i don't understand if this is done or not because it is not marked as draft but there are many things missing looking at the Checkboxes, The last commit was also already a while ago |
@Snowiiii Well as I pointed out in the important block at the beginning (and more than once on discord), it is currently not possible to go further and test, as NBT Data is never read in some cases. At the time, I verified this by adding debug statements, but only the one corresponding to saving got printed, never the one for reading. |
Important
This PR relies on Entity saving to work (which I was under the impression it already does), so I'll mark this as merge ready until then
Description
This PR aims to add the covetted
PersitentDataContainer
feature to the Plugin API, but there are still some things I need to consider:Chunk
World
Entity
TileState
*Structure
*ItemMeta
GeneratedStructure
*Raid
*OfflinePlayer
ItemStack
(*) : These are probably impossible to implement right now, because Pumpkin doesn't handle them yet
Testing
Will be done by: