Hi! Unfortunately i don't have any codes on my hand now. I'd like to learn on how to spawn any type of pets which follows you? Please advice! Thanks
Then your going to be going up a steep learning curve... First you need to know how to create your own custom entity (preferably by extending one of PocketMine's entity classes) then you need to write the AI into this new entities Entity::onUpdate() method. After you've got your AI done the rest should be pretty simple, add way(s) for players to get their pets! Spoiler There is nothing wrong with copying code, so long as you understand it. What's the point of reinventing the wheel just for the sake of learning? Wouldn't it be wiser to simply study it instead?
Ok so you prefer learning. A big thumbs up for you Here's a basic guide for you. Create a new class extends Entity (or maybe Living class, depends on what you need) (Let's assume the new class called Pet) Implement AI to follow owner into Pet class (You can do it by passing Player class into Pet class, and every tick check movements of Player and move the Pet) Register Pet class with your plugin (Entity::registerEntity()) When Player joined or executed command /pet or whatever (depends on your flavour) spawn Entity as usual using PocketMine API with your Pet class done Everyone has thier own way to learn. Someone do it by copying code, someone do it by other way. There's no right or wrong as long as you achieve your aim, to learn. P/S: The guide i provided is just my way of spawning Pet. There are still a lot of different ways to do it.
yes, go learn it by reading it, sometimes you cant just get someone to teach you stuff and it relies on you to learn for yourself
Here's how: PHP: $pos = Position::class;$nbt = new CompoundTag('', [ 'Pos' => new ListTag('Pos', [ new DoubleTag('', $pos->x), new DoubleTag('', $pos->y), new DoubleTag('', $pos->z) ]), 'Motion' => new ListTag('Motion', [ new DoubleTag('', 0), new DoubleTag('', 0), new DoubleTag('', 0) ]), 'Rotation' => new ListTag('Rotation', [ new FloatTag('', lcg_value() * 360), new FloatTag('', 0) ]),]);$entity = Entity::createEntity("Zombie", $pos->getLevel(), $nbt);$entity->setNameTag("you");$entity->spawnToAll(); You can use setNameTagVisible to make sure everyone can see it's name. Spoiler If I'm correct, you actually meant: "How to spawn an entity and program it to follow a player?". But that would be two questions. One question per thread please.
For following the player, I'll be releasing a work in progress new pet plugin this afternoon. I'm currently in school, (I shouldn't even be typing this...) but I'll notify you when it's public.