help me? With nbt tags pls it's important I'm new in nbt's setup: I want to a give a item with nbt the item: In /give command: "/give dislost skull:3 1 {MinionInformation:{MinionType:{ActionType:0,TargetID:56}}}" In code. BTW I tried it Code: PHP: use pocketmine\plugin\PluginBase;use pocketmine\item\Item;use pocketmine\nbt\tag\StringTag;use pocketmine\inventory\ShapedRecipe;class Main extends PluginBase{ public function onEnable(){ $dm = Item::get(Item::SKULL, 3, 1, {MinionInformation:{MinionType:{ActionType:0,TargetID:56}}}); $diamondminion = new ShapedRecipe(["XXX" "XYX" "XXX"], ["X" => Item::get(264, 0, 10), "Y" => Item::get(Item::WOODEN_PICKAXE)], [$dm]); $this->getServer()->getCraftingManager()->registerShapedRecipe($diamondminion); }}
Hmm...Just looking at the default /give command in pocketmine(https://github.com/pmmp/PocketMine-MP/blob/master/src/command/defaults/GiveCommand.php), it doesn't seem to support extra NBT tags after the item like vanilla Minecraft :/ Perhaps someone who's more experienced can help! Sorry for not being much of a help mate..
Check out this post on setting NBT tags. https://forums.pmmp.io/threads/how-do-you-properly-set-nbt.1182/ Here's another post that I don't think it's relevant. https://forums.pmmp.io/threads/item-nbt-tag-in-give-command.326/
Wait no, I'm wrong. PHP: if(isset($args[3])){ $data = implode(" ", array_slice($args, 3)); try{ $tags = JsonNbtParser::parseJson($data); }catch(NbtDataException $e){ $sender->sendMessage(new TranslationContainer("commands.give.tagError", [$e->getMessage()])); return true; } $item->setNamedTag($tags);} It does exist in pocketmine
PHP: /** @var Item $item */$nbt = $item->getNamedTag() ?? new CompoundTag("", []);$nbt->test = new StringTag("test", "hey");$item->setNamedTag($nbt); How do I set the nbt tag [{MinionInformation:{MinionType:{ActionType:0,TargetID:56}}}] In code bro.
Take a look at how alvin0319 did it! https://github.com/alvin0319/Custom...ader/item/properties/CustomItemProperties.php
Welcome to the Development forums! Maybe try figuring it out? I believe you can do it. You can search stuff in Google too, add `pmmp` at the end when searching for help.
Yes but all used config and jsonparser But see the full code on top I didn't maded config I maded one recipe only
This may be totally wrong. PHP: new CompoundTag("MinionInformation",[ new CompoundTag("MinionType",[ new IntTag("ActionType", 0), new IntTag("TargetID", 56) ])]);
It works but when I craft and move the crafted item it gone and ingredients get back to my inventory same thing with inventory close
Code: {MinionInformation:{MinionType:{ActionType:0,TargetID:56}}} That is json, of course it won't work. Write a function that decodes the string and returns nbt. Something like this: https://github.com/pmmp/NBT/blob/stable/src/JsonNbtParser.php
PHP: $dm = Item::get(Item::SKULL, 3, 1);$dm->getNamedTag()->setTag(new CompoundTag("MinionInformation" [ new CompoundTag("MinionType", [ new IntTag("ActionType", 0), new IntTag("TargetID", 56) ])]));
or PHP: $dm = Item::get(Item::SKULL, 3, 1, JsonNbtParser::parseJson("{MinionInformation:{MinionType:{ActionType:0,TargetID:56}}}"));