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

Spawn Entities (Mimicking Vanilla)

Discussion in 'Development' started by Magicode, Dec 9, 2016.

  1. Magicode

    Magicode Baby Zombie

    Messages:
    183
    GitHub:
    magicode1
    Hi,

    I was wondering how I could get my plugin to spawn mobs (I know there is no AI, the plugin I am working on one already has the AI done, we just need it to spawn mobs) in random areas around the world, like what normally occurs in nature in Vanilla PE.

    If it's not too much trouble, I would also like to know how to spawn Monsters at night.

    Thanks
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Nope IM never had a MobAI I think, but G***** had (and has?)
     
  3. Magicode

    Magicode Baby Zombie

    Messages:
    183
    GitHub:
    magicode1
    No, they removed it.
     
    HimbeersaftLP likes this.
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    I think I know how we can do it @Magicode. Let's dicuss this on the gitter chat :)
     
  5. Magicode

    Magicode Baby Zombie

    Messages:
    183
    GitHub:
    magicode1
    Ok Be Right There :)
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Just to make sure, you're asking for the algorithm for random mobs right?
    As far as I remember, it is to randomly pick a position in a chunk, check its light level and other conditions, spawn mob there if applicable, or pick another position if not.
     
    HimbeersaftLP likes this.
  7. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    I'm spawning entities around players, using those conditions yep.
     
    HimbeersaftLP likes this.
  8. archie426

    archie426 Baby Zombie

    Messages:
    130
    GitHub:
    archie426
    Really?
     
  9. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Yep, IM had really no improvements except a buggy Redstone implementation and some useless features (no offense to anyone who helped in the development of it)

    Edit: Damn, I'm going off-topic again...
     
    Last edited: Dec 10, 2016
    archie426 likes this.
  10. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    http://minecraft.gamepedia.com/Spawn#Natural_generation
    Note that some of the detailed information are customized in pocketmine.yml
    Whether they do or not it has no relevance to this thread if you don't accurately point out how they do so.
     
    HimbeersaftLP and Sandertv like this.
  11. archie426

    archie426 Baby Zombie

    Messages:
    130
    GitHub:
    archie426
    Oh, sorry
     
  12. Skullex

    Skullex Spider

    Messages:
    13
    GitHub:
    skull3x
    Instead of randomly spawning mobs anywhere around a world, I would rather spawn them in random positions around the player. I experienced issues spawning mobs in areas where no chunks were loaded yet.

    "If it's not too much trouble, I would also like to know how to spawn Monsters at night."

    PHP:
    $hostile = [
    [
    "Zombie""Creeper""Skeleton""Spider""Enderman""ZombieVillager"]
    ];
    $time $player->getLevel()->getTime() % Level::TIME_FULL;
    $night = ($time >= Level::TIME_NIGHT && $time Level::TIME_SUNRISE);
    if(
    $player instanceof Player && $night){
          
    Entity::createEntity($hostile$pos);
    }
    //removed Entity::createEntity($hostile[mt_rand(0, 1)][mt_rand(0, 10)], $pos);
     
    Last edited: Dec 11, 2016
  13. Primus

    Primus Zombie Pigman

    Messages:
    749
     
  14. Skullex

    Skullex Spider

    Messages:
    13
    GitHub:
    skull3x
    That just gave me an idea
     
  15. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Don't worry we got this covered already, thanks for your help :)
     
    Skullex and HimbeersaftLP like this.
  16. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Undefined index: $hostile[1]
     
  17. Skullex

    Skullex Spider

    Messages:
    13
    GitHub:
    skull3x
    Yeah, I noticed that after I tested it. Thanks for the clarification :)
     
  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.