Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom Item Name

Comments in 'Plugin Development' started by MrGenga, Oct 2, 2015.

  1. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    Hello again :D
    I not know, this code works or not, but I give answer for you, this code is good?
    PHP:
    public function CustomItemName(PlayerItemHeldEvent $event) {
    if(
    $event->getItem()->getId() == 1$event->getPlayer()->sendPopup("Stoney!");
    }
    Or...
    PHP:
    $item->setCustomName("Stoney"); //or setName? P.S. PM 1.6
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    in MCPE 0.11.0 use the first code but in 0.12.1 (PM 1.6) use setCustomName() method
    HotFireyDeath likes this.
  3. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    PHP:
    public function setCustomName(PlayerItemHeldEvent $event) {
    if(
    $event->getItem()->getId() == 1) {
    $event->getPlayer()->sendPopup("Rocky");
    // There you go :)
  4. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    Events it s the hooks, not function using in plugin
  5. Jaydenb1321
    Offline

    Jaydenb1321 New Member

    Joined:
    Aug 16, 2014
    Posts:
    45
    Minecraft User:
    ItzBulkDev
    You will have to make a task so it can show up for 3 second which is like 60 ticks
  6. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    Like this (?)
    PHP:
     public function onHeld(PlayerItemHeldEvent $event){
                    
    $player $event->getPlayer();
                    
    $item $event->getItem()->getId();
                      if(
    $item == 332) {
                       
    $item->setCustomName(TextFormat::YELLOW "Cool Name");
       }
    }
  7. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Yeah.
    TonyDroide likes this.
  8. Jaydenb1321
    Offline

    Jaydenb1321 New Member

    Joined:
    Aug 16, 2014
    Posts:
    45
    Minecraft User:
    ItzBulkDev
    If setCustomName was a method, that would be true
  9. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    ? xD
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Do it just once, e.g. when player joins or when player gets the item. Don't do it every time the player switches to that item.
    TonyDroide likes this.

Share This Page

Advertisement