mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Chest: constrain pair positions to immediately horizontally adjacent blocks
under normal circumstances a chest will never pair with a chest which isn't directly next to it anyway.
This commit is contained in:
parent
cc6296b019
commit
a2274429ab
@ -29,6 +29,7 @@ use pocketmine\math\Vector3;
|
|||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
use pocketmine\world\World;
|
use pocketmine\world\World;
|
||||||
|
use function abs;
|
||||||
|
|
||||||
class Chest extends Spawnable implements Container, Nameable{
|
class Chest extends Spawnable implements Container, Nameable{
|
||||||
use NameableTrait {
|
use NameableTrait {
|
||||||
@ -59,8 +60,17 @@ class Chest extends Spawnable implements Container, Nameable{
|
|||||||
|
|
||||||
public function readSaveData(CompoundTag $nbt) : void{
|
public function readSaveData(CompoundTag $nbt) : void{
|
||||||
if($nbt->hasTag(self::TAG_PAIRX, IntTag::class) and $nbt->hasTag(self::TAG_PAIRZ, IntTag::class)){
|
if($nbt->hasTag(self::TAG_PAIRX, IntTag::class) and $nbt->hasTag(self::TAG_PAIRZ, IntTag::class)){
|
||||||
$this->pairX = $nbt->getInt(self::TAG_PAIRX);
|
$pairX = $nbt->getInt(self::TAG_PAIRX);
|
||||||
$this->pairZ = $nbt->getInt(self::TAG_PAIRZ);
|
$pairZ = $nbt->getInt(self::TAG_PAIRZ);
|
||||||
|
if(
|
||||||
|
($this->x === $pairX and abs($this->z - $pairZ) === 1) or
|
||||||
|
($this->z === $pairZ and abs($this->x - $pairX) === 1)
|
||||||
|
){
|
||||||
|
$this->pairX = $pairX;
|
||||||
|
$this->pairZ = $pairZ;
|
||||||
|
}else{
|
||||||
|
$this->pairX = $this->pairZ = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->loadName($nbt);
|
$this->loadName($nbt);
|
||||||
$this->loadItems($nbt);
|
$this->loadItems($nbt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user