More classes updated

This commit is contained in:
Shoghi Cervantes
2014-02-07 17:07:57 +01:00
parent 95bff304e4
commit 083bfcc83c
7 changed files with 122 additions and 485 deletions

View File

@ -114,13 +114,13 @@ class Explosion{
$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);
}
$server->api->player->broadcastPacket($server->api->player->getAll($this->level), ProtocolInfo::EXPLOSION_PACKET, array(
"x" => $this->source->x,
"y" => $this->source->y,
"z" => $this->source->z,
"radius" => $this->size,
"records" => $send,
));
$pk = new ExplosionPacket;
$pk->x = $this->source->x;
$pk->y = $this->source->y;
$pk->z = $this->source->z;
$pk->radius = $this->size;
$pk->records = $send;
$server->api->player->broadcastPacket($this->level->players, $pk);
}
}

View File

@ -78,10 +78,11 @@ class Level{
}
if($this->server->api->dhandle("time.change", array("level" => $this, "time" => $time)) !== false){
$this->time = $time;
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::SET_TIME_PACKET, array(
"time" => (int) $this->time,
"started" => $this->stopTime == false,
));
$pk = new SetTimePacket;
$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){
foreach($this->changedBlocks as $blocks){
foreach($blocks as $b){
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::UPDATE_BLOCK_PACKET, array(
"x" => $b->x,
"y" => $b->y,
"z" => $b->z,
"block" => $b->getID(),
"meta" => $b->getMetadata(),
));
$pk = new UpdateBlockPacket;
$pk->x = $b->x;
$pk->y = $b->y;
$pk->z = $b->z;
$pk->block = $b->getID();
$pk->meta = $b->getMetadata();
$this->server->api->player->broadcastPacket($this->players, $pk);
}
}
$this->changedBlocks = array();
@ -286,13 +287,13 @@ class Level{
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($direct === true){
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::UPDATE_BLOCK_PACKET, array(
"x" => $pos->x,
"y" => $pos->y,
"z" => $pos->z,
"block" => $block->getID(),
"meta" => $block->getMetadata(),
));
$pk = new UpdateBlockPacket;
$pk->x = $pos->x;
$pk->y = $pos->y;
$pk->z = $pos->z;
$pk->block = $block->getID();
$pk->meta = $block->getMetadata();
$this->server->api->player->broadcastPacket($this->players, $pk);
}elseif($direct === false){
if(!($pos instanceof Position)){
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
@ -326,13 +327,13 @@ class Level{
$block->position($pos);
if($direct === true){
$this->server->api->player->broadcastPacket($this->players, ProtocolInfo::UPDATE_BLOCK_PACKET, array(
"x" => $pos->x,
"y" => $pos->y,
"z" => $pos->z,
"block" => $block->getID(),
"meta" => $block->getMetadata(),
));
$pk = new UpdateBlockPacket;
$pk->x = $pos->x;
$pk->y = $pos->y;
$pk->z = $pos->z;
$pk->block = $block->getID();
$pk->meta = $block->getMetadata();
$this->server->api->player->broadcastPacket($this->players, $pk);
}else{
$i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4);
if(!isset($this->changedBlocks[$i])){

View File

@ -142,26 +142,27 @@ class Tile extends Position{
}else{
$player->windows[$id] = $this;
}
$player->dataPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, array(
"windowid" => $id,
"type" => WINDOW_CHEST,
"slots" => is_array($player->windows[$id]) ? CHEST_SLOTS << 1:CHEST_SLOTS,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z,
));
$pk = new ContainerOpenPacket;
$pk->windowid = $id;
$pk->type = WINDOW_CHEST;
$pk->slots = is_array($player->windows[$id]) ? CHEST_SLOTS << 1:CHEST_SLOTS;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$player->dataPacket($pk);
$slots = array();
if(is_array($player->windows[$id])){
$all = $this->server->api->player->getAll($this->level);
foreach($player->windows[$id] as $ob){
$this->server->api->player->broadcastPacket($all, ProtocolInfo::TILE_EVENT_PACKET, array(
"x" => $ob->x,
"y" => $ob->y,
"z" => $ob->z,
"case1" => 1,
"case2" => 2,
));
foreach($player->windows[$id] as $ob){
$pk = new TileEventPacket;
$pk->x = $ob->x;
$pk->y = $ob->y;
$pk->z = $ob->z;
$pk->case1 = 1;
$pk->case2 = 2;
$this->server->api->player->broadcastPacket($all, $pk);
for($s = 0; $s < CHEST_SLOTS; ++$s){
$slot = $ob->getSlot($s);
if($slot->getID() > AIR and $slot->count > 0){
@ -172,13 +173,13 @@ class Tile extends Position{
}
}
}else{
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), ProtocolInfo::TILE_EVENT_PACKET, array(
"x" => $this->x,
"y" => $this->y,
"z" => $this->z,
"case1" => 1,
"case2" => 2,
));
$pk = new TileEventPacket;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->case1 = 1;
$pk->case2 = 2;
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), $pk);
for($s = 0; $s < CHEST_SLOTS; ++$s){
$slot = $this->getSlot($s);
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,
"count" => count($slots),
"slots" => $slots,
));
$pk = new ContainerSetContentPacket;
$pk->windowid = $id;
$pk->slots = $slots;
$player->dataPacket($pk);
return true;
}elseif($this->class === TILE_FURNACE){
$player->windowCnt++;
$player->windowCnt = $id = max(2, $player->windowCnt % 99);
$player->windows[$id] = $this;
$player->dataPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, array(
"windowid" => $id,
"type" => WINDOW_FURNACE,
"slots" => FURNACE_SLOTS,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z
));
$pk = new ContainerOpenPacket;
$pk->windowid = $id;
$pk->type = WINDOW_FURNACE;
$pk->slots = FURNACE_SLOTS;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$player->dataPacket($pk);
$slots = array();
for($s = 0; $s < FURNACE_SLOTS; ++$s){
$slot = $this->getSlot($s);
@ -215,11 +218,10 @@ class Tile extends Position{
$slots[] = BlockAPI::getItem(AIR, 0, 0);
}
}
$player->dataPacket(ProtocolInfo::CONTAINER_SET_CONTENT_PACKET, array(
"windowid" => $id,
"count" => count($slots),
"slots" => $slots
));
$pk = new ContainerSetContentPacket;
$pk->windowid = $id;
$pk->slots = $slots;
$player->dataPacket($pk);
return true;
}
}
@ -383,12 +385,12 @@ class Tile extends Position{
$nbt->write(chr(NBT::TAG_END));
$player->dataPacket(ProtocolInfo::ENTITY_DATA_PACKET, array(
"x" => $this->x,
"y" => $this->y,
"z" => $this->z,
"namedtag" => $nbt->binary,
));
$pk = new EntityDataPacket;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->namedtag = $nbt->binary;
$player->dataPacket($pk);
break;
case TILE_SIGN:
$nbt = new NBT();
@ -428,12 +430,12 @@ class Tile extends Position{
$nbt->write(chr(NBT::TAG_END));
$player->dataPacket(ProtocolInfo::ENTITY_DATA_PACKET, array(
"x" => $this->x,
"y" => $this->y,
"z" => $this->z,
"namedtag" => $nbt->binary,
));
$pk = new EntityDataPacket;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->namedtag = $nbt->binary;
$player->dataPacket($pk);
break;
}
}