-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFloatingText.php
60 lines (40 loc) · 1.56 KB
/
FloatingText.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
<?php
namespace FloatingText;
use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\utils\Config;
use pocketmine\entity\Entity;
use pocketmine\math\Vector3;
use pocketmine\item\Item;
use pocketmine\utils\UUID;
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
use pocketmine\event\player\PlayerJoinEvent;
class FloatingText extends PluginBase implements Listener {
public function onEnable(){
$x = (float) 128; //浮き文字が表示される x座標
$y = (float) 8; //浮き文字が表示される y座標
$z = (float) 128; //浮き文字が表示される z座標
$eid = Entity::$entityCount++; //EntityID (固定が良い)
$name = "FloatingText"; //浮き文字
$pos = new Vector3($x, $y, $z); //vector3 オブジェクト
$pk = new AddPlayerPacket();
$pk->uuid = UUID::fromRandom();
$pk->username = $name;
$pk->entityUniqueId = $eid;
$pk->entityRuntimeId = $eid;
$pk->position = $pos;
$pk->item = Item::get(Item::AIR); //持ち物は"なし"なので AIR
$flags =
1 << Entity::DATA_FLAG_CAN_SHOW_NAMETAG |
1 << Entity::DATA_FLAG_ALWAYS_SHOW_NAMETAG |
1 << Entity::DATA_FLAG_IMMOBILE;
$pk->metadata = [
Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, $flags],
Entity::DATA_SCALE => [Entity::DATA_TYPE_FLOAT, 0],
];
$this->FloatInfo = $pk;
}
public function onJoin(PlayerJoinEvent $event){
$event->getPlayer()->dataPacket($this->FloatInfo); //Player参加時に浮き文字(Packet)を送信
}
}