"Working" server

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-06 02:11:20 +01:00
parent fc63676bde
commit 2fd71922ca
6 changed files with 36 additions and 15 deletions

View File

@ -136,9 +136,9 @@ class CustomPacketHandler{
break; break;
case 0x83: case 0x83:
if($this->c === false){ if($this->c === false){
$this->data["unknown1"] = Utils::readInt($this->get(4)); $this->data["status"] = Utils::readInt($this->get(4));
}else{ }else{
$this->raw .= Utils::writeInt($this->data["unknown1"]); $this->raw .= Utils::writeInt($this->data["status"]);
} }
break; break;
case 0x85: case 0x85:

View File

@ -96,6 +96,9 @@ class Packet{
case "triad": case "triad":
$this->addRaw(Utils::writeTriad($this->data[$field])); $this->addRaw(Utils::writeTriad($this->data[$field]));
break; break;
case "itriad":
$this->addRaw(strrev(Utils::writeTriad($this->data[$field])));
break;
case "int": case "int":
$this->addRaw(Utils::writeInt($this->data[$field])); $this->addRaw(Utils::writeInt($this->data[$field]));
break; break;
@ -188,6 +191,9 @@ class Packet{
case "triad": case "triad":
$this->data[] = Utils::readTriad($this->get(3)); $this->data[] = Utils::readTriad($this->get(3));
break; break;
case "itriad":
$this->data[] = Utils::readTriad(strrev($this->get(3)));
break;
case "int": case "int":
$this->data[] = Utils::readInt($this->get(4)); $this->data[] = Utils::readInt($this->get(4));
break; break;

View File

@ -36,7 +36,7 @@ class PocketMinecraftServer{
$this->username = $username; $this->username = $username;
$this->cnt = 1; $this->cnt = 1;
$this->serverID = Utils::getRandomBytes(8); $this->serverID = Utils::getRandomBytes(8);
$this->seed = "\x4f\xf0\x2d\x84"; $this->seed = Utils::getRandomBytes(4);//"\x4f\xf0\x2d\x84";
$this->events = array("disabled" => array()); $this->events = array("disabled" => array());
$this->actions = array(); $this->actions = array();
$this->clients = array(); $this->clients = array();
@ -45,7 +45,8 @@ class PocketMinecraftServer{
$this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, 19132, true, false); $this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, 19132, true, false);
console("[INFO] Creating Minecraft Server"); console("[INFO] Creating Minecraft Server");
console("[INFO] Username: ".$this->username); console("[INFO] Username: ".$this->username);
console("[INFO] Protocol: ".$this->protocol); console("[INFO] Seed: ".Utils::readInt($this->seed));
//console("[INFO] Protocol: ".$this->protocol);
$this->stop = false; $this->stop = false;
} }

View File

@ -101,23 +101,35 @@ class Session{
case 0x82: case 0x82:
$this->username = $data["username"]; $this->username = $data["username"];
console("[INFO] User ".$this->username." connected from ".$this->ip.":".$this->port); console("[INFO] ".$this->username." connected from ".$this->ip.":".$this->port);
$this->send(0x84, array(
$this->counter[0],
0x00,
array(
"id" => 0x83,
"status" => 0,
),
));
++$this->counter[0];
$this->send(0x84, array( $this->send(0x84, array(
$this->counter[0], $this->counter[0],
0x00, 0x00,
array( array(
"id" => 0x87, "id" => 0x87,
"seed" => $this->server->seed, "seed" => $this->server->seed,
"x" => 0, "x" => 128,
"y" => 100, "y" => 100,
"z" => 0, "z" => 128,
"spawnX" => 0, "spawnX" => 0,
"spawnY" => 100, "spawnY" => 0,
"spawnZ" => 0, "spawnZ" => 0,
), ),
)); ));
++$this->counter[0]; ++$this->counter[0];
break; break;
case 0x84:
console("[INFO] ".$this->username." spawned!");
break;
} }
break; break;

View File

@ -81,25 +81,25 @@ $pstruct = array(
), ),
0x80 => array( 0x80 => array(
"triad", "itriad",
"ubyte", "ubyte",
"customData", "customData",
), ),
0x84 => array( 0x84 => array(
"triad", "itriad",
"ubyte", "ubyte",
"customData", "customData",
), ),
0x88 => array( 0x88 => array(
"triad", "itriad",
"ubyte", "ubyte",
"customData", "customData",
), ),
0x8c => array( 0x8c => array(
"triad", "itriad",
"ubyte", "ubyte",
"customData", "customData",
), ),
@ -107,14 +107,14 @@ $pstruct = array(
0xa0 => array( 0xa0 => array(
"short", "short",
"bool", "bool",
"triad", "itriad",
"special1", "special1",
), ),
0xc0 => array( 0xc0 => array(
"short", "short",
"bool", "bool",
"triad", "itriad",
"special1", "special1",
), ),

View File

@ -40,6 +40,8 @@ $dataName = array(
0x87 => "StartGame", 0x87 => "StartGame",
0x93 => "MoveEntity_PosRot", 0x93 => "MoveEntity_PosRot",
0x94 => "MovePlayer",
0x9d => "RequestChunk",
0xa4 => "SetEntityMotion", 0xa4 => "SetEntityMotion",
); );