mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +00:00
Fixed Double Chests
This commit is contained in:
parent
1d8562fb8c
commit
ce91f2943a
@ -55,6 +55,7 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
|||||||
for($i = 0; $i < $this->getSize(); ++$i){
|
for($i = 0; $i < $this->getSize(); ++$i){
|
||||||
$this->inventory->setItem($i, $this->getItem($i));
|
$this->inventory->setItem($i, $this->getItem($i));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->checkPairing();
|
$this->checkPairing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,13 +170,16 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
|||||||
|
|
||||||
protected function checkPairing(){
|
protected function checkPairing(){
|
||||||
if(($pair = $this->getPair()) instanceof Chest){
|
if(($pair = $this->getPair()) instanceof Chest){
|
||||||
if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly
|
if($this->doubleInventory === null){
|
||||||
$this->doubleInventory = new DoubleChestInventory($pair, $this);
|
if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly
|
||||||
}else{
|
$this->doubleInventory = new DoubleChestInventory($pair, $this);
|
||||||
$this->doubleInventory = new DoubleChestInventory($this, $pair);
|
}else{
|
||||||
|
$this->doubleInventory = new DoubleChestInventory($this, $pair);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->doubleInventory = null;
|
$this->doubleInventory = null;
|
||||||
|
unset($this->namedtag->pairx, $this->namedtag->pairz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +196,7 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
|||||||
*/
|
*/
|
||||||
public function getPair(){
|
public function getPair(){
|
||||||
if($this->isPaired()){
|
if($this->isPaired()){
|
||||||
$tile = $this->getLevel()->getTile(new Vector3((int) $this->namedtag->pairx, $this->y, (int) $this->namedtag->pairz));
|
$tile = $this->getLevel()->getTile(new Vector3((int) $this->namedtag["pairx"], $this->y, (int) $this->namedtag["pairz"]));
|
||||||
if($tile instanceof Chest){
|
if($tile instanceof Chest){
|
||||||
return $tile;
|
return $tile;
|
||||||
}
|
}
|
||||||
@ -206,11 +210,11 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->namedtag->pairx = $tile->x;
|
$this->namedtag->pairx = new Int("pairx", $tile->x);
|
||||||
$this->namedtag->pairz = $tile->z;
|
$this->namedtag->pairz = new Int("pairz", $tile->z);
|
||||||
|
|
||||||
$tile->namedtag->pairx = $this->x;
|
$tile->namedtag->pairx = new Int("pairx", $this->x);
|
||||||
$tile->namedtag->pairz = $this->z;
|
$tile->namedtag->pairz = new Int("pairz", $this->z);
|
||||||
|
|
||||||
$this->spawnToAll();
|
$this->spawnToAll();
|
||||||
$tile->spawnToAll();
|
$tile->spawnToAll();
|
||||||
@ -244,8 +248,8 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
|||||||
new Int("x", (int) $this->x),
|
new Int("x", (int) $this->x),
|
||||||
new Int("y", (int) $this->y),
|
new Int("y", (int) $this->y),
|
||||||
new Int("z", (int) $this->z),
|
new Int("z", (int) $this->z),
|
||||||
new Int("pairx", (int) $this->namedtag->pairx),
|
new Int("pairx", (int) $this->namedtag["pairx"]),
|
||||||
new Int("pairz", (int) $this->namedtag->pairz)
|
new Int("pairz", (int) $this->namedtag["pairz"])
|
||||||
]);
|
]);
|
||||||
}else{
|
}else{
|
||||||
return new Compound("", [
|
return new Compound("", [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user