Consistently use 'mob head' terminology in the API

previously, we were sometimes using 'mob head' and other times 'skull', sometimes even within the same file.
This commit is contained in:
Dylan K. Taylor
2023-05-26 14:52:28 +01:00
parent edafe9d21f
commit bdb0ed0701
15 changed files with 107 additions and 107 deletions

View File

@ -0,0 +1,90 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block\tile;
use pocketmine\block\utils\MobHeadType;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\world\World;
/**
* @deprecated
* @see \pocketmine\block\MobHead
*/
class MobHead extends Spawnable{
private const TAG_SKULL_TYPE = "SkullType"; //TAG_Byte
private const TAG_ROT = "Rot"; //TAG_Byte
private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte
private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int
private MobHeadType $mobHeadType;
private int $rotation = 0;
public function __construct(World $world, Vector3 $pos){
$this->mobHeadType = MobHeadType::SKELETON();
parent::__construct($world, $pos);
}
public function readSaveData(CompoundTag $nbt) : void{
if(($skullTypeTag = $nbt->getTag(self::TAG_SKULL_TYPE)) instanceof ByteTag){
try{
$this->mobHeadType = MobHeadType::fromMagicNumber($skullTypeTag->getValue());
}catch(\InvalidArgumentException $e){
//bad data, drop it
}
}
$rotation = $nbt->getByte(self::TAG_ROT, 0);
if($rotation >= 0 && $rotation <= 15){
$this->rotation = $rotation;
}
}
protected function writeSaveData(CompoundTag $nbt) : void{
$nbt->setByte(self::TAG_SKULL_TYPE, $this->mobHeadType->getMagicNumber());
$nbt->setByte(self::TAG_ROT, $this->rotation);
}
public function setMobHeadType(MobHeadType $type) : void{
$this->mobHeadType = $type;
}
public function getMobHeadType() : MobHeadType{
return $this->mobHeadType;
}
public function getRotation() : int{
return $this->rotation;
}
public function setRotation(int $rotation) : void{
$this->rotation = $rotation;
}
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
$nbt->setByte(self::TAG_SKULL_TYPE, $this->mobHeadType->getMagicNumber());
$nbt->setByte(self::TAG_ROT, $this->rotation);
}
}