Merge branch 'php/7.0'

This commit is contained in:
Dylan K. Taylor 2017-09-01 16:57:51 +01:00
commit 5335ed9394
3 changed files with 31 additions and 20 deletions

View File

@ -136,10 +136,6 @@ class Chest extends Transparent{
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$top = $this->getSide(Vector3::SIDE_UP);
if($top->isTransparent() !== true){
return true;
}
$t = $this->getLevel()->getTile($this);
$chest = null;
@ -157,10 +153,12 @@ class Chest extends Transparent{
$chest = Tile::createTile("Chest", $this->getLevel(), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
return true;
}
if(
!$this->getSide(Vector3::SIDE_UP)->isTransparent() or
($chest->isPaired() and !$chest->getPair()->getBlock()->getSide(Vector3::SIDE_UP)->isTransparent()) or
(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag and $chest->namedtag->Lock->getValue() !== $item->getCustomName())
){
return true;
}
$player->addWindow($chest->getInventory());

View File

@ -836,21 +836,15 @@ class Level implements ChunkManager, Metadatable{
$this->server->batchPackets($target, $packets, false, false);
}
public function clearCache(bool $full = false){
if($full){
public function clearCache(bool $force = false){
if($force){
$this->chunkCache = [];
$this->blockCache = [];
}else{
if(count($this->chunkCache) > 768){
$this->chunkCache = [];
}
if(count($this->blockCache) > 2048){
$this->blockCache = [];
}
}
}
public function clearChunkCache(int $chunkX, int $chunkZ){

View File

@ -54,11 +54,30 @@ class Sign extends Spawnable{
unset($this->namedtag->Creator);
}
/**
* Changes contents of the specific lines to the string provided.
* Leaves contents of the specifc lines as is if null is provided.
*
* @param null|string $line1
* @param null|string $line2
* @param null|string $line3
* @param null|string $line4
*
* @return bool
*/
public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){
$this->namedtag->Text1->setValue($line1);
$this->namedtag->Text2->setValue($line2);
$this->namedtag->Text3->setValue($line3);
$this->namedtag->Text4->setValue($line4);
if($line1 !== null){
$this->namedtag->Text1->setValue("Text1", $line1);
}
if($line2 !== null){
$this->namedtag->Text2->setValue("Text2", $line2);
}
if($line3 !== null){
$this->namedtag->Text3->setValue("Text3", $line3);
}
if($line4 !== null){
$this->namedtag->Text4->setValue("Text4", $line4);
}
$this->onChanged();
}