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

[1.5] Spawning a Human NPC

Comments in 'Plugin Development' started by Samueljh1, Apr 24, 2015.

  1. Kiosek
    Offline

    Kiosek New Member

    Joined:
    Jun 17, 2014
    Posts:
    34
    Minecraft User:
    Cecil107
    Skus todle
    PHP:
    public static function getNBT(Position $pos$name){
        
    $pos = new Location($pos->x$pos->y$pos->z0.00.0$pos->getLevel());
        
    $nbt = new Compound;
        
    $nbt->NameTag = new String($name);
        
    $nbt->Pos = new Enum("Pos", [
                new 
    Double(0$pos->x),
                new 
    Double(1$pos->y),
                new 
    Double(2$pos->z),
        ]);
        
    $nbt->Motion = new Enum("Motion", [
                new 
    Double(00.0),
                new 
    Double(10.0),
                new 
    Double(20.0),
        ]);
        
    $nbt->Rotation = new Enum("Rotation", [
                new 
    Float(0$pos->yaw),
                new 
    Float(1$pos->pitch)
        ]);
        
    $nbt->FallDistance = new Float("FallDistance"0.0);
        
    $nbt->Fire = new Short("Fire"0);
        
    $nbt->Air = new Short("Air"0);
        
    //$nbt->OnGround = new Byte("OnGround", 1);
        //$nbt->Invulnerable = new Byte("Invulnerable", 1);
        
    $nbt->Health = new Short("Health"20);
        
    $nbt->Inventory = new Enum("Inventory", []);
        
    $nbt->Skin = new Compound("Skin", [

    "Data" => new String("Data"str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2)),
    "Slim" => new Byte(0)

    ]);
        return 
    $nbt;
        }

    public function 
    spawnNPC(){
            
    $level $this->getServer()->getLevelByName("flat");
            
    $entity Entity::createEntity("Human"$level->getChunk(13 >> 4, -16 >> 4), $this->getNBT(new Position(136, -16), "CreeperFace"));
            
    $entity->spawnToAll();
            
    $entity->setSkin ("$player->getSkinData()")
    }
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    ale potom bych musel to dát pro každého hráče zvlášť když se připojí ne?
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    a taky hráči by pak viděli svůj skin na těch NPC že?
    aha já tam mám static function a volám to normálně možná proto :D
  4. Kiosek
    Offline

    Kiosek New Member

    Joined:
    Jun 17, 2014
    Posts:
    34
    Minecraft User:
    Cecil107
    to nevadi ne jo a sem Cecil107
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    ok a tobě to funguje zkoušel jsi to?
  6. Kiosek
    Offline

    Kiosek New Member

    Joined:
    Jun 17, 2014
    Posts:
    34
    Minecraft User:
    Cecil107
    nn skusim
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    tak nový kód trochu upravený ale furt to píše že HUMAN MUST HAVE A VALID SKIN SET
    zkusím ještě ten skin hráče

    PHP:
    public static function getNBT(Position $pos$name){
        
    $pos = new Location($pos->x$pos->y$pos->z0.00.0$pos->level);
        
    $nbt = new Compound;
        
    $nbt->NameTag = new String($name);
        
    $nbt->Pos = new Enum("Pos", [
                new 
    Double(0$pos->x),
                new 
    Double(1$pos->y),
                new 
    Double(2$pos->z),
        ]);
        
    $nbt->Motion = new Enum("Motion", [
                new 
    Double(00.0),
                new 
    Double(10.0),
                new 
    Double(20.0),
        ]);
        
    $nbt->Rotation = new Enum("Rotation", [
                new 
    Float(0$pos->yaw),
                new 
    Float(1$pos->pitch)
        ]);
        
    $nbt->FallDistance = new Float("FallDistance"0.0);
        
    $nbt->Fire = new Short("Fire"0);
        
    $nbt->Air = new Short("Air"0);
        
    $nbt->OnGround = new Byte("OnGround"1);
        
    $nbt->Invulnerable = new Byte("Invulnerable"1);
        
    $nbt->Health = new Short("Health"20);
        
    $nbt->Inventory = new Enum("Inventory", []);
        
    $nbt->Skin = new Compound("Skin", [

    "Data" => new String("Data"str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2)),
    "Slim" => new Byte("Slim"0)

    ]);
        return 
    $nbt;
        }
      
        public function 
    spawnNPC(){
            
    $level $this->getServer()->getLevelByName("flat");
            
    $entity Entity::createEntity("Human"$level->getChunk(13 >> 4, -16 >> 4), self::getNBT(new Position(136, -16$level), "CreeperFace"));
            
    $entity->spawnToAll();
            
    $entity->setSkin(str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\xFF"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2) . str_repeat("\x80"32*16*2), false);
        }
    PEMapModder likes this.
  8. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    no still doesn´t work :(
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The last line, why put it after spawnToAll?
    Kiosek likes this.
  10. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    I tried Before too but problem is i should spawn entity only once Because server crashed without plugin too so entity still was spawned in map
  11. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    no one has an answer? have same prob -> all the time i get invalid skin...
  12. CreeperFace001
    Offline

    CreeperFace001 Banned

    Joined:
    Jun 29, 2015
    Posts:
    11
    Minecraft User:
    Creeperface001
    maybe because mob with ivalid skin is still in the world
    PEMapModder likes this.
  13. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    no, u can delete the invalid entities with ->close(); iam do it so if i have an invalid human in world.
    but i cant get fix the error...if i create a new one
  14. GMR_Alexander101
    Offline

    GMR_Alexander101 New Member

    Joined:
    Nov 20, 2015
    Posts:
    1
    Minecraft User:
    GMR_Alexander101
    Were can i download this NPC Pluggin i relay wanted for my new server thats comming soon i already made nuketown and other pvp maps plz reply giving me a download!
  15. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    The only NPC plugin on the forums is Slapper.
    Last edited: Jan 8, 2016
    Vaivez66 and Legoboy0215 like this.
  16. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Hows this working for 1.6?

Share This Page

Advertisement