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

Spawn a mob

Comments in 'Plugin Development' started by Legoboy0215, Jul 24, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How do you spawn a mob with code? I asked @BalAnce but I want more info.
    jojoe77777 likes this.
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I spawned a Zombie with code and it worked. But I tried a Creeper then it crashed. Why?
  3. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    what was the code you used for zombie
  4. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    And what was the crash message?
    BalAnce likes this.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Crash was spawnToAll on null. When it was a zombie, everything was ok lol.
  6. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    code?
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Same as slapper:
    PHP:
            $nbt =  new Compound("",[
                new 
    Enum("Pos",[
                    new 
    Double("",$x),
                    new 
    Double("",$y),
                    new 
    Double("",$z),
                    ]),
                new 
    Enum("Motion", [
                    new 
    Double("",0),
                    new 
    Double("",0),
                    new 
    Double("",0),
                    ]),
                new 
    Enum("Rotation", [
                    new 
    Float("",$yaw),
                    new 
    Float("",$pitch),
                    ])
                ]);
            
    $entity Entity::createEntity($mobname$level->getChunk($x>>4$z>>4), $nbt);
            
    $entity->spawnToAll();
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Every var is defined and no problems.
    Avatar.png
  9. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    You might need to set fuse for creeper.. Not sure.

Share This Page

Advertisement