mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Tile NBT usage enhancements (#1259)
* Do not create new NBT objects on Tile::getSpawnCompound() * PocketMine's string formatting * Remove more useless array indices and create lesser new NBT objects. * Remove unused imports and type-hint Sign::setText() params * Do not mess with Sign::setText() params due to #1204 * Fix formatting * Make getSpawnCompound() final and add abstract addAdditionalSpawnData() * Make the same changes for Bed tile * Fix a missing "->" and remove some unneeded int casting.
This commit is contained in:
committed by
Dylan K. Taylor
parent
3fdbcee10f
commit
7d3fca83f0
@ -77,7 +77,24 @@ abstract class Spawnable extends Tile{
|
||||
/**
|
||||
* @return CompoundTag
|
||||
*/
|
||||
abstract public function getSpawnCompound() : CompoundTag;
|
||||
final public function getSpawnCompound() : CompoundTag{
|
||||
$nbt = new CompoundTag("", [
|
||||
$this->namedtag->id,
|
||||
$this->namedtag->x,
|
||||
$this->namedtag->y,
|
||||
$this->namedtag->z
|
||||
]);
|
||||
$this->addAdditionalSpawnData($nbt);
|
||||
return $nbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension to getSpawnCompound() for
|
||||
* further modifying the generic tile NBT.
|
||||
*
|
||||
* @param CompoundTag $nbt
|
||||
*/
|
||||
abstract public function addAdditionalSpawnData(CompoundTag $nbt);
|
||||
|
||||
/**
|
||||
* Called when a player updates a block entity's NBT data
|
||||
|
Reference in New Issue
Block a user