mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 01:51:51 +00:00
Remove Chest TileEntities on break
This commit is contained in:
parent
69a1c97a36
commit
ccd1231d42
@ -31,10 +31,16 @@ class TileEntityAPI{
|
|||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($x, $y, $z){
|
public function get($x, $y = false, $z = false){
|
||||||
$x = (int) $x;
|
if(($x instanceof Vector3) or ($x instanceof Block)){
|
||||||
$y = (int) $y;
|
$z = (int) $x->z;
|
||||||
$z = (int) $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;");
|
$tiles = $this->server->query("SELECT * FROM tileentities WHERE x = $x AND y = $y AND z = $z;");
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if($tiles !== false and $tiles !== true){
|
if($tiles !== false and $tiles !== true){
|
||||||
|
@ -205,4 +205,5 @@ require_once("block/FallableBlock.php");
|
|||||||
require_once("block/LiquidBlock.php");
|
require_once("block/LiquidBlock.php");
|
||||||
require_once("block/StairBlock.php");
|
require_once("block/StairBlock.php");
|
||||||
require_once("block/DoorBlock.php");
|
require_once("block/DoorBlock.php");
|
||||||
|
require_once("block/ContainerBlock.php");
|
||||||
/***REM_END***/
|
/***REM_END***/
|
||||||
|
57
src/material/block/ContainerBlock.php
Normal file
57
src/material/block/ContainerBlock.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
-
|
||||||
|
/ \
|
||||||
|
/ \
|
||||||
|
/ PocketMine \
|
||||||
|
/ MP \
|
||||||
|
|\ @shoghicp /|
|
||||||
|
|. \ / .|
|
||||||
|
| .. \ / .. |
|
||||||
|
| .. | .. |
|
||||||
|
| .. | .. |
|
||||||
|
\ | /
|
||||||
|
\ | /
|
||||||
|
\ | /
|
||||||
|
\ | /
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ContainerBlock extends SolidBlock{
|
||||||
|
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||||
|
parent::__construct($id, $meta, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
||||||
|
if($this->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;
|
||||||
|
}
|
||||||
|
}
|
@ -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){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(CHEST, $meta, "Chest");
|
parent::__construct(CHEST, $meta, "Chest");
|
||||||
$this->isActivable = true;
|
$this->isActivable = true;
|
||||||
|
@ -27,6 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
|
|
||||||
define("TILE_SIGN", "Sign");
|
define("TILE_SIGN", "Sign");
|
||||||
|
define("TILE_CHEST", "Chest");
|
||||||
|
|
||||||
class TileEntity extends stdClass{
|
class TileEntity extends stdClass{
|
||||||
public $name;
|
public $name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user