I know I have asked the community about this before, but I didn't quite understand it properly. (It is not your fault, it's just that my knowledge was very small at that time, and I didn't even know what to ask) PHP: Entity::createEntity("Snowball", $pos->getLevel()->getChunk($pos->x >> 4, $pos->z >> 4), $nbt)->spawnTo($player); This is how I have spawned a snowball. I am not sure how to use namedtag on it, and calling it later on so I can verify that it was created by a certain plugin. *Cough* Guns *Cough*
He is talking about namedtag, a.k.a. Named Binary Tag, a.k.a. NBT. NBT is basically a structure of data about an object in various parts of the game, e.g. objects in a level, objects in an inventory, etc. NBT is used by Minecraft as the universal data saving format (except chunks). Therefore, you can store any data you like within an NBT. NBT data types include the 4 common integer types, strings, lists and maps. A list is like the java.util.List in Java, and map is like the java.util.Map<String, *> in Java. Using suitable data types and suitable keys in a map, you can store data for a certain object in a level, such as a tile or an entity.
To be honest, I didn't even know what NBT really meant... I only knew that it was a way to store data and etc. So is it possible for you to help me out with this one? PHP: $nbt =new Compound("",["Pos" => new Enum("Pos",[new Double("", $frontPos->x),new Double("", $frontPos->y + 1),new Double("", $frontPos->z)]),"Motion" => new Enum("Motion",[new Double("", $dir->x),new Double("", $dir->y),new Double("", $dir->z)]),"Rotation" => new Enum("Rotation",[new Float("", 0),new Float("", 0)])]); I am not really sure how to add a data in the snowball, and getting it back...
Look at how Slapper stores commands. It is bad practice though. If the data are from a plugin, they should be saved on an independent compound field to avoid collision.
It took me a very long time going though Slapper code and doing lots of Trial & Error, but it doesn't really work for me. PHP: $snowball->namedtag->bullet = new String("bullet", "$type", "$damage"); So I guess I found out how to add a bit of data into an entity, but not really sure how get it back. For example, getting the string "bullet", or the "$type" it is currently storing.
PHP: $snowball->namedtag["bullet"] is one way, PHP: $snowball->namedtag->bullet->getValue() is another way.
So... Slapper uses bad practice? How would you connect to Compound tags together? PHP: $nbt =new Compound(/*BLAH*/); Then what?
I read the source code, and it created lots of different compounds to store the command. He said that putting lots of info into a single compound is a bad practice. Okay, I am seriously sorry about asking similar questions over and over, but I just cannot understand. I know you are trying your best to explain this simple NBT thing to this idiot (that's me, just in case anyone misinterprets me). So I would try to make this the last question I will make here: What exactly goes in here? PHP: new String(/*Here*/, /*and here*/) and how do you get the data back? (I tried to ask you this many times, but I didn't get the answer, or at least I didn't managed to get what you said there) I know I have already requested too much, but it would even better if you give me an example usage on these two.
Why is it a bad practice to put lots of info into a single compound? Of course, the data would be more tidy if you put the info into nested compounds. However, in plugins, it is advisable to put data into a same big compound (but different nested compounds inside) to avoid collision. Same reason as why not to use global variables.