Skip to content
This repository was archived by the owner on Jul 11, 2018. It is now read-only.

Commit cc76936

Browse files
committed
Mobsters-0.4.0
1 parent d84af40 commit cc76936

18 files changed

+153
-299
lines changed

Mobsters/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Documentation
2424
Changes
2525
-------
2626

27+
* 0.4.0 : Updated for PM1.5 (API: 1.12.0)
2728
* 0.3.0 : Fire up Motion events
2829
* 0.2.0 : Bug fixes
2930
* 0.1.0 : First release

Mobsters/plugin.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Mobsters
2-
version: 0.3.0
3-
api: [1.6.0]
2+
version: 0.4.0
3+
api: [1.12.0]
44
load: STARTUP
55
main: aliuly\mobsters\Main
66

Mobsters/src/aliuly/mobsters/Main.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public function onEnable(){
3535
Cow::NETWORK_ID, Mooshroom::NETWORK_ID, Wolf::NETWORK_ID,
3636
Enderman::NETWORK_ID, Spider::NETWORK_ID, Skeleton::NETWORK_ID,
3737
PigZombie::NETWORK_ID, Creeper::NETWORK_ID, Slime::NETWORK_ID,
38-
Silverfish::NETWORK_ID, Villager::NETWORK_ID, Zombie::NETWORK_ID
38+
Silverfish::NETWORK_ID
3939
] as $type){
40-
Block::$creative[] = [ Item::SPAWN_EGG, $type ];
40+
Item::addCreativeItem(Item::get(Item::SPAWN_EGG, $type));
4141
}
4242
Entity::registerEntity(Chicken::class);
4343
Entity::registerEntity(Pig::class);

Mobsters/src/aliuly/mobsters/idiots/Chicken.php

+9-21
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
use pocketmine\network\protocol\AddEntityPacket;
7+
use pocketmine\network\Network;
78
use pocketmine\Player;
89
use pocketmine\entity\Animal;
910

@@ -34,36 +35,23 @@ public function getName(){
3435
}
3536

3637
public function spawnTo(Player $player){
37-
$pk = new AddMobPacket();
38+
39+
$pk = new AddEntityPacket();
3840
$pk->eid = $this->getId();
3941
$pk->type = self::NETWORK_ID;
4042
$pk->x = $this->x;
4143
$pk->y = $this->y;
4244
$pk->z = $this->z;
45+
$pk->speedX = $this->motionX;
46+
$pk->speedY = $this->motionY;
47+
$pk->speedZ = $this->motionZ;
4348
$pk->yaw = $this->yaw;
4449
$pk->pitch = $this->pitch;
45-
$pk->metadata = $this->getData();
46-
$player->dataPacket($pk);
47-
48-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
49-
50+
$pk->metadata = $this->dataProperties;
51+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
5052
parent::spawnTo($player);
5153
}
5254

53-
public function getData(){ //TODO
54-
$flags = 0;
55-
$flags |= $this->fireTicks > 0 ? 1 : 0;
56-
//$flags |= ($this->crouched === true ? 0b10:0) << 1;
57-
//$flags |= ($this->inAction === true ? 0b10000:0);
58-
$d = [
59-
0 => ["type" => 0, "value" => $flags],
60-
1 => ["type" => 1, "value" => $this->airTicks],
61-
16 => ["type" => 0, "value" => 0],
62-
17 => ["type" => 6, "value" => [0, 0, 0]],
63-
];
64-
65-
return $d;
66-
}
6755

6856
public function getDrops(){
6957
$drops = [

Mobsters/src/aliuly/mobsters/idiots/Cow.php

+11-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
use pocketmine\network\protocol\AddEntityPacket;
7+
use pocketmine\network\Network;
8+
79
use pocketmine\Player;
810
use pocketmine\entity\Animal;
911

@@ -20,37 +22,23 @@ public function getName(){
2022
}
2123

2224
public function spawnTo(Player $player){
23-
$pk = new AddMobPacket();
25+
26+
$pk = new AddEntityPacket();
2427
$pk->eid = $this->getId();
2528
$pk->type = self::NETWORK_ID;
2629
$pk->x = $this->x;
2730
$pk->y = $this->y;
2831
$pk->z = $this->z;
32+
$pk->speedX = $this->motionX;
33+
$pk->speedY = $this->motionY;
34+
$pk->speedZ = $this->motionZ;
2935
$pk->yaw = $this->yaw;
3036
$pk->pitch = $this->pitch;
31-
$pk->metadata = $this->getData();
32-
$player->dataPacket($pk);
33-
34-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
35-
37+
$pk->metadata = $this->dataProperties;
38+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
3639
parent::spawnTo($player);
3740
}
38-
39-
public function getData(){ //TODO
40-
$flags = 0;
41-
$flags |= $this->fireTicks > 0 ? 1 : 0;
42-
//$flags |= ($this->crouched === true ? 0b10:0) << 1;
43-
//$flags |= ($this->inAction === true ? 0b10000:0);
44-
$d = [
45-
0 => ["type" => 0, "value" => $flags],
46-
1 => ["type" => 1, "value" => $this->airTicks],
47-
16 => ["type" => 0, "value" => 0],
48-
17 => ["type" => 6, "value" => [0, 0, 0]],
49-
];
50-
51-
return $d;
52-
}
53-
41+
5442
public function getDrops(){
5543
$drops = [ Item::get($this->fireTicks > 0 ? Item::COOKED_BEEF : Item::RAW_BEEF, 0, mt_rand(1,3)) ];
5644
$leather = mt_rand(0,2);

Mobsters/src/aliuly/mobsters/idiots/Creeper.php

+10-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
use pocketmine\network\protocol\AddEntityPacket;
7+
use pocketmine\network\Network;
8+
79
use pocketmine\Player;
810
use pocketmine\entity\Monster;
911
use pocketmine\entity\Explosive;
@@ -21,37 +23,23 @@ public function getName(){
2123
}
2224

2325
public function spawnTo(Player $player){
24-
$pk = new AddMobPacket();
26+
27+
$pk = new AddEntityPacket();
2528
$pk->eid = $this->getId();
2629
$pk->type = self::NETWORK_ID;
2730
$pk->x = $this->x;
2831
$pk->y = $this->y;
2932
$pk->z = $this->z;
33+
$pk->speedX = $this->motionX;
34+
$pk->speedY = $this->motionY;
35+
$pk->speedZ = $this->motionZ;
3036
$pk->yaw = $this->yaw;
3137
$pk->pitch = $this->pitch;
32-
$pk->metadata = $this->getData();
33-
$player->dataPacket($pk);
34-
35-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
36-
38+
$pk->metadata = $this->dataProperties;
39+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
3740
parent::spawnTo($player);
3841
}
3942

40-
public function getData(){ //TODO
41-
$flags = 0;
42-
$flags |= $this->fireTicks > 0 ? 1 : 0;
43-
//$flags |= ($this->crouched === true ? 0b10:0) << 1;
44-
//$flags |= ($this->inAction === true ? 0b10000:0);
45-
$d = [
46-
0 => ["type" => 0, "value" => $flags],
47-
1 => ["type" => 1, "value" => $this->airTicks],
48-
16 => ["type" => 0, "value" => 0],
49-
17 => ["type" => 6, "value" => [0, 0, 0]],
50-
];
51-
52-
return $d;
53-
}
54-
5543
public function getDrops(){
5644
$drops = [];
5745
$rand = mt_rand(0,2);

Mobsters/src/aliuly/mobsters/idiots/Enderman.php

+9-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
use pocketmine\network\protocol\AddEntityPacket;
7+
use pocketmine\network\Network;
78
use pocketmine\Player;
89
use pocketmine\entity\Monster;
910
use pocketmine\inventory\InventoryHolder;
@@ -21,37 +22,23 @@ public function getName(){
2122
}
2223

2324
public function spawnTo(Player $player){
24-
$pk = new AddMobPacket();
25+
26+
$pk = new AddEntityPacket();
2527
$pk->eid = $this->getId();
2628
$pk->type = self::NETWORK_ID;
2729
$pk->x = $this->x;
2830
$pk->y = $this->y;
2931
$pk->z = $this->z;
32+
$pk->speedX = $this->motionX;
33+
$pk->speedY = $this->motionY;
34+
$pk->speedZ = $this->motionZ;
3035
$pk->yaw = $this->yaw;
3136
$pk->pitch = $this->pitch;
32-
$pk->metadata = $this->getData();
33-
$player->dataPacket($pk);
34-
35-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
36-
37+
$pk->metadata = $this->dataProperties;
38+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
3739
parent::spawnTo($player);
3840
}
3941

40-
public function getData(){ //TODO
41-
$flags = 0;
42-
$flags |= $this->fireTicks > 0 ? 1 : 0;
43-
//$flags |= ($this->crouched === true ? 0b10:0) << 1;
44-
//$flags |= ($this->inAction === true ? 0b10000:0);
45-
$d = [
46-
0 => ["type" => 0, "value" => $flags],
47-
1 => ["type" => 1, "value" => $this->airTicks],
48-
16 => ["type" => 0, "value" => 0],
49-
17 => ["type" => 6, "value" => [0, 0, 0]],
50-
];
51-
52-
return $d;
53-
}
54-
5542
public function getDrops(){
5643
return [];
5744
}

Mobsters/src/aliuly/mobsters/idiots/Mooshroom.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
use pocketmine\network\protocol\AddEntityPacket;
7+
use pocketmine\network\Network;
78
use pocketmine\Player;
89
use pocketmine\entity\Animal;
910

@@ -16,21 +17,20 @@ public function getName(){
1617
}
1718

1819
public function spawnTo(Player $player){
19-
//echo __METHOD__.",".__LINE__."\n";
20-
$pk = new AddMobPacket();
20+
21+
$pk = new AddEntityPacket();
2122
$pk->eid = $this->getId();
2223
$pk->type = self::NETWORK_ID;
2324
$pk->x = $this->x;
2425
$pk->y = $this->y;
2526
$pk->z = $this->z;
27+
$pk->speedX = $this->motionX;
28+
$pk->speedY = $this->motionY;
29+
$pk->speedZ = $this->motionZ;
2630
$pk->yaw = $this->yaw;
2731
$pk->pitch = $this->pitch;
28-
$pk->metadata = $this->getData();
29-
$player->dataPacket($pk);
30-
31-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
32-
33-
//parent::spawnTo($player);
32+
$pk->metadata = $this->dataProperties;
33+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
3434
Animal::spawnTo($player);
3535
}
3636
}

Mobsters/src/aliuly/mobsters/idiots/Pig.php

+9-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
use pocketmine\network\protocol\AddEntityPacket;
7+
use pocketmine\network\Network;
78
use pocketmine\Player;
89
use pocketmine\entity\Rideable;
910
use pocketmine\entity\Animal;
@@ -30,37 +31,22 @@ public function getName(){
3031
public static $mindist = 3;
3132

3233
public function spawnTo(Player $player){
33-
$pk = new AddMobPacket();
34+
35+
$pk = new AddEntityPacket();
3436
$pk->eid = $this->getId();
3537
$pk->type = self::NETWORK_ID;
3638
$pk->x = $this->x;
3739
$pk->y = $this->y;
3840
$pk->z = $this->z;
41+
$pk->speedX = $this->motionX;
42+
$pk->speedY = $this->motionY;
43+
$pk->speedZ = $this->motionZ;
3944
$pk->yaw = $this->yaw;
4045
$pk->pitch = $this->pitch;
41-
$pk->metadata = $this->getData();
42-
$player->dataPacket($pk);
43-
44-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
45-
46+
$pk->metadata = $this->dataProperties;
47+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
4648
parent::spawnTo($player);
4749
}
48-
49-
public function getData(){ //TODO
50-
$flags = 0;
51-
$flags |= $this->fireTicks > 0 ? 1 : 0;
52-
//$flags |= ($this->crouched === true ? 0b10:0) << 1;
53-
//$flags |= ($this->inAction === true ? 0b10000:0);
54-
$d = [
55-
0 => ["type" => 0, "value" => $flags],
56-
1 => ["type" => 1, "value" => $this->airTicks],
57-
16 => ["type" => 0, "value" => 0],
58-
17 => ["type" => 6, "value" => [0, 0, 0]],
59-
];
60-
61-
return $d;
62-
}
63-
6450
public function getDrops(){
6551
return [Item::get($this->fireTicks > 0 ? Item::COOKED_PORKCHOP : Item::RAW_PORKCHOP, 0, mt_rand(1, 3))];
6652
}

Mobsters/src/aliuly/mobsters/idiots/PigZombie.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use pocketmine\item\Item;
55
use pocketmine\event\entity\EntityDamageByEntityEvent;
6-
use pocketmine\network\protocol\AddMobPacket;
6+
7+
use pocketmine\network\protocol\AddEntityPacket;
8+
use pocketmine\network\Network;
79
use pocketmine\Player;
810
use pocketmine\entity\Zombie;
911
use pocketmine\entity\Monster;
@@ -14,21 +16,21 @@ class PigZombie extends Zombie{
1416
public function getName(){
1517
return "PigZombie";
1618
}
17-
1819
public function spawnTo(Player $player){
19-
$pk = new AddMobPacket();
20+
21+
$pk = new AddEntityPacket();
2022
$pk->eid = $this->getId();
2123
$pk->type = self::NETWORK_ID;
2224
$pk->x = $this->x;
2325
$pk->y = $this->y;
2426
$pk->z = $this->z;
27+
$pk->speedX = $this->motionX;
28+
$pk->speedY = $this->motionY;
29+
$pk->speedZ = $this->motionZ;
2530
$pk->yaw = $this->yaw;
2631
$pk->pitch = $this->pitch;
27-
$pk->metadata = $this->getData();
28-
$player->dataPacket($pk);
29-
30-
$player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ);
31-
32+
$pk->metadata = $this->dataProperties;
33+
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
3234
Monster::spawnTo($player);
3335
}
3436
}

0 commit comments

Comments
 (0)