1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Questions with nbt and help

Discussion in 'Development' started by Ayush, Jun 14, 2021.

  1. Ayush

    Ayush Witch

    Messages:
    62
    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::SKULL31, {MinionInformation:{MinionType:{ActionType:0,TargetID:56}}});

          
    $diamondminion = new ShapedRecipe(["XXX" "XYX" "XXX"], ["X" => Item::get(264010), "Y" => Item::get(Item::WOODEN_PICKAXE)], [$dm]);
            
           
    $this->getServer()->getCraftingManager()->registerShapedRecipe($diamondminion);
         }
    }
     
  2. Ayush

    Ayush Witch

    Messages:
    62
    Maybe someone help me fast
     
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Ayush likes this.
  4. Axon

    Axon Zombie

    Messages:
    276
    Agent likes this.
  5. Ayush

    Ayush Witch

    Messages:
    62
  6. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Wait no, I'm wrong.
    PHP:
    if(isset($args[3])){
         
    $data implode(" "array_slice($args3));
         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
     
    Ayush likes this.
  7. Ayush

    Ayush Witch

    Messages:
    62
    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.
     
  8. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
  9. Ayush

    Ayush Witch

    Messages:
    62
    See my code first and help:
    PHP:
     $item Item::get(Item::SKULL31);
     
  10. Axon

    Axon Zombie

    Messages:
    276
    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.
     
  11. Ayush

    Ayush Witch

    Messages:
    62
    Lol I did that already
     
  12. Axon

    Axon Zombie

    Messages:
    276
    And did you read the results? Hmm
     
    Agent and Ayush like this.
  13. Ayush

    Ayush Witch

    Messages:
    62
    Yes but all used config and jsonparser
    But see the full code on top I didn't maded config I maded one recipe only
     
  14. Axon

    Axon Zombie

    Messages:
    276
    This may be totally wrong.
    PHP:
    new CompoundTag("MinionInformation",[
        new 
    CompoundTag("MinionType",[
            new 
    IntTag("ActionType"0),
            new 
    IntTag("TargetID"56)
        ]
    )]
    );
     
    Agent and Ayush like this.
  15. Ayush

    Ayush Witch

    Messages:
    62
    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
     
  16. Primus

    Primus Zombie Pigman

    Messages:
    749
    minijaham, Ayush and Axon like this.
  17. Mcbeany

    Mcbeany Spider Jockey

    Messages:
    33
    GitHub:
    mcbeany
    PHP:
    $dm Item::get(Item::SKULL31);
    $dm->getNamedTag()->setTag(new CompoundTag("MinionInformation" [
      new 
    CompoundTag("MinionType", [
        new 
    IntTag("ActionType"0),
        new 
    IntTag("TargetID"56)
      ])
    ]));
     
    Ayush likes this.
  18. Mcbeany

    Mcbeany Spider Jockey

    Messages:
    33
    GitHub:
    mcbeany
    or
    PHP:
    $dm Item::get(Item::SKULL31JsonNbtParser::parseJson("{MinionInformation:{MinionType:{ActionType:0,TargetID:56}}}"));
     
    Ayush likes this.
  19. Ayush

    Ayush Witch

    Messages:
    62
    I maded but when I craft that it cancels the crafting and return? How I fix that?
     
  20. Ayush

    Ayush Witch

    Messages:
    62
    This is easy!
     
    Mcbeany likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.