diff --git a/src/API/TileEntityAPI.php b/src/API/TileEntityAPI.php index a2777e13..9ad983f0 100644 --- a/src/API/TileEntityAPI.php +++ b/src/API/TileEntityAPI.php @@ -31,10 +31,16 @@ class TileEntityAPI{ $this->server = $server; } - public function get($x, $y, $z){ - $x = (int) $x; - $y = (int) $y; - $z = (int) $z; + public function get($x, $y = false, $z = false){ + if(($x instanceof Vector3) or ($x instanceof Block)){ + $z = (int) $x->z; + $y = (int) $x->y; + $x = (int) $x->x; + }else{ + $x = (int) $x; + $y = (int) $y; + $z = (int) $z; + } $tiles = $this->server->query("SELECT * FROM tileentities WHERE x = $x AND y = $y AND z = $z;"); $ret = array(); if($tiles !== false and $tiles !== true){ diff --git a/src/material/Block.php b/src/material/Block.php index 189396e5..c51f6698 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -205,4 +205,5 @@ require_once("block/FallableBlock.php"); require_once("block/LiquidBlock.php"); require_once("block/StairBlock.php"); require_once("block/DoorBlock.php"); +require_once("block/ContainerBlock.php"); /***REM_END***/ diff --git a/src/material/block/ContainerBlock.php b/src/material/block/ContainerBlock.php new file mode 100644 index 00000000..a8fb6dfc --- /dev/null +++ b/src/material/block/ContainerBlock.php @@ -0,0 +1,57 @@ +inWorld === true){ + $server = ServerAPI::request(); + $t = $server->api->tileentity->get($this); + if($t !== false){ + if(is_array($t)){ + foreach($t as $ts){ + if($ts->class === TILE_CHEST){ + $server->api->tileentity->remove($ts->id); + } + } + }elseif($t->class === TILE_CHEST){ + $server->api->tileentity->remove($t->id); + } + } + $level->setBlock($this, 0, 0); + return true; + } + return false; + } + + public function onActivate(BlockAPI $level, Item $item, Player $player){ + return false; + } +} \ No newline at end of file diff --git a/src/material/block/solid/Chest.php b/src/material/block/solid/Chest.php index 17693060..c4dda231 100644 --- a/src/material/block/solid/Chest.php +++ b/src/material/block/solid/Chest.php @@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or */ -class ChestBlock extends SolidBlock{ +class ChestBlock extends ContainerBlock{ public function __construct($meta = 0){ parent::__construct(CHEST, $meta, "Chest"); $this->isActivable = true; diff --git a/src/world/TileEntity.php b/src/world/TileEntity.php index db81a02f..50da034c 100644 --- a/src/world/TileEntity.php +++ b/src/world/TileEntity.php @@ -27,6 +27,7 @@ the Free Software Foundation, either version 3 of the License, or define("TILE_SIGN", "Sign"); +define("TILE_CHEST", "Chest"); class TileEntity extends stdClass{ public $name;