mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Fix mob head crashes and drops, fix #221
This commit is contained in:
parent
0e10a149ef
commit
e85d6d134e
@ -29,6 +29,7 @@ use pocketmine\nbt\tag\CompoundTag;
|
|||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
use pocketmine\nbt\tag\StringTag;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
use pocketmine\tile\Skull as SkullTile;
|
||||||
use pocketmine\tile\Spawnable;
|
use pocketmine\tile\Spawnable;
|
||||||
use pocketmine\tile\Tile;
|
use pocketmine\tile\Tile;
|
||||||
|
|
||||||
@ -36,8 +37,6 @@ class MobHead extends Flowable{
|
|||||||
|
|
||||||
protected $id = self::MOB_HEAD_BLOCK;
|
protected $id = self::MOB_HEAD_BLOCK;
|
||||||
|
|
||||||
protected $type;
|
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
$this->meta = $meta;
|
$this->meta = $meta;
|
||||||
}
|
}
|
||||||
@ -89,7 +88,6 @@ class MobHead extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
parent::onUpdate($type);
|
|
||||||
$faces = [
|
$faces = [
|
||||||
1 => 0,
|
1 => 0,
|
||||||
2 => 3,
|
2 => 3,
|
||||||
@ -105,15 +103,16 @@ class MobHead extends Flowable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return parent::onUpdate($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($this->meta === 3){
|
if(($tile = $this->level->getTile($this)) instanceof SkullTile){
|
||||||
return [];
|
return [
|
||||||
|
[Item::MOB_HEAD, $tile->getType(), 1]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
return [
|
|
||||||
[Item::MOB_HEAD, $this->type, 1]
|
return [];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,6 +33,7 @@ class Skull extends Spawnable{
|
|||||||
const TYPE_ZOMBIE = 2;
|
const TYPE_ZOMBIE = 2;
|
||||||
const TYPE_HUMAN = 3;
|
const TYPE_HUMAN = 3;
|
||||||
const TYPE_CREEPER = 4;
|
const TYPE_CREEPER = 4;
|
||||||
|
const TYPE_DRAGON = 5;
|
||||||
|
|
||||||
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
public function __construct(Chunk $chunk, CompoundTag $nbt){
|
||||||
if(!isset($nbt->SkullType)){
|
if(!isset($nbt->SkullType)){
|
||||||
@ -44,13 +45,9 @@ class Skull extends Spawnable{
|
|||||||
parent::__construct($chunk, $nbt);
|
parent::__construct($chunk, $nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setType($type){
|
public function setType(int $type){
|
||||||
if($type >= 0 && $type <= 4){
|
$this->namedtag->SkullType = new ByteTag("SkullType", $type);
|
||||||
$this->namedtag->SkullType = new ByteTag("SkullType", $type);
|
$this->onChanged();
|
||||||
$this->onChanged();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType(){
|
public function getType(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user