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

Block Name

Discussion in 'Development' started by StuckDexter, May 2, 2017.

  1. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    How can i set a id or name to a block?
    With metadata, when yes how?
     
  2. Lowkey

    Lowkey Slime

    Messages:
    94
    Please rephrase. To add an item to a player's inventory, the format is as such;

    PHP:
    /** @var Player $player */

    $player->getInventory()->addItem(Item::get(ID,META,COUNT);

    //Example? This is how you would add 3 diamond swords.

    $player->getInventory()->addItem(Item::get(276,0,3);
    //You can also use a variable for addItem() such as $item, but it must be defined correctly.
     
  3. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    But I want to do metadata on a block.
    It exist a file named BlockMetadataStore
    How can I set metadata to a block which i can place.
     
  4. Lowkey

    Lowkey Slime

    Messages:
    94
    With commands or code?
     
  5. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
  6. Lowkey

    Lowkey Slime

    Messages:
    94
    PHP:
    /** @var Player $player */

    $player->getInventory()->addItem(Block::get(ID,META,COUNT);
     
  7. Lowkey

    Lowkey Slime

    Messages:
    94
    To set the name use setCustomName and a variable for $item.
     
  8. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
  9. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
  10. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    But how can I set a name to a Block setCustomName only work for items
     
  11. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you meant when it's placed and re picked up?
     
  12. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    Not really i only want to set something (name or id or something else) that i can check if it is exact this block .
     
  13. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    transfer the NBT data on place and transfer it on break
     
  14. StuckDexter

    StuckDexter Silverfish

    Messages:
    24
    Oh nbt is very clever
    Thanks
     
  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.