-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateZombie.php
83 lines (73 loc) · 2.48 KB
/
CreateZombie.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* @name CreateZombie
* @author alvin0319
* @main alvin0319\CreateZombie
* @version 1.0.0
* @api 4.0.0
*/
namespace alvin0319;
use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\Player;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\scheduler\Task;
use pocketmine\level\Level;
use pocketmine\level\Position;
use pocketmine\item\Item;
use pocketmine\entity\Zombie;
use pocketmine\utils\Config;
//한글깨짐방지
class CreateZombie extends PluginBase implements Listener {
public function onEnable() : void{
$this->getServer()->getPluginManager()->registerEvents ($this, $this);
if (! $this->getServer()->isLevelGenerated("BossLevel")) $this->getServer()->generateLevel("BossLevel",null,"FLAT");
if (! $this->getServer()->isLevelLoaded("BossLevel")) $this->getServer()->loadLevel("BossLevel");
$this->getScheduler()->scheduleRepeatingTask (new class ($this) extends Task {
private $owner;
public function __construct(CreateZombie $owner) {
$this->owner = $owner;
}
public function getOwner() {
return $this->owner;
}
public function onRun(int $currentTick) {
$nbt = new CompoundTag('', [
'Pos' => new ListTag('Pos', [
new DoubleTag('', 253),
new DoubleTag('', 4),
new DoubleTag('', 253)
]),
'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(Entity::ZOMBIE, $this->owner->getServer()->getLevelByName("BossLevel"), $nbt);
$entity->setHealth(100);
$entity->spawnToAll();
$this->owner->getServer()->broadcastMessage ("§b§l[ Boss ] §f보스가 스폰되었습니다");
}
}, 2000);
}
public function entity(EntityDamageEvent $event){
if($event instanceof EntityDamageByEntityEvent){
$damager = $event->getDamager();
$entity = $event->getEntity();
if($damager instanceof Player){
$entity->attack(new EntityDamageEvent($damager, EntityDamageEvent::CAUSE_ENTITY_ATTACK, 1));
}
}
}
}