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

get Entity

Comments in 'Plugin Development' started by Creeperface, Jun 20, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    when i create entity so how can i get this entity sometimes later?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Save the Entity object. But you can't get it back when the chunk is unloaded.
    Creeperface likes this.
  3. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    its not perfect and with POSTWORLD and "onEnable" it doesnt work but

    set a public var.
    set this to 0 "on enable" (because onenable dont let u show all world entites dont know why)
    on first player join
    PHP:

    public function onJoin(PlayerJoinEvent $event)
            {   
                if(
    $this->var == 0//that the code only do it once
                
    {
                
    $entities $this->getServer()->getLevelbyName("***")->getEntities(); // u can also use get default world
              
                
    foreach($entities as $human)
                {           
                    if(
    strpos(strtolower($human),"human") !==false//check if the entitiy is a human entity
                    
    {
                        
    //do something
                    
    }
                }
                
    $this->var 1;
                }
            }
    if u creater only human entities u can get thgem all and do something with them.
    Creeperface likes this.
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    thx :)
    Xenturio likes this.
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    hm when i have any entities on server so sometimes there is a bug when i join MCPE crashes always. i solve it i teleport me to another place from console but why it happens? (i have the newest MCPE version)
  6. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    it is in all PM versions 1.5
  8. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio

Share This Page

Advertisement