Fixed double chests being openable when the other half has a solid block above it, close #1165

This commit is contained in:
Muqsit 2017-09-01 16:50:55 +01:00 committed by Dylan K. Taylor
parent 226175f961
commit 138d85307b

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());