mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
More classes updated
This commit is contained in:
parent
95bff304e4
commit
083bfcc83c
@ -317,13 +317,13 @@ class BlockAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function cancelAction(Block $block, Player $player, $send = true){
|
private function cancelAction(Block $block, Player $player, $send = true){
|
||||||
$player->dataPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, array(
|
$pk = new UpdateBlockPacket;
|
||||||
"x" => $block->x,
|
$pk->x = $block->x;
|
||||||
"y" => $block->y,
|
$pk->y = $block->y;
|
||||||
"z" => $block->z,
|
$pk->z = $block->z;
|
||||||
"block" => $block->getID(),
|
$pk->block = $block->getID();
|
||||||
"meta" => $block->getMetadata()
|
$pk->meta = $block->getMetadata();
|
||||||
));
|
$player->dataPacket($pk);
|
||||||
if($send === true){
|
if($send === true){
|
||||||
$player->sendInventorySlot($player->slot);
|
$player->sendInventorySlot($player->slot);
|
||||||
}
|
}
|
||||||
@ -459,363 +459,6 @@ class BlockAPI{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
public function flowLavaOn($source, $face){
|
|
||||||
$down = 0;
|
|
||||||
if($face === BlockFace::BOTTOM){
|
|
||||||
$level = 0;
|
|
||||||
$down = 1;
|
|
||||||
}else{
|
|
||||||
$level = ($source[1] & 0x07) + 2;
|
|
||||||
if($level > 0x07){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$spread = $this->server->api->level->getBlockFace($source, $face);
|
|
||||||
if(($source[0] === 10 or $source[0] === 11) and $spread[0] === 10){
|
|
||||||
if($level < ($spread[1] & 0x07)){
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $spread[2][0],
|
|
||||||
"y" => $spread[2][1],
|
|
||||||
"z" => $spread[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $spread[0], $level | $down, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}elseif($spread[0] === 9 or $spread[0] === 8){
|
|
||||||
if($source[0] === 11){
|
|
||||||
$this->server->api->level->setBlock($source[2][0], $source[2][1], $source[2][2], 49, 0);
|
|
||||||
}elseif($face === 0){
|
|
||||||
$this->server->api->level->setBlock($source[2][0], $source[2][1], $source[2][2], 1, 0);
|
|
||||||
}else{
|
|
||||||
$this->server->api->level->setBlock($source[2][0], $source[2][1], $source[2][2], 4, 0);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}elseif(isset(Material::$flowable[$spread[0]])){
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $spread[2][0],
|
|
||||||
"y" => $spread[2][1],
|
|
||||||
"z" => $spread[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 10, $level | $down, false);
|
|
||||||
return true;
|
|
||||||
}elseif(($source[1] & 0x08) === 0x08){
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $source[0], $source[1] & 0x07, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function flowWaterOn($source, $face, &$spread = null){
|
|
||||||
$down = 0;
|
|
||||||
if($face === BlockFace::BOTTOM){
|
|
||||||
$level = 0;
|
|
||||||
$down = 1;
|
|
||||||
}else{
|
|
||||||
$level = ($source[1] & 0x07) + 1;
|
|
||||||
if($level > 0x07){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$spread = $this->server->api->level->getBlockFace($source, $face);
|
|
||||||
if(($source[0] === 8 or $source[0] === 9) and $spread[0] === 8){
|
|
||||||
if($level < ($spread[1] & 0x07)){
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $spread[2][0],
|
|
||||||
"y" => $spread[2][1],
|
|
||||||
"z" => $spread[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $spread[0], $level | $down, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}elseif($spread[0] === 11){
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 49, 0, true);
|
|
||||||
return true;
|
|
||||||
}elseif($spread[0] === 10){
|
|
||||||
if($face === 0 or ($spread[1] & 0x08) === 0){
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 4, 0, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}elseif(isset(Material::$flowable[$spread[0]])){
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $spread[2][0],
|
|
||||||
"y" => $spread[2][1],
|
|
||||||
"z" => $spread[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], 8, $level | $down, false);
|
|
||||||
return true;
|
|
||||||
}elseif(($source[1] & 0x08) === 0x08){
|
|
||||||
$this->server->api->level->setBlock($spread[2][0], $spread[2][1], $spread[2][2], $source[0], $source[1] & 0x07, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateBlock($x, $y, $z, $type = BLOCK_UPDATE_NORMAL){
|
|
||||||
$block = $this->server->api->level->getBlock($x, $y, $z);
|
|
||||||
$changed = false;
|
|
||||||
|
|
||||||
switch($block[0]){
|
|
||||||
case 8:
|
|
||||||
case 9:
|
|
||||||
$faces = array();
|
|
||||||
if(!$this->flowWaterOn($block, 0, $floor) or $block[0] === 9){
|
|
||||||
$this->flowWaterOn($block, 2, $faces[0]);
|
|
||||||
$this->flowWaterOn($block, 3, $faces[1]);
|
|
||||||
$this->flowWaterOn($block, 4, $faces[2]);
|
|
||||||
$this->flowWaterOn($block, 5, $faces[3]);
|
|
||||||
}
|
|
||||||
if($block[0] === 8){
|
|
||||||
//Source creation
|
|
||||||
if(!isset(Material::$flowable[$floor[0]])){
|
|
||||||
$sources = 0;
|
|
||||||
foreach($faces as $i => $b){
|
|
||||||
if($b[0] === 9){
|
|
||||||
++$sources;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($sources >= 2){
|
|
||||||
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], 9, 0, false);
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$drained = true;
|
|
||||||
$level = $block[1] & 0x07;
|
|
||||||
$up = $this->server->api->level->getBlockFace($block, BlockFace::UP);
|
|
||||||
if($up[0] === 8 or $up[0] === 9){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::NORTH);
|
|
||||||
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::SOUTH);
|
|
||||||
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::EAST);
|
|
||||||
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::WEST);
|
|
||||||
if($b[0] === 9 or ($b[0] === 8 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($drained === true){
|
|
||||||
++$level;
|
|
||||||
if($level > 0x07){
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] + 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] - 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] + 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] - 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1] - 1,
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], 0, 0, false);
|
|
||||||
}else{
|
|
||||||
$block[1] = ($block[1] & 0x08) | $level;
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] + 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] - 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] + 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] - 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1] - 1,
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(10, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], $block[0], $block[1], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
case 11:
|
|
||||||
if(!$this->flowLavaOn($block, 0) or $block[0] === 11){
|
|
||||||
$this->flowLavaOn($block, 2);
|
|
||||||
$this->flowLavaOn($block, 3);
|
|
||||||
$this->flowLavaOn($block, 4);
|
|
||||||
$this->flowLavaOn($block, 5);
|
|
||||||
}
|
|
||||||
if($block[0] === 10){
|
|
||||||
$drained = true;
|
|
||||||
$level = $block[1] & 0x07;
|
|
||||||
$up = $this->server->api->level->getBlockFace($block, BlockFace::UP);
|
|
||||||
if($up[0] === 10 or $up[0] === 11){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::NORTH);
|
|
||||||
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::SOUTH);
|
|
||||||
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::EAST);
|
|
||||||
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}else{
|
|
||||||
$b = $this->server->api->level->getBlockFace($block, BlockFace::WEST);
|
|
||||||
if($b[0] === 11 or ($b[0] === 10 and ($b[1] & 0x08) === 0 and ($b[1] & 0x07) < $level)){
|
|
||||||
$drained = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($drained === true){
|
|
||||||
++$level;
|
|
||||||
if($level > 0x07){
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] + 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] - 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] + 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] - 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1] - 1,
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], 0, 0, false);
|
|
||||||
}else{
|
|
||||||
$block[1] = ($block[1] & 0x08) | $level;
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] + 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0] - 1,
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] + 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2] - 1,
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1] - 1,
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->schedule(20, array($this, "blockScheduler"), array(
|
|
||||||
"x" => $block[2][0],
|
|
||||||
"y" => $block[2][1],
|
|
||||||
"z" => $block[2][2],
|
|
||||||
"type" => BLOCK_UPDATE_NORMAL,
|
|
||||||
));
|
|
||||||
$this->server->api->level->setBlock($block[2][0], $block[2][1], $block[2][2], $block[0], $block[1], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if($type === BLOCK_TYPE_SCHEDULED){
|
|
||||||
$type = BLOCK_UPDATE_WEAK;
|
|
||||||
}
|
|
||||||
if($changed === true){
|
|
||||||
$this->updateBlocksAround($x, $y, $z, $type);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
||||||
if($delay !== false){
|
if($delay !== false){
|
||||||
$this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
|
$this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
|
||||||
|
@ -157,14 +157,14 @@ class EntityAPI{
|
|||||||
$entity->closed = true;
|
$entity->closed = true;
|
||||||
$this->server->query("DELETE FROM entities WHERE EID = ".$eid.";");
|
$this->server->query("DELETE FROM entities WHERE EID = ".$eid.";");
|
||||||
if($entity->class === ENTITY_PLAYER){
|
if($entity->class === ENTITY_PLAYER){
|
||||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll(), ProtocolInfo::REMOVE_PLAYER_PACKET, array(
|
$pk = new RemovePlayerPacket;
|
||||||
"clientID" => 0,
|
$pk->eid = $entity->eid;
|
||||||
"eid" => $entity->eid,
|
$pk->clientID = 0;
|
||||||
));
|
$this->server->api->player->broadcastPacket($this->server->api->player->getAll(), $pk);
|
||||||
}else{
|
}else{
|
||||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($entity->level), ProtocolInfo::REMOVE_ENTITY_PACKET, array(
|
$pk = new RemoveEntityPacket;
|
||||||
"eid" => $entity->eid,
|
$pk->eid = $entity->eid;
|
||||||
));
|
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($entity->level), $pk);
|
||||||
}
|
}
|
||||||
$this->server->api->dhandle("entity.remove", $entity);
|
$this->server->api->dhandle("entity.remove", $entity);
|
||||||
$entity = null;
|
$entity = null;
|
||||||
|
@ -402,14 +402,14 @@ class PlayerAPI{
|
|||||||
if($p !== $player and ($p->entity instanceof Entity)){
|
if($p !== $player and ($p->entity instanceof Entity)){
|
||||||
$p->entity->spawn($player);
|
$p->entity->spawn($player);
|
||||||
if($p->level !== $player->level){
|
if($p->level !== $player->level){
|
||||||
$player->dataPacket(ProtocolInfo::MOVE_ENTITY_POSROT_PACKET, array(
|
$pk = new MoveEntityPacket_PosRot;
|
||||||
"eid" => $p->entity->eid,
|
$pk->eid = $p->entity->eid;
|
||||||
"x" => -256,
|
$pk->x = -256;
|
||||||
"y" => 128,
|
$pk->y = 128;
|
||||||
"z" => -256,
|
$pk->z = -256;
|
||||||
"yaw" => 0,
|
$pk->yaw = 0;
|
||||||
"pitch" => 0,
|
$pk->pitch = 0;
|
||||||
));
|
$player->dataPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,14 +420,14 @@ class PlayerAPI{
|
|||||||
if($p !== $player and ($p->entity instanceof Entity) and ($player->entity instanceof Entity)){
|
if($p !== $player and ($p->entity instanceof Entity) and ($player->entity instanceof Entity)){
|
||||||
$player->entity->spawn($p);
|
$player->entity->spawn($p);
|
||||||
if($p->level !== $player->level){
|
if($p->level !== $player->level){
|
||||||
$p->dataPacket(ProtocolInfo::MOVE_ENTITY_POSROT_PACKET, array(
|
$pk = new MoveEntityPacket_PosRot;
|
||||||
"eid" => $player->entity->eid,
|
$pk->eid = $player->entity->eid;
|
||||||
"x" => -256,
|
$pk->x = -256;
|
||||||
"y" => 128,
|
$pk->y = 128;
|
||||||
"z" => -256,
|
$pk->z = -256;
|
||||||
"yaw" => 0,
|
$pk->yaw = 0;
|
||||||
"pitch" => 0,
|
$pk->pitch = 0;
|
||||||
));
|
$p->dataPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,7 +561,7 @@ class Player{
|
|||||||
$pk = new ContainerSetDataPacket;
|
$pk = new ContainerSetDataPacket;
|
||||||
$pk->windowid = $id;
|
$pk->windowid = $id;
|
||||||
$pk->property = 1; //Fire icon
|
$pk->property = 1; //Fire icon
|
||||||
$pk->value = $data->data["BurnTicks"]);
|
$pk->value = $data->data["BurnTicks"];
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -722,7 +722,7 @@ class Player{
|
|||||||
if($m !== ""){
|
if($m !== ""){
|
||||||
$pk = new MessagePacket;
|
$pk = new MessagePacket;
|
||||||
$pk->source = ($author instanceof Player) ? $author->username:$author;
|
$pk->source = ($author instanceof Player) ? $author->username:$author;
|
||||||
$pk->message = TextFormat::clean($m), //Colors not implemented :(
|
$pk->message = TextFormat::clean($m); //Colors not implemented :(
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -956,7 +956,7 @@ class Player{
|
|||||||
if($player !== $this and $player->entity instanceof Entity){
|
if($player !== $this and $player->entity instanceof Entity){
|
||||||
$pk = new MoveEntityPacket_PosRot;
|
$pk = new MoveEntityPacket_PosRot;
|
||||||
$pk->eid = $player->entity->eid;
|
$pk->eid = $player->entity->eid;
|
||||||
$pk->x = $player->entity->x
|
$pk->x = $player->entity->x;
|
||||||
$pk->y = $player->entity->y;
|
$pk->y = $player->entity->y;
|
||||||
$pk->z = $player->entity->z;
|
$pk->z = $player->entity->z;
|
||||||
$pk->yaw = $player->entity->yaw;
|
$pk->yaw = $player->entity->yaw;
|
||||||
@ -2310,16 +2310,7 @@ class Player{
|
|||||||
public function directBigRawPacket(RakNetDataPacket $packet){
|
public function directBigRawPacket(RakNetDataPacket $packet){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
reliability 2
|
|
||||||
hasSplit 1
|
|
||||||
$data = array(
|
|
||||||
"id" => false,
|
|
||||||
"pid" => 0x50,
|
|
||||||
"sendtime" => microtime(true),
|
|
||||||
"raw" => "",
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$sendtime = microtime(true);
|
$sendtime = microtime(true);
|
||||||
|
|
||||||
|
@ -114,13 +114,13 @@ class Explosion{
|
|||||||
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
|
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
|
||||||
$send[] = new Vector3($block->x - $source->x, $block->y - $source->y, $block->z - $source->z);
|
$send[] = new Vector3($block->x - $source->x, $block->y - $source->y, $block->z - $source->z);
|
||||||
}
|
}
|
||||||
$server->api->player->broadcastPacket($server->api->player->getAll($this->level), ProtocolInfo::EXPLOSION_PACKET, array(
|
$pk = new ExplosionPacket;
|
||||||
"x" => $this->source->x,
|
$pk->x = $this->source->x;
|
||||||
"y" => $this->source->y,
|
$pk->y = $this->source->y;
|
||||||
"z" => $this->source->z,
|
$pk->z = $this->source->z;
|
||||||
"radius" => $this->size,
|
$pk->radius = $this->size;
|
||||||
"records" => $send,
|
$pk->records = $send;
|
||||||
));
|
$server->api->player->broadcastPacket($this->level->players, $pk);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,11 @@ class Level{
|
|||||||
}
|
}
|
||||||
if($this->server->api->dhandle("time.change", array("level" => $this, "time" => $time)) !== false){
|
if($this->server->api->dhandle("time.change", array("level" => $this, "time" => $time)) !== false){
|
||||||
$this->time = $time;
|
$this->time = $time;
|
||||||
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::SET_TIME_PACKET, array(
|
|
||||||
"time" => (int) $this->time,
|
$pk = new SetTimePacket;
|
||||||
"started" => $this->stopTime == false,
|
$pk->time = (int) $this->time;
|
||||||
));
|
$pk->started = $this->stopTime == false;
|
||||||
|
$this->server->api->player->broadcastPacket($this->players, $pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,13 +110,13 @@ class Level{
|
|||||||
if(count($this->changedBlocks) > 0){
|
if(count($this->changedBlocks) > 0){
|
||||||
foreach($this->changedBlocks as $blocks){
|
foreach($this->changedBlocks as $blocks){
|
||||||
foreach($blocks as $b){
|
foreach($blocks as $b){
|
||||||
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::UPDATE_BLOCK_PACKET, array(
|
$pk = new UpdateBlockPacket;
|
||||||
"x" => $b->x,
|
$pk->x = $b->x;
|
||||||
"y" => $b->y,
|
$pk->y = $b->y;
|
||||||
"z" => $b->z,
|
$pk->z = $b->z;
|
||||||
"block" => $b->getID(),
|
$pk->block = $b->getID();
|
||||||
"meta" => $b->getMetadata(),
|
$pk->meta = $b->getMetadata();
|
||||||
));
|
$this->server->api->player->broadcastPacket($this->players, $pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->changedBlocks = array();
|
$this->changedBlocks = array();
|
||||||
@ -286,13 +287,13 @@ class Level{
|
|||||||
public function setBlockRaw(Vector3 $pos, Block $block, $direct = true, $send = true){
|
public function setBlockRaw(Vector3 $pos, Block $block, $direct = true, $send = true){
|
||||||
if(($ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata())) === true and $send !== false){
|
if(($ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata())) === true and $send !== false){
|
||||||
if($direct === true){
|
if($direct === true){
|
||||||
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::UPDATE_BLOCK_PACKET, array(
|
$pk = new UpdateBlockPacket;
|
||||||
"x" => $pos->x,
|
$pk->x = $pos->x;
|
||||||
"y" => $pos->y,
|
$pk->y = $pos->y;
|
||||||
"z" => $pos->z,
|
$pk->z = $pos->z;
|
||||||
"block" => $block->getID(),
|
$pk->block = $block->getID();
|
||||||
"meta" => $block->getMetadata(),
|
$pk->meta = $block->getMetadata();
|
||||||
));
|
$this->server->api->player->broadcastPacket($this->players, $pk);
|
||||||
}elseif($direct === false){
|
}elseif($direct === false){
|
||||||
if(!($pos instanceof Position)){
|
if(!($pos instanceof Position)){
|
||||||
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
||||||
@ -326,13 +327,13 @@ class Level{
|
|||||||
$block->position($pos);
|
$block->position($pos);
|
||||||
|
|
||||||
if($direct === true){
|
if($direct === true){
|
||||||
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::UPDATE_BLOCK_PACKET, array(
|
$pk = new UpdateBlockPacket;
|
||||||
"x" => $pos->x,
|
$pk->x = $pos->x;
|
||||||
"y" => $pos->y,
|
$pk->y = $pos->y;
|
||||||
"z" => $pos->z,
|
$pk->z = $pos->z;
|
||||||
"block" => $block->getID(),
|
$pk->block = $block->getID();
|
||||||
"meta" => $block->getMetadata(),
|
$pk->meta = $block->getMetadata();
|
||||||
));
|
$this->server->api->player->broadcastPacket($this->players, $pk);
|
||||||
}else{
|
}else{
|
||||||
$i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4);
|
$i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4);
|
||||||
if(!isset($this->changedBlocks[$i])){
|
if(!isset($this->changedBlocks[$i])){
|
||||||
|
@ -142,26 +142,27 @@ class Tile extends Position{
|
|||||||
}else{
|
}else{
|
||||||
$player->windows[$id] = $this;
|
$player->windows[$id] = $this;
|
||||||
}
|
}
|
||||||
$player->dataPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, array(
|
|
||||||
"windowid" => $id,
|
$pk = new ContainerOpenPacket;
|
||||||
"type" => WINDOW_CHEST,
|
$pk->windowid = $id;
|
||||||
"slots" => is_array($player->windows[$id]) ? CHEST_SLOTS << 1:CHEST_SLOTS,
|
$pk->type = WINDOW_CHEST;
|
||||||
"x" => $this->x,
|
$pk->slots = is_array($player->windows[$id]) ? CHEST_SLOTS << 1:CHEST_SLOTS;
|
||||||
"y" => $this->y,
|
$pk->x = $this->x;
|
||||||
"z" => $this->z,
|
$pk->y = $this->y;
|
||||||
));
|
$pk->z = $this->z;
|
||||||
|
$player->dataPacket($pk);
|
||||||
$slots = array();
|
$slots = array();
|
||||||
|
|
||||||
if(is_array($player->windows[$id])){
|
if(is_array($player->windows[$id])){
|
||||||
$all = $this->server->api->player->getAll($this->level);
|
$all = $this->server->api->player->getAll($this->level);
|
||||||
foreach($player->windows[$id] as $ob){
|
foreach($player->windows[$id] as $ob){
|
||||||
$this->server->api->player->broadcastPacket($all, ProtocolInfo::TILE_EVENT_PACKET, array(
|
$pk = new TileEventPacket;
|
||||||
"x" => $ob->x,
|
$pk->x = $ob->x;
|
||||||
"y" => $ob->y,
|
$pk->y = $ob->y;
|
||||||
"z" => $ob->z,
|
$pk->z = $ob->z;
|
||||||
"case1" => 1,
|
$pk->case1 = 1;
|
||||||
"case2" => 2,
|
$pk->case2 = 2;
|
||||||
));
|
$this->server->api->player->broadcastPacket($all, $pk);
|
||||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||||
$slot = $ob->getSlot($s);
|
$slot = $ob->getSlot($s);
|
||||||
if($slot->getID() > AIR and $slot->count > 0){
|
if($slot->getID() > AIR and $slot->count > 0){
|
||||||
@ -172,13 +173,13 @@ class Tile extends Position{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), ProtocolInfo::TILE_EVENT_PACKET, array(
|
$pk = new TileEventPacket;
|
||||||
"x" => $this->x,
|
$pk->x = $this->x;
|
||||||
"y" => $this->y,
|
$pk->y = $this->y;
|
||||||
"z" => $this->z,
|
$pk->z = $this->z;
|
||||||
"case1" => 1,
|
$pk->case1 = 1;
|
||||||
"case2" => 2,
|
$pk->case2 = 2;
|
||||||
));
|
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), $pk);
|
||||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||||
$slot = $this->getSlot($s);
|
$slot = $this->getSlot($s);
|
||||||
if($slot->getID() > AIR and $slot->count > 0){
|
if($slot->getID() > AIR and $slot->count > 0){
|
||||||
@ -188,24 +189,26 @@ class Tile extends Position{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$player->dataPacket(ProtocolInfo::CONTAINER_SET_CONTENT_PACKET, array(
|
|
||||||
"windowid" => $id,
|
$pk = new ContainerSetContentPacket;
|
||||||
"count" => count($slots),
|
$pk->windowid = $id;
|
||||||
"slots" => $slots,
|
$pk->slots = $slots;
|
||||||
));
|
$player->dataPacket($pk);
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->class === TILE_FURNACE){
|
}elseif($this->class === TILE_FURNACE){
|
||||||
$player->windowCnt++;
|
$player->windowCnt++;
|
||||||
$player->windowCnt = $id = max(2, $player->windowCnt % 99);
|
$player->windowCnt = $id = max(2, $player->windowCnt % 99);
|
||||||
$player->windows[$id] = $this;
|
$player->windows[$id] = $this;
|
||||||
$player->dataPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, array(
|
|
||||||
"windowid" => $id,
|
$pk = new ContainerOpenPacket;
|
||||||
"type" => WINDOW_FURNACE,
|
$pk->windowid = $id;
|
||||||
"slots" => FURNACE_SLOTS,
|
$pk->type = WINDOW_FURNACE;
|
||||||
"x" => $this->x,
|
$pk->slots = FURNACE_SLOTS;
|
||||||
"y" => $this->y,
|
$pk->x = $this->x;
|
||||||
"z" => $this->z
|
$pk->y = $this->y;
|
||||||
));
|
$pk->z = $this->z;
|
||||||
|
$player->dataPacket($pk);
|
||||||
|
|
||||||
$slots = array();
|
$slots = array();
|
||||||
for($s = 0; $s < FURNACE_SLOTS; ++$s){
|
for($s = 0; $s < FURNACE_SLOTS; ++$s){
|
||||||
$slot = $this->getSlot($s);
|
$slot = $this->getSlot($s);
|
||||||
@ -215,11 +218,10 @@ class Tile extends Position{
|
|||||||
$slots[] = BlockAPI::getItem(AIR, 0, 0);
|
$slots[] = BlockAPI::getItem(AIR, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$player->dataPacket(ProtocolInfo::CONTAINER_SET_CONTENT_PACKET, array(
|
$pk = new ContainerSetContentPacket;
|
||||||
"windowid" => $id,
|
$pk->windowid = $id;
|
||||||
"count" => count($slots),
|
$pk->slots = $slots;
|
||||||
"slots" => $slots
|
$player->dataPacket($pk);
|
||||||
));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,12 +385,12 @@ class Tile extends Position{
|
|||||||
|
|
||||||
$nbt->write(chr(NBT::TAG_END));
|
$nbt->write(chr(NBT::TAG_END));
|
||||||
|
|
||||||
$player->dataPacket(ProtocolInfo::ENTITY_DATA_PACKET, array(
|
$pk = new EntityDataPacket;
|
||||||
"x" => $this->x,
|
$pk->x = $this->x;
|
||||||
"y" => $this->y,
|
$pk->y = $this->y;
|
||||||
"z" => $this->z,
|
$pk->z = $this->z;
|
||||||
"namedtag" => $nbt->binary,
|
$pk->namedtag = $nbt->binary;
|
||||||
));
|
$player->dataPacket($pk);
|
||||||
break;
|
break;
|
||||||
case TILE_SIGN:
|
case TILE_SIGN:
|
||||||
$nbt = new NBT();
|
$nbt = new NBT();
|
||||||
@ -428,12 +430,12 @@ class Tile extends Position{
|
|||||||
|
|
||||||
$nbt->write(chr(NBT::TAG_END));
|
$nbt->write(chr(NBT::TAG_END));
|
||||||
|
|
||||||
$player->dataPacket(ProtocolInfo::ENTITY_DATA_PACKET, array(
|
$pk = new EntityDataPacket;
|
||||||
"x" => $this->x,
|
$pk->x = $this->x;
|
||||||
"y" => $this->y,
|
$pk->y = $this->y;
|
||||||
"z" => $this->z,
|
$pk->z = $this->z;
|
||||||
"namedtag" => $nbt->binary,
|
$pk->namedtag = $nbt->binary;
|
||||||
));
|
$player->dataPacket($pk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user