Better BlockEntityDataPacket handling

This commit is contained in:
Dylan K. Taylor
2016-11-28 10:38:56 +00:00
parent 2987c7a80c
commit c4d4277a6c
3 changed files with 54 additions and 29 deletions

View File

@ -46,11 +46,6 @@ abstract class Spawnable extends Tile{
return true;
}
/**
* @return CompoundTag
*/
public abstract function getSpawnCompound();
public function __construct(Chunk $chunk, CompoundTag $nbt){
parent::__construct($chunk, $nbt);
$this->spawnToAll();
@ -76,4 +71,22 @@ abstract class Spawnable extends Tile{
$this->level->clearChunkCache($this->chunk->getX(), $this->chunk->getZ());
}
}
/**
* @return CompoundTag
*/
public abstract function getSpawnCompound();
/**
* Called when a player updates a block entity's NBT data
* for example when writing on a sign.
*
* @param CompoundTag $nbt
* @param Player $player
*
* @return bool indication of success, will respawn the tile to the player if false.
*/
public function updateCompoundTag(CompoundTag $nbt, Player $player) : bool{
return false;
}
}