mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Save placed blocks
This commit is contained in:
parent
b52a7ad28e
commit
fae7fae8ec
@ -46,7 +46,7 @@ Current features of the server:
|
||||
-------------------------------
|
||||
* Players can connect and move around the world (and see each other)
|
||||
* Support for reading/sending chunks!
|
||||
* Map saving!
|
||||
* Map saving! Place & remove blocks
|
||||
* Multiple worlds and importing!
|
||||
* PvP, life regeneration and death cause!
|
||||
* Extensible API!
|
||||
|
1
TODO
1
TODO
@ -1,4 +1,3 @@
|
||||
- Save placed blocks and relay them to other players.
|
||||
- Fix spawn position resetting
|
||||
- Mob spawning, item pick up
|
||||
- Fix metadata orientation
|
||||
|
@ -37,10 +37,36 @@ class LevelAPI{
|
||||
|
||||
public function init(){
|
||||
$this->server->addHandler("onBlockBreak", array($this, "handle"));
|
||||
$this->server->addHandler("onBlockPlace", array($this, "handle"));
|
||||
}
|
||||
|
||||
public function handle($data, $event){
|
||||
switch($event){
|
||||
case "onBlockPlace":
|
||||
switch($data["face"]){
|
||||
case 0:
|
||||
--$data["y"];
|
||||
break;
|
||||
case 1:
|
||||
++$data["y"];
|
||||
break;
|
||||
case 2:
|
||||
--$data["z"];
|
||||
break;
|
||||
case 3:
|
||||
++$data["z"];
|
||||
break;
|
||||
case 4:
|
||||
--$data["x"];
|
||||
break;
|
||||
case 5:
|
||||
++$data["x"];
|
||||
break;
|
||||
}
|
||||
$block = $this->getBlock($data["x"], $data["y"], $data["z"]);
|
||||
console("[DEBUG] EID ".$data["eid"]." placed ".$data["block"].":".$data["meta"]." into ".$block[0].":".$block[1]." at X ".$data["x"]." Y ".$data["y"]." Z ".$data["z"], true, true, 2);
|
||||
$this->setBlock($data["x"], $data["y"], $data["z"], $data["block"], $data["meta"]);
|
||||
break;
|
||||
case "onBlockBreak":
|
||||
$block = $this->getBlock($data["x"], $data["y"], $data["z"]);
|
||||
console("[DEBUG] EID ".$data["eid"]." broke block ".$block[0].":".$block[1]." at X ".$data["x"]." Y ".$data["y"]." Z ".$data["z"], true, true, 2);
|
||||
|
@ -415,6 +415,24 @@ class CustomPacketHandler{
|
||||
$this->raw .= Utils::writeInt($this->data["target"]);
|
||||
}
|
||||
break;
|
||||
case MC_USE_ITEM:
|
||||
if($this->c === false){
|
||||
$this->data["x"] = Utils::readInt($this->get(4));
|
||||
$this->data["y"] = Utils::readInt($this->get(4));
|
||||
$this->data["z"] = Utils::readInt($this->get(4));
|
||||
$this->data["face"] = Utils::readInt($this->get(4));
|
||||
$this->data["block"] = Utils::readShort($this->get(2));
|
||||
$this->data["meta"] = Utils::readByte($this->get(1));
|
||||
$this->data["eid"] = Utils::readInt($this->get(4));
|
||||
$this->data["unknown2"] = Utils::readFloat($this->get(4));
|
||||
$this->data["unknown3"] = Utils::readFloat($this->get(4));
|
||||
$this->data["unknown4"] = Utils::readFloat($this->get(4));
|
||||
}else{
|
||||
$this->raw .= Utils::writeByte($this->data["action"]);
|
||||
$this->raw .= Utils::writeInt($this->data["eid"]);
|
||||
$this->raw .= Utils::writeInt($this->data["target"]);
|
||||
}
|
||||
break;
|
||||
case MC_SET_ENTITY_DATA:
|
||||
if($this->c === false){
|
||||
$this->data["eid"] = Utils::readInt($this->get(4));
|
||||
|
@ -313,6 +313,12 @@ class Session{
|
||||
');
|
||||
console("[INTERNAL] Chunk X ".$data["x"]." Z ".$data["z"]." requested", true, true, 3);
|
||||
break;
|
||||
case MC_USE_ITEM:
|
||||
if($data["face"] >= 0 and $data["face"] <= 5 and $data["block"] !== 0){
|
||||
$data["eid"] = $this->eid;
|
||||
$this->server->handle("onBlockPlace", $data);
|
||||
}
|
||||
break;
|
||||
case MC_PLACE_BLOCK:
|
||||
var_dump($data);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user