Setting NBT Tag on a block

Discussion in 'Development' started by minijaham, Dec 29, 2020.

  1. minijaham

    minijaham Zombie

    Messages:
    218
    GitHub:
    minijaham
    Hey, I was looking online to find how to set an NBT Tag on a block.

    I couldn't really find any resources, so here I am.

    My plan is to make some sort of LuckyBlock plugin which starts a timer to auto-break the lucky block once a player places a block that has a certain NBT tag on.

    I've noticed that custom names on a placed block seem to reset after the placement. That's why I was looking for another way
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    503
    You can create a custom tile and save it there
     
  3. OguzhanUmutlu

    OguzhanUmutlu Witch

    Messages:
    52
    GitHub:
    OguzhanUmutlu
    Here is it :)
    PHP:
    use pocketmine\metadata\MetadataValue;
    use 
    pocketmine\block\Block;

    Block::setMetadata(string $metadataKeyMetadataValue $newMetadataValue);
    Block::getMetadata(string $metadataKey);
    Block::hasMetadata(string $metadataKey); // returns bool
    Block::removeMetadata(string $metadataKeyPlugin $owningPlugin);
     
  4. minijaham

    minijaham Zombie

    Messages:
    218
    GitHub:
    minijaham
    Damn..I need to learn more PMMP :l Thanks for the reply!
     

Share This Page

  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.