mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-26 04:43:45 +00:00
Added more typehints to Tile namespace
This commit is contained in:
parent
45b003ac2e
commit
0b1a9ba062
@ -49,7 +49,7 @@ class Bed extends Spawnable{
|
||||
$this->onChanged();
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->color = $this->namedtag->color;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
public function close(){
|
||||
public function close() : void{
|
||||
if($this->closed === false){
|
||||
$this->inventory->removeAllViewers(true);
|
||||
|
||||
@ -74,7 +74,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
public function saveNBT() : void{
|
||||
$this->namedtag->Items->setValue([]);
|
||||
for($index = 0; $index < $this->getSize(); ++$index){
|
||||
$this->setItem($index, $this->inventory->getItem($index));
|
||||
@ -93,7 +93,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getSlotIndex(int $index){
|
||||
protected function getSlotIndex(int $index) : int{
|
||||
foreach($this->namedtag->Items as $i => $slot){
|
||||
if($slot->Slot->getValue() === $index){
|
||||
return (int) $i;
|
||||
@ -200,7 +200,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
/**
|
||||
* @return Chest|null
|
||||
*/
|
||||
public function getPair(){
|
||||
public function getPair() : ?Chest{
|
||||
if($this->isPaired()){
|
||||
$tile = $this->getLevel()->getTile(new Vector3($this->namedtag->pairx->getValue(), $this->y, $this->namedtag->pairz->getValue()));
|
||||
if($tile instanceof Chest){
|
||||
@ -253,7 +253,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
if($this->isPaired()){
|
||||
$nbt->pairx = $this->namedtag->pairx;
|
||||
$nbt->pairz = $this->namedtag->pairz;
|
||||
|
@ -39,7 +39,7 @@ class EnchantTable extends Spawnable implements Nameable{
|
||||
return "Enchanting Table";
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
if($this->hasName()){
|
||||
$nbt->CustomName = $this->namedtag->CustomName;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class FlowerPot extends Spawnable{
|
||||
return $this->getItem()->isNull();
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->item = $this->namedtag->item;
|
||||
$nbt->mData = $this->namedtag->mData;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
return "Furnace";
|
||||
}
|
||||
|
||||
public function close(){
|
||||
public function close() : void{
|
||||
if($this->closed === false){
|
||||
$this->inventory->removeAllViewers(true);
|
||||
$this->inventory = null;
|
||||
@ -96,7 +96,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
}
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
public function saveNBT() : void{
|
||||
$this->namedtag->Items->setValue([]);
|
||||
for($index = 0; $index < $this->getSize(); ++$index){
|
||||
$this->setItem($index, $this->inventory->getItem($index));
|
||||
@ -273,7 +273,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->BurnTime = $this->namedtag->BurnTime;
|
||||
$nbt->CookTime = $this->namedtag->CookTime;
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ItemFrame extends Spawnable{
|
||||
$this->onChanged();
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->ItemDropChance = $this->namedtag->ItemDropChance;
|
||||
$nbt->ItemRotation = $this->namedtag->ItemRotation;
|
||||
|
||||
|
@ -54,7 +54,7 @@ class Sign extends Spawnable{
|
||||
parent::__construct($level, $nbt);
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
public function saveNBT() : void{
|
||||
parent::saveNBT();
|
||||
$this->namedtag->Text = new StringTag("Text", implode("\n", $this->text));
|
||||
|
||||
@ -127,7 +127,7 @@ class Sign extends Spawnable{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->Text = new StringTag("Text", implode("\n", $this->text));
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Skull extends Spawnable{
|
||||
return $this->namedtag->SkullType->getValue();
|
||||
}
|
||||
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt){
|
||||
public function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->SkullType = $this->namedtag->SkullType;
|
||||
$nbt->Rot = $this->namedtag->Rot;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ abstract class Spawnable extends Tile{
|
||||
return $pk;
|
||||
}
|
||||
|
||||
public function spawnTo(Player $player){
|
||||
public function spawnTo(Player $player) : bool{
|
||||
if($this->closed){
|
||||
return false;
|
||||
}
|
||||
@ -67,7 +67,7 @@ abstract class Spawnable extends Tile{
|
||||
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
|
||||
}
|
||||
|
||||
protected function onChanged(){
|
||||
protected function onChanged() : void{
|
||||
$this->spawnToAll();
|
||||
|
||||
if($this->chunk !== null){
|
||||
@ -96,7 +96,7 @@ abstract class Spawnable extends Tile{
|
||||
*
|
||||
* @param CompoundTag $nbt
|
||||
*/
|
||||
abstract public function addAdditionalSpawnData(CompoundTag $nbt);
|
||||
abstract public function addAdditionalSpawnData(CompoundTag $nbt) : void;
|
||||
|
||||
/**
|
||||
* Called when a player updates a block entity's NBT data
|
||||
|
@ -97,7 +97,7 @@ abstract class Tile extends Position{
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
public static function createTile($type, Level $level, CompoundTag $nbt, ...$args){
|
||||
public static function createTile($type, Level $level, CompoundTag $nbt, ...$args) : ?Tile{
|
||||
if(isset(self::$knownTiles[$type])){
|
||||
$class = self::$knownTiles[$type];
|
||||
return new $class($level, $nbt, ...$args);
|
||||
@ -149,11 +149,11 @@ abstract class Tile extends Position{
|
||||
$this->getLevel()->addTile($this);
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
public function getId() : int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function saveNBT(){
|
||||
public function saveNBT() : void{
|
||||
$this->namedtag->id->setValue(static::getSaveId());
|
||||
$this->namedtag->x->setValue($this->x);
|
||||
$this->namedtag->y->setValue($this->y);
|
||||
@ -164,7 +164,7 @@ abstract class Tile extends Position{
|
||||
return $this->namedtag;
|
||||
}
|
||||
|
||||
public function getCleanedNBT(){
|
||||
public function getCleanedNBT() : ?CompoundTag{
|
||||
$this->saveNBT();
|
||||
$tag = clone $this->namedtag;
|
||||
unset($tag->x, $tag->y, $tag->z, $tag->id);
|
||||
@ -236,7 +236,7 @@ abstract class Tile extends Position{
|
||||
return false;
|
||||
}
|
||||
|
||||
final public function scheduleUpdate(){
|
||||
final public function scheduleUpdate() : void{
|
||||
$this->level->updateTiles[$this->id] = $this;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ abstract class Tile extends Position{
|
||||
$this->close();
|
||||
}
|
||||
|
||||
public function close(){
|
||||
public function close() : void{
|
||||
if(!$this->closed){
|
||||
$this->closed = true;
|
||||
unset($this->level->updateTiles[$this->id]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user