I can spawn!!

This commit is contained in:
Shoghi Cervantes 2014-02-28 19:47:08 +01:00
parent f1d6726615
commit c488c19db9
33 changed files with 112 additions and 102 deletions

View File

@ -98,7 +98,9 @@ abstract class Entity extends Position{
public abstract function spawnTo(Player $player); public abstract function spawnTo(Player $player);
abstract function attackEntity($damage, $source = "generic"); abstract function attack($damage, $source = "generic");
abstract function heal($amount, $source = "generic");
public function onUpdate(){ public function onUpdate(){
if($this->closed !== false){ if($this->closed !== false){
@ -207,7 +209,11 @@ abstract class Entity extends Position{
} }
public function setPositionAndRotation(Vector3 $pos, $yaw, $pitch){ //TODO public function setPositionAndRotation(Vector3 $pos, $yaw, $pitch){ //TODO
$this->x = $pos->x;
$this->y = $pos->y;
$this->z = $pos->z;
$this->yaw = $yaw;
$this->pitch = $pitch;
} }
public function onCollideWithPlayer(EntityPlayer $entityPlayer){ public function onCollideWithPlayer(EntityPlayer $entityPlayer){
@ -306,4 +312,7 @@ require_once("entity/HumanEntity.php");
require_once("entity/ProjectileEntity.php"); require_once("entity/ProjectileEntity.php");
require_once("entity/VehicleEntity.php"); require_once("entity/VehicleEntity.php");
require_once("entity/HangingEntity.php"); require_once("entity/HangingEntity.php");
require_once("entity/HumanEntity.php");
require_once("entity/PlayerEntity.php");
/***REM_END***/ /***REM_END***/

View File

@ -20,8 +20,7 @@
*/ */
class Player{ class Player extends PlayerEntity{
private $server;
private $recoveryQueue = array(); private $recoveryQueue = array();
private $receiveQueue = array(); private $receiveQueue = array();
private $resendQueue = array(); private $resendQueue = array();
@ -41,12 +40,8 @@ class Player{
private $counter = array(0, 0, 0, 0); private $counter = array(0, 0, 0, 0);
private $username; private $username;
private $iusername; private $iusername;
private $eid = false;
private $startAction = false; private $startAction = false;
private $isSleeping = false; private $isSleeping = false;
public $data;
/** @var \Entity */
public $entity = false;
public $auth = false; public $auth = false;
public $CID; public $CID;
public $MTU; public $MTU;
@ -82,8 +77,6 @@ class Player{
private $chunkCount = array(); private $chunkCount = array();
private $received = array(); private $received = array();
public $loginData = array(); public $loginData = array();
/** @var \Level */
public $level;
public function __get($name){ public function __get($name){
if(isset($this->{$name})){ if(isset($this->{$name})){
@ -147,14 +140,14 @@ class Player{
} }
public function orderChunks(){ public function orderChunks(){
if(!($this->entity instanceof Entity) or $this->connected === false){ if($this->connected === false){
return false; return false;
} }
$newOrder = array(); $newOrder = array();
$lastLoaded = $this->chunksLoaded; $lastLoaded = $this->chunksLoaded;
$centerX = intval(($this->entity->x - 0.5) / 16); $centerX = intval(($this->x - 0.5) / 16);
$centerZ = intval(($this->entity->z - 0.5) / 16); $centerZ = intval(($this->z - 0.5) / 16);
$startX = $centerX - $this->viewDistance; $startX = $centerX - $this->viewDistance;
$startZ = $centerZ - $this->viewDistance; $startZ = $centerZ - $this->viewDistance;
$finalX = $centerX + $this->viewDistance; $finalX = $centerX + $this->viewDistance;
@ -556,7 +549,7 @@ class Player{
switch($event){ switch($event){
case "tile.update": case "tile.update":
if($data->level === $this->level){ if($data->level === $this->level){
if($data->class === Tile::FURNACE){ if($data instanceof FurnaceTile){
foreach($this->windows as $id => $w){ foreach($this->windows as $id => $w){
if($w === $data){ if($w === $data){
$pk = new ContainerSetDataPacket; $pk = new ContainerSetDataPacket;
@ -899,22 +892,19 @@ class Player{
* @return boolean * @return boolean
*/ */
public function teleport(Vector3 $pos, $yaw = false, $pitch = false, $terrain = true, $force = true){ public function teleport(Vector3 $pos, $yaw = false, $pitch = false, $terrain = true, $force = true){
if($this->entity instanceof Entity and $this->level instanceof Level){ if($this->level instanceof Level){
$this->entity->check = false;
if($yaw === false){ if($yaw === false){
$yaw = $this->entity->yaw; $yaw = $this->yaw;
} }
if($pitch === false){ if($pitch === false){
$pitch = $this->entity->pitch; $pitch = $this->pitch;
} }
if($this->server->api->dhandle("player.teleport", array("player" => $this, "target" => $pos)) === false){ if($this->server->api->dhandle("player.teleport", array("player" => $this, "target" => $pos)) === false){
$this->entity->check = true;
return false; return false;
} }
if($pos instanceof Position and $pos->level instanceof Level and $pos->level !== $this->level){ /*if($pos instanceof Position and $pos->level instanceof Level and $pos->level !== $this->level){
if($this->server->api->dhandle("player.teleport.level", array("player" => $this, "origin" => $this->level, "target" => $pos->level)) === false){ if($this->server->api->dhandle("player.teleport.level", array("player" => $this, "origin" => $this->level, "target" => $pos->level)) === false){
$this->entity->check = true;
return false; return false;
} }
@ -987,20 +977,20 @@ class Player{
$player->sendArmor($this); $player->sendArmor($this);
} }
} }
} }*/
$this->lastCorrect = $pos; $this->lastCorrect = $pos;
$this->entity->fallY = false; /*$this->entity->fallY = false;
$this->entity->fallStart = false; $this->entity->fallStart = false;*/
$this->entity->setPosition($pos, $yaw, $pitch); $this->setPosition($pos, $yaw, $pitch);
$this->entity->resetSpeed(); /*$this->entity->resetSpeed();
$this->entity->updateLast(); $this->entity->updateLast();
$this->entity->calculateVelocity(); $this->entity->calculateVelocity();*/
if($terrain === true){ if($terrain === true){
$this->orderChunks(); $this->orderChunks();
$this->getNextChunk(); $this->getNextChunk();
} }
$this->entity->check = true; //$this->entity->check = true;
if($force === true){ if($force === true){
$this->forceMovement = $pos; $this->forceMovement = $pos;
} }
@ -1418,12 +1408,16 @@ class Player{
$this->slot = -1;//0 $this->slot = -1;//0
$this->hotbar = array(-1, -1, -1, -1, -1, -1, -1, -1, -1); $this->hotbar = array(-1, -1, -1, -1, -1, -1, -1, -1, -1);
} }
$this->entity = $this->server->api->entity->add($this->level, ENTITY_PLAYER, 0, array("player" => $this));
$this->eid = $this->entity->eid; parent::__construct($this->level, new NBTTag_Compound(false, array(
$this->server->query("UPDATE players SET EID = ".$this->eid." WHERE CID = ".$this->CID.";"); "Pos" => new NBTTag_List("Pos", array(
$this->entity->x = $this->data->get("position")["x"]; 0 => new NBTTag_Double(0, $this->data->get("position")["x"]),
$this->entity->y = $this->data->get("position")["y"]; 1 => new NBTTag_Double(1, $this->data->get("position")["y"]),
$this->entity->z = $this->data->get("position")["z"]; 2 => new NBTTag_Double(2, $this->data->get("position")["z"])
)),
"NameTag" => new NBTTag_String("NameTag", $this->username),
)));
$this->namedtag->Pos->setTagType(NBTTag::TAG_Double);
if(($level = $this->server->api->level->get($this->data->get("spawn")["level"])) !== false){ if(($level = $this->server->api->level->get($this->data->get("spawn")["level"])) !== false){
$this->spawnPosition = new Position($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"], $level); $this->spawnPosition = new Position($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"], $level);
@ -1433,9 +1427,7 @@ class Player{
$pk->z = (int) $this->spawnPosition->z; $pk->z = (int) $this->spawnPosition->z;
$this->dataPacket($pk); $this->dataPacket($pk);
} }
$this->entity->check = false;
$this->entity->setName($this->username);
$this->entity->data["CID"] = $this->CID;
$this->evid[] = $this->server->event("server.chat", array($this, "eventHandler")); $this->evid[] = $this->server->event("server.chat", array($this, "eventHandler"));
$this->evid[] = $this->server->event("entity.motion", array($this, "eventHandler")); $this->evid[] = $this->server->event("entity.motion", array($this, "eventHandler"));
$this->evid[] = $this->server->event("entity.animate", array($this, "eventHandler")); $this->evid[] = $this->server->event("entity.animate", array($this, "eventHandler"));
@ -1448,7 +1440,7 @@ class Player{
$this->evid[] = $this->server->event("tile.update", array($this, "eventHandler")); $this->evid[] = $this->server->event("tile.update", array($this, "eventHandler"));
$this->lastMeasure = microtime(true); $this->lastMeasure = microtime(true);
$this->server->schedule(50, array($this, "measureLag"), array(), true); $this->server->schedule(50, array($this, "measureLag"), array(), true);
console("[INFO] ".TextFormat::AQUA.$this->username.TextFormat::RESET."[/".$this->ip.":".$this->port."] logged in with entity id ".$this->eid." at (".$this->entity->level->getName().", ".round($this->entity->x, 2).", ".round($this->entity->y, 2).", ".round($this->entity->z, 2).")"); console("[INFO] ".TextFormat::AQUA.$this->username.TextFormat::RESET."[/".$this->ip.":".$this->port."] logged in with entity id ".$this->id." at (".$this->level->getName().", ".round($this->x, 4).", ".round($this->y, 4).", ".round($this->z, 4).")");
break; break;
case ProtocolInfo::READY_PACKET: case ProtocolInfo::READY_PACKET:
if($this->loggedIn === false){ if($this->loggedIn === false){
@ -1459,19 +1451,16 @@ class Player{
if($this->spawned !== false){ if($this->spawned !== false){
break; break;
} }
$this->entity->setHealth($this->data->get("health"), "spawn", true); $this->heal($this->data->get("health"), "spawn", true);
$this->spawned = true; $this->spawned = true;
//TODO //TODO
$this->server->api->player->spawnAllPlayers($this); //$this->server->api->player->spawnAllPlayers($this);
//TODO //TODO
$this->server->api->player->spawnToAllPlayers($this); //$this->server->api->player->spawnToAllPlayers($this);
//TODO //TODO
$this->server->api->entity->spawnAll($this); //$this->server->api->entity->spawnAll($this);
$this->entity->spawnToAll(); $this->spawnToAll();
//$this->sendArmor();
$this->server->schedule(5, array($this->entity, "update"), array(), true);
$this->server->schedule(2, array($this->entity, "updateMovement"), array(), true);
$this->sendArmor();
$this->sendChat($this->server->motd."\n"); $this->sendChat($this->server->motd."\n");
if($this->iusername === "steve" or $this->iusername === "stevie"){ if($this->iusername === "steve" or $this->iusername === "stevie"){
@ -1486,19 +1475,16 @@ class Player{
$pk->time = $this->level->getTime(); $pk->time = $this->level->getTime();
$this->dataPacket($pk); $this->dataPacket($pk);
$pos = new Position($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"], $this->level); $pos = new Position($this->x, $this->y, $this->z, $this->level);
$pos = $this->level->getSafeSpawn($pos); $pos = $this->level->getSafeSpawn($pos);
$this->teleport($pos); $this->teleport($pos);
$this->server->schedule(10, array($this, "teleport"), $pos);
$this->server->schedule(20, array($this, "teleport"), $pos);
$this->server->schedule(30, array($this, "teleport"), $pos);
$this->server->handle("player.spawn", $this); $this->server->handle("player.spawn", $this);
break; break;
case 2://Chunk loaded? case 2://Chunk loaded?
break; break;
} }
break; break;
case ProtocolInfo::ROTATE_HEAD_PACKET: /*case ProtocolInfo::ROTATE_HEAD_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
@ -1511,22 +1497,22 @@ class Player{
$this->entity->setPosition($this->entity, $packet->yaw, $this->entity->pitch); $this->entity->setPosition($this->entity, $packet->yaw, $this->entity->pitch);
} }
} }
break; break;*/
case ProtocolInfo::MOVE_PLAYER_PACKET: case ProtocolInfo::MOVE_PLAYER_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
if(($this->entity instanceof Entity) and $packet->messageIndex > $this->lastMovement){ if($packet->messageIndex > $this->lastMovement){
$this->lastMovement = $packet->messageIndex; $this->lastMovement = $packet->messageIndex;
$newPos = new Vector3($packet->x, $packet->y, $packet->z); $newPos = new Vector3($packet->x, $packet->y, $packet->z);
if($this->forceMovement instanceof Vector3){ /*if($this->forceMovement instanceof Vector3){
if($this->forceMovement->distance($newPos) <= 0.7){ if($this->forceMovement->distance($newPos) <= 0.7){
$this->forceMovement = false; $this->forceMovement = false;
}else{ }else{
$this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false); $this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false);
} }
} }*/
$speed = $this->entity->getSpeedMeasure(); /*$speed = $this->entity->getSpeedMeasure();
if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){ if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){
if($this->lastCorrect instanceof Vector3){ if($this->lastCorrect instanceof Vector3){
$this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
@ -1534,16 +1520,16 @@ class Player{
if($this->blocked !== true){ if($this->blocked !== true){
console("[WARNING] ".$this->username." moved too quickly!"); console("[WARNING] ".$this->username." moved too quickly!");
} }
}else{ }else{*/
$this->entity->setPosition($newPos, $packet->yaw, $packet->pitch); $this->setPosition($newPos, $packet->yaw, $packet->pitch);
} //}
} }
break; break;
case ProtocolInfo::PLAYER_EQUIPMENT_PACKET: /*case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
$packet->eid = $this->eid; $packet->eid = $this->id;
$data = array(); $data = array();
$data["eid"] = $packet->eid; $data["eid"] = $packet->eid;
@ -1600,10 +1586,10 @@ class Player{
$this->entity->inAction = false; $this->entity->inAction = false;
$this->entity->updateMetadata(); $this->entity->updateMetadata();
} }
break; break;*/
case ProtocolInfo::REQUEST_CHUNK_PACKET: case ProtocolInfo::REQUEST_CHUNK_PACKET:
break; break;
case ProtocolInfo::USE_ITEM_PACKET: /*case ProtocolInfo::USE_ITEM_PACKET:
if(!($this->entity instanceof Entity)){ if(!($this->entity instanceof Entity)){
break; break;
} }
@ -1688,8 +1674,8 @@ class Player{
$this->startAction = microtime(true); $this->startAction = microtime(true);
$this->entity->updateMetadata(); $this->entity->updateMetadata();
} }
break; break;*/
case ProtocolInfo::PLAYER_ACTION_PACKET: /*case ProtocolInfo::PLAYER_ACTION_PACKET:
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
@ -1764,8 +1750,8 @@ class Player{
case 6: //get out of the bed case 6: //get out of the bed
$this->stopSleep(); $this->stopSleep();
} }
break; break;*/
case ProtocolInfo::REMOVE_BLOCK_PACKET: /*case ProtocolInfo::REMOVE_BLOCK_PACKET:
$blockVector = new Vector3($packet->x, $packet->y, $packet->z); $blockVector = new Vector3($packet->x, $packet->y, $packet->z);
if($this->spawned === false or $this->blocked === true or $this->entity->distance($blockVector) > 8){ if($this->spawned === false or $this->blocked === true or $this->entity->distance($blockVector) > 8){
$target = $this->level->getBlock($blockVector); $target = $this->level->getBlock($blockVector);
@ -1782,8 +1768,8 @@ class Player{
$this->craftingItems = array(); $this->craftingItems = array();
$this->toCraft = array(); $this->toCraft = array();
$this->server->api->block->playerBlockBreak($this, $blockVector); $this->server->api->block->playerBlockBreak($this, $blockVector);
break; break;*/
case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET: /*case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET:
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
@ -1820,8 +1806,8 @@ class Player{
$this->entity->inAction = false; $this->entity->inAction = false;
$this->entity->updateMetadata(); $this->entity->updateMetadata();
} }
break; break;*/
case ProtocolInfo::INTERACT_PACKET: /*case ProtocolInfo::INTERACT_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
@ -1836,7 +1822,7 @@ class Player{
if($target instanceof Entity and $this->entity instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){ if($target instanceof Entity and $this->entity instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){
$data["targetentity"] = $target; $data["targetentity"] = $target;
$data["entity"] = $this->entity; $data["entity"] = $this->entity;
if($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){ if($target instanceof PlayerEntity and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){
break; break;
}elseif($this->server->handle("player.interact", $data) !== false){ }elseif($this->server->handle("player.interact", $data) !== false){
$slot = $this->getSlot($this->slot); $slot = $this->getSlot($this->slot);
@ -1909,14 +1895,14 @@ class Player{
} }
} }
break; break;*/
case ProtocolInfo::ANIMATE_PACKET: /*case ProtocolInfo::ANIMATE_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
} }
$packet->eid = $this->eid; $packet->eid = $this->eid;
$this->server->api->dhandle("entity.animate", array("eid" => $packet->eid, "entity" => $this->entity, "action" => $packet->action)); $this->server->api->dhandle("entity.animate", array("eid" => $packet->eid, "entity" => $this->entity, "action" => $packet->action));
break; break;*/
case ProtocolInfo::RESPAWN_PACKET: case ProtocolInfo::RESPAWN_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
@ -1941,7 +1927,7 @@ class Player{
break; break;
case ProtocolInfo::SET_HEALTH_PACKET: //Not used case ProtocolInfo::SET_HEALTH_PACKET: //Not used
break; break;
case ProtocolInfo::ENTITY_EVENT_PACKET: /*case ProtocolInfo::ENTITY_EVENT_PACKET:
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
@ -1994,8 +1980,8 @@ class Player{
} }
break; break;
} }
break; break;*/
case ProtocolInfo::DROP_ITEM_PACKET: /*case ProtocolInfo::DROP_ITEM_PACKET:
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;
} }
@ -2016,7 +2002,7 @@ class Player{
$this->entity->inAction = false; $this->entity->inAction = false;
$this->entity->updateMetadata(); $this->entity->updateMetadata();
} }
break; break;*/
case ProtocolInfo::MESSAGE_PACKET: case ProtocolInfo::MESSAGE_PACKET:
if($this->spawned === false){ if($this->spawned === false){
break; break;
@ -2056,7 +2042,7 @@ class Player{
$pk->case2 = 0; $pk->case2 = 0;
$this->server->api->player->broadcastPacket($this->level->players, $pk); $this->server->api->player->broadcastPacket($this->level->players, $pk);
} }
}elseif($this->windows[$packet->windowid]->class === Tile::CHEST){ }elseif($this->windows[$packet->windowid] instanceof ChestTile){
$pk = new TileEventPacket; $pk = new TileEventPacket;
$pk->x = $this->windows[$packet->windowid]->x; $pk->x = $this->windows[$packet->windowid]->x;
$pk->y = $this->windows[$packet->windowid]->y; $pk->y = $this->windows[$packet->windowid]->y;
@ -2183,7 +2169,16 @@ class Player{
$tile->setSlot($slotn, $item, true, $offset); $tile->setSlot($slotn, $item, true, $offset);
}else{ }else{
$tile = $this->windows[$packet->windowid]; $tile = $this->windows[$packet->windowid];
if(($tile->class !== Tile::CHEST and $tile->class !== Tile::FURNACE) or $packet->slot < 0 or ($tile->class === Tile::CHEST and $packet->slot >= ChestTile::SLOTS) or ($tile->class === Tile::FURNACE and $packet->slot >= FurnaceTile::SLOTS)){ if(
!($tile instanceof ChestTile or $tile instanceof FurnaceTile)
or $packet->slot < 0
or (
$tile instanceof ChestTile
and $packet->slot >= ChestTile::SLOTS
) or (
$tile instanceof FurnaceTile and $packet->slot >= FurnaceTile::SLOTS
)
){
break; break;
} }
$item = BlockAPI::getItem($packet->item->getID(), $packet->item->getMetadata(), $packet->item->count); $item = BlockAPI::getItem($packet->item->getID(), $packet->item->getMetadata(), $packet->item->count);
@ -2204,7 +2199,7 @@ class Player{
break; break;
} }
if($tile->class === Tile::FURNACE and $packet->slot == 2){ if($tile instanceof FurnaceTile and $packet->slot == 2){
switch($slot->getID()){ switch($slot->getID()){
case IRON_INGOT: case IRON_INGOT:
AchievementAPI::grantAchievement($this, "acquireIron"); AchievementAPI::grantAchievement($this, "acquireIron");

View File

@ -34,7 +34,6 @@ abstract class Tile extends Position{
public $x; public $x;
public $y; public $y;
public $z; public $z;
public $class;
public $attach; public $attach;
public $metadata; public $metadata;
public $closed; public $closed;
@ -64,7 +63,6 @@ abstract class Tile extends Position{
$this->lastUpdate = microtime(true); $this->lastUpdate = microtime(true);
$this->id = Tile::$tileCount++; $this->id = Tile::$tileCount++;
Tile::$list[$this->id] = $this; Tile::$list[$this->id] = $this;
$this->class = $this->namedtag->id;
$this->x = (int) $this->namedtag->x; $this->x = (int) $this->namedtag->x;
$this->y = (int) $this->namedtag->y; $this->y = (int) $this->namedtag->y;
$this->z = (int) $this->namedtag->z; $this->z = (int) $this->namedtag->z;

View File

@ -96,7 +96,7 @@ require_once(FILE_PATH."/src/math/Vector3.php");
require_once(FILE_PATH."/src/math/Position.php"); require_once(FILE_PATH."/src/math/Position.php");
require_once(FILE_PATH."/src/pmf/PMF.php"); require_once(FILE_PATH."/src/pmf/PMF.php");
require_all(FILE_PATH . "src/"); require_all(FILE_PATH . "src/", array("notimplemented")); //REMOVE LATER!
$inc = get_included_files(); $inc = get_included_files();
$inc[] = array_shift($inc); $inc[] = array_shift($inc);

View File

@ -24,8 +24,8 @@ class HumanEntity extends CreatureEntity implements ProjectileSourceEntity{
protected $nameTag; protected $nameTag;
protected function initEntity(){ protected function initEntity(){
if(isset($this->namedtag->nameTag)){ if(isset($this->namedtag->NameTag)){
$this->nameTag = $this->namedtag->nameTag; $this->nameTag = $this->namedtag->NameTag;
} }
} }
@ -62,8 +62,20 @@ class HumanEntity extends CreatureEntity implements ProjectileSourceEntity{
$pk->slot = 0; $pk->slot = 0;
$player->dataPacket($pk);*/ $player->dataPacket($pk);*/
$this->sendEquipment($player) $this->sendEquipment($player);
$this->sendArmor($player); $this->sendArmor($player);
} }
public function getMetadata(){
return array();
}
public function attack($damage, $source = "generic"){
}
public function heal($amount, $source = "generic"){
}
} }

View File

@ -30,7 +30,7 @@ class ChestTile extends SpawnableTile{
const SLOTS = 27; const SLOTS = 27;
public function __construct(Level $level, NBTTag_Compound $nbt){ public function __construct(Level $level, NBTTag_Compound $nbt){
$nbt->id = Tile::Chest; $nbt->id = Tile::CHEST;
parent::__construct($level, $nbt); parent::__construct($level, $nbt);
} }
@ -89,7 +89,7 @@ class ChestTile extends SpawnableTile{
$nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt = new NBT(NBT::LITTLE_ENDIAN);
if($this->isPaired()){ if($this->isPaired()){
$nbt->setData(new NBTTag_Compound("", array( $nbt->setData(new NBTTag_Compound("", array(
new NBTTag_String("id", $this->class), new NBTTag_String("id", Tile::CHEST),
new NBTTag_Int("x", (int) $this->x), new NBTTag_Int("x", (int) $this->x),
new NBTTag_Int("y", (int) $this->y), new NBTTag_Int("y", (int) $this->y),
new NBTTag_Int("z", (int) $this->z), new NBTTag_Int("z", (int) $this->z),
@ -98,7 +98,7 @@ class ChestTile extends SpawnableTile{
))); )));
}else{ }else{
$nbt->setData(new NBTTag_Compound("", array( $nbt->setData(new NBTTag_Compound("", array(
new NBTTag_String("id", $this->class), new NBTTag_String("id", Tile::CHEST),
new NBTTag_Int("x", (int) $this->x), new NBTTag_Int("x", (int) $this->x),
new NBTTag_Int("y", (int) $this->y), new NBTTag_Int("y", (int) $this->y),
new NBTTag_Int("z", (int) $this->z) new NBTTag_Int("z", (int) $this->z)

View File

@ -21,7 +21,7 @@
trait ContainerTileTrait{ trait ContainerTileTrait{
public function openInventory(Player $player){ public function openInventory(Player $player){
if($this->class === Tile::CHEST){ if($this instanceof ChestTile){
$player->windowCnt++; $player->windowCnt++;
$player->windowCnt = $id = max(2, $player->windowCnt % 99); $player->windowCnt = $id = max(2, $player->windowCnt % 99);
if(($pair = $this->getPair()) !== false){ if(($pair = $this->getPair()) !== false){
@ -92,7 +92,7 @@ trait ContainerTileTrait{
$pk->slots = $slots; $pk->slots = $slots;
$player->dataPacket($pk); $player->dataPacket($pk);
return true; return true;
}elseif($this->class === Tile::FURNACE){ }elseif($this instanceof FurnaceTile){
$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;
@ -124,9 +124,6 @@ trait ContainerTileTrait{
} }
public function getSlotIndex($s){ public function getSlotIndex($s){
if($this->class !== Tile::CHEST and $this->class !== Tile::FURNACE){
return false;
}
foreach($this->namedtag->Items as $i => $slot){ foreach($this->namedtag->Items as $i => $slot){
if($slot->Slot === $s){ if($slot->Slot === $s){
return $i; return $i;

View File

@ -29,7 +29,7 @@ class FurnaceTile extends Tile{
const SLOTS = 3; const SLOTS = 3;
public function __construct(Level $level, NBTTag_Compound $nbt){ public function __construct(Level $level, NBTTag_Compound $nbt){
$nbt->id = Tile::Furnace; $nbt->id = Tile::FURNACE;
parent::__construct($level, $nbt); parent::__construct($level, $nbt);
if(!isset($this->namedtag->BurnTime) or $this->namedtag->BurnTime < 0){ if(!isset($this->namedtag->BurnTime) or $this->namedtag->BurnTime < 0){
$this->namedtag->BurnTime = 0; $this->namedtag->BurnTime = 0;

View File

@ -26,7 +26,7 @@ require_once("SpawnableTile.php");
class SignTile extends SpawnableTile{ class SignTile extends SpawnableTile{
public function __construct(Level $level, NBTTag_Compound $nbt){ public function __construct(Level $level, NBTTag_Compound $nbt){
$nbt->id = Tile::Sign; $nbt->id = Tile::SIGN;
parent::__construct($level, $nbt); parent::__construct($level, $nbt);
} }
@ -60,7 +60,7 @@ class SignTile extends SpawnableTile{
new NBTTag_String("Text2", $this->namedtag->Text2), new NBTTag_String("Text2", $this->namedtag->Text2),
new NBTTag_String("Text3", $this->namedtag->Text3), new NBTTag_String("Text3", $this->namedtag->Text3),
new NBTTag_String("Text4", $this->namedtag->Text4), new NBTTag_String("Text4", $this->namedtag->Text4),
new NBTTag_String("id", $this->class), new NBTTag_String("id", Tile::SIGN),
new NBTTag_Int("x", (int) $this->x), new NBTTag_Int("x", (int) $this->x),
new NBTTag_Int("y", (int) $this->y), new NBTTag_Int("y", (int) $this->y),
new NBTTag_Int("z", (int) $this->z) new NBTTag_Int("z", (int) $this->z)

View File

@ -28,7 +28,7 @@ class Level{
public $tiles = array(); public $tiles = array();
public $chunkTiles = array(); public $chunkTiles = array();
public $nextSave, $players = array(), $level; public $nextSave, $level;
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime, $generator; private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime, $generator;
public function __construct(PMFLevel $level, $name){ public function __construct(PMFLevel $level, $name){
@ -109,7 +109,6 @@ class Level{
return false; return false;
} }
$now = microtime(true); $now = microtime(true);
$this->players = $this->server->api->player->getAll($this);
if($this->level->isGenerating === 0 and count($this->changedCount) > 0){ if($this->level->isGenerating === 0 and count($this->changedCount) > 0){
arsort($this->changedCount); arsort($this->changedCount);