mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
Better Tile selection & player death check and fix
This commit is contained in:
parent
26fb652c5a
commit
1474d8c785
@ -52,7 +52,7 @@ class LevelAPI{
|
|||||||
if($block[0] === 0){
|
if($block[0] === 0){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->setBlock($data["x"], $data["y"], $data["z"], 0, 0);
|
$this->setBlock($data["x"], $data["y"], $data["z"], 0, 0, true, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,12 +84,10 @@ class LevelAPI{
|
|||||||
return $this->heightMap[$z][$x];
|
return $this->heightMap[$z][$x];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock($x, $y, $z, $block, $meta = 0, $update = true){
|
public function setBlock($x, $y, $z, $block, $meta = 0, $update = true, $tiles = false){
|
||||||
if($x < 0 or $y < 0 or $z < 0){
|
if($x < 0 or $y < 0 or $z < 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->map->setBlock($x, $y, $z, $block, $meta);
|
|
||||||
$this->heightMap[$z][$x] = $this->map->getFloor($x, $z);
|
|
||||||
if($this->server->api->dhandle("block.change", array(
|
if($this->server->api->dhandle("block.change", array(
|
||||||
"x" => $x,
|
"x" => $x,
|
||||||
"y" => $y,
|
"y" => $y,
|
||||||
@ -97,10 +95,17 @@ class LevelAPI{
|
|||||||
"block" => $block,
|
"block" => $block,
|
||||||
"meta" => $meta,
|
"meta" => $meta,
|
||||||
)) !== false){
|
)) !== false){
|
||||||
|
$this->map->setBlock($x, $y, $z, $block, $meta);
|
||||||
|
$this->heightMap[$z][$x] = $this->map->getFloor($x, $z);
|
||||||
if($update === true){
|
if($update === true){
|
||||||
$this->server->api->block->updateBlock($x, $y, $z, BLOCK_UPDATE_NORMAL);
|
$this->server->api->block->updateBlock($x, $y, $z, BLOCK_UPDATE_NORMAL);
|
||||||
$this->server->api->block->updateBlocksAround($x, $y, $z, BLOCK_UPDATE_NORMAL);
|
$this->server->api->block->updateBlocksAround($x, $y, $z, BLOCK_UPDATE_NORMAL);
|
||||||
}
|
}
|
||||||
|
if($tiles === true){
|
||||||
|
if(($t = $this->server->api->tileentity->get($x, $y, $z)) !== false){
|
||||||
|
$t[0]->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,30 @@ class TileEntityAPI{
|
|||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($eid){
|
public function get($x, $y, $z){
|
||||||
if(isset($this->server->tileEntities[$eid])){
|
$x = (int) $x;
|
||||||
return $this->server->tileEntities[$eid];
|
$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){
|
||||||
|
while(($t = $tiles->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||||
|
if(($tile = $this->getByID($t["ID"])) !== false){
|
||||||
|
if($tile->normal === true){
|
||||||
|
$ret[] = $tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count($ret) === 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByID($id){
|
||||||
|
if(isset($this->server->tileEntities[$id])){
|
||||||
|
return $this->server->tileEntities[$id];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -53,7 +74,7 @@ class TileEntityAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function spawnTo($id, $player){
|
public function spawnTo($id, $player){
|
||||||
$t = $this->get($id);
|
$t = $this->getByID($id);
|
||||||
if($t === false){
|
if($t === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -61,7 +82,7 @@ class TileEntityAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function spawnToAll($id){
|
public function spawnToAll($id){
|
||||||
$t = $this->get($id);
|
$t = $this->getByID($id);
|
||||||
if($t === false){
|
if($t === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -551,10 +551,14 @@ class Player{
|
|||||||
$this->server->api->dhandle("entity.animate", array("eid" => $this->eid, "action" => $data["action"]));
|
$this->server->api->dhandle("entity.animate", array("eid" => $this->eid, "action" => $data["action"]));
|
||||||
break;
|
break;
|
||||||
case MC_RESPAWN:
|
case MC_RESPAWN:
|
||||||
//$this->entity->invincible = true;
|
if($this->entity->dead === false){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$this->entity->fire = 0;
|
||||||
|
$this->entity->air = 300;
|
||||||
$this->entity->setPosition($data["x"], $data["y"], $data["z"], 0, 0);
|
$this->entity->setPosition($data["x"], $data["y"], $data["z"], 0, 0);
|
||||||
$this->entity->setHealth(20, "respawn");
|
$this->entity->setHealth(20, "respawn");
|
||||||
//$this->entity->invincible = false;
|
$this->entity->updateMetadata();
|
||||||
break;
|
break;
|
||||||
case MC_SET_HEALTH:
|
case MC_SET_HEALTH:
|
||||||
if($this->server->gamemode === 1){
|
if($this->server->gamemode === 1){
|
||||||
|
@ -30,6 +30,7 @@ define("TILE_SIGN", 0);
|
|||||||
|
|
||||||
class TileEntity extends stdClass{
|
class TileEntity extends stdClass{
|
||||||
public $name;
|
public $name;
|
||||||
|
public $normal;
|
||||||
public $id;
|
public $id;
|
||||||
public $x;
|
public $x;
|
||||||
public $y;
|
public $y;
|
||||||
@ -42,6 +43,7 @@ class TileEntity extends stdClass{
|
|||||||
private $server;
|
private $server;
|
||||||
function __construct(PocketMinecraftServer $server, $id, $class, $x, $y, $z, $data = array()){
|
function __construct(PocketMinecraftServer $server, $id, $class, $x, $y, $z, $data = array()){
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
$this->normal = true;
|
||||||
$this->class = (int) $class;
|
$this->class = (int) $class;
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->closed = false;
|
$this->closed = false;
|
||||||
@ -54,15 +56,13 @@ class TileEntity extends stdClass{
|
|||||||
$this->y = (int) $y;
|
$this->y = (int) $y;
|
||||||
$this->z = (int) $z;
|
$this->z = (int) $z;
|
||||||
$this->server->query("INSERT OR REPLACE INTO tileentities (ID, class, x, y, z) VALUES (".$this->id.", ".$this->class.", ".$this->x.", ".$this->y.", ".$this->z.");");
|
$this->server->query("INSERT OR REPLACE INTO tileentities (ID, class, x, y, z) VALUES (".$this->id.", ".$this->class.", ".$this->x.", ".$this->y.", ".$this->z.");");
|
||||||
$update = false;
|
|
||||||
switch($this->class){
|
switch($this->class){
|
||||||
case TILE_SIGN:
|
case TILE_SIGN:
|
||||||
$this->server->query("UPDATE tileentities SET spawnable = 1 WHERE ID = ".$this->id.";");
|
$this->server->query("UPDATE tileentities SET spawnable = 1 WHERE ID = ".$this->id.";");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($update === true){
|
//$this->server->schedule(40, array($this, "update"), array(), true);
|
||||||
$this->server->schedule(40, array($this, "update"), array(), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(){
|
public function update(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user