mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-23 20:04:02 +00:00
Starting to support Chest windows
This commit is contained in:
parent
54e6bd0ee9
commit
700314d75a
@ -69,7 +69,7 @@ class BlockAPI{
|
||||
$meta = (int) $params[3];
|
||||
}
|
||||
if(($player = $this->server->api->player->get($username)) !== false){
|
||||
$this->drop($player->entity->x, $player->entity->y, $player->entity->z, $block, $meta, $amount);
|
||||
$this->drop($player->entity->x - 0.5, $player->entity->y, $player->entity->z - 0.5, $block, $meta, $amount);
|
||||
console("[INFO] Giving ".$amount." of ".$block.":".$meta." to ".$username);
|
||||
}else{
|
||||
console("[INFO] Unknown player");
|
||||
@ -231,6 +231,14 @@ class BlockAPI{
|
||||
$cancelPlace = false;
|
||||
if(isset(Material::$activable[$target[0]])){
|
||||
switch($target[0]){
|
||||
case 54:
|
||||
$this->server->api->player->getByEID($data["eid"])->dataPacket(MC_CONTAINER_OPEN, array(
|
||||
"windowid" => 1,
|
||||
"type" => WINDOW_CHEST,
|
||||
"slots" => 27,
|
||||
"title" => "Random Chest",
|
||||
));
|
||||
break;
|
||||
case 6:
|
||||
if($data["block"] === 351 and $data["meta"] === 0x0F){ //Bonemeal
|
||||
Sapling::growTree($this->server->api->level, $target, $target[1] & 0x03);
|
||||
|
@ -505,6 +505,41 @@ class CustomPacketHandler{
|
||||
$this->raw .= Utils::writeShort($this->data["meta"]);
|
||||
}
|
||||
break;
|
||||
case MC_CONTAINER_OPEN:
|
||||
if($this->c === false){
|
||||
$this->data["windowid"] = ord($this->get(1));
|
||||
$this->data["type"] = ord($this->get(1));
|
||||
$this->data["slots"] = Utils::readShort($this->get(2), false);
|
||||
$this->data["title"] = $this->get(Utils::readShort($this->get(2), false));
|
||||
}else{
|
||||
$this->raw .= chr($this->data["windowid"]);
|
||||
$this->raw .= chr($this->data["type"]);
|
||||
$this->raw .= Utils::writeShort($this->data["slots"]);
|
||||
$this->raw .= Utils::writeShort(strlen($this->data["title"])).$this->data["title"];
|
||||
}
|
||||
break;
|
||||
case MC_CONTAINER_CLOSE:
|
||||
if($this->c === false){
|
||||
$this->data["windowid"] = ord($this->get(1));
|
||||
}else{
|
||||
$this->raw .= chr($this->data["windowid"]);
|
||||
}
|
||||
break;
|
||||
case MC_CONTAINER_SET_SLOT:
|
||||
if($this->c === false){
|
||||
$this->data["windowid"] = ord($this->get(1));
|
||||
$this->data["slot"] = Utils::readShort($this->get(2), false);
|
||||
$this->data["block"] = Utils::readShort($this->get(2), false);
|
||||
$this->data["stack"] = ord($this->get(1));
|
||||
$this->data["meta"] = Utils::readShort($this->get(2), false);
|
||||
}else{
|
||||
$this->raw .= chr($this->data["windowid"]);
|
||||
$this->raw .= Utils::writeShort($this->data["slot"]);
|
||||
$this->raw .= Utils::writeShort($this->data["block"]);
|
||||
$this->raw .= chr($this->data["stack"]);
|
||||
$this->raw .= Utils::writeShort($this->data["meta"]);
|
||||
}
|
||||
break;
|
||||
case MC_CLIENT_MESSAGE:
|
||||
if($this->c === false){
|
||||
$this->data["message"] = $this->get(Utils::readShort($this->get(2), false));
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -34,7 +34,7 @@ define("ENTITY_PAINTING", 4);
|
||||
|
||||
class Entity extends stdClass{
|
||||
var $eid, $type, $name, $x, $y, $z, $yaw, $pitch, $dead, $data, $class, $attach, $metadata, $closed, $player, $onTick;
|
||||
private $ev, $server;
|
||||
private $server;
|
||||
function __construct($server, $eid, $class, $type = 0, $data = array()){
|
||||
$this->server = $server;
|
||||
$this->eid = (int) $eid;
|
||||
|
@ -75,7 +75,7 @@ class Packet{
|
||||
case 0x40:
|
||||
$reply = new CustomPacketHandler($this->data[$field]["id"], "", $this->data[$field], true);
|
||||
$this->addRaw(Utils::writeShort((strlen($reply->raw) + 1) << 3));
|
||||
$this->addRaw(Utils::writeTriad($this->data[$field]["count"]));
|
||||
$this->addRaw(Utils::writeTriad(strrev($this->data[$field]["count"])));
|
||||
$this->addRaw(chr($this->data[$field]["id"]));
|
||||
$this->addRaw($reply->raw);
|
||||
break;
|
||||
|
@ -398,7 +398,7 @@ class Player{
|
||||
$this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]);
|
||||
break;
|
||||
default:
|
||||
console("[INTERNAL] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 3);
|
||||
console("[DEBUG] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -62,7 +62,7 @@ class SerializedPacketHandler{
|
||||
|
||||
$len = ceil(Utils::readShort($this->get(2), false) / 8); //Utils::readShort($this->get(2), false) >> 3;
|
||||
if($pid !== 0x00){
|
||||
$c = Utils::readTriad($this->get(3));
|
||||
$c = Utils::readTriad(strrev($this->get(3)));
|
||||
}
|
||||
if($pid === 0x60 and $i === 0){
|
||||
$this->data["unknown1"] = $this->get(4);
|
||||
|
36
src/classes/TileEntity.class.php
Normal file
36
src/classes/TileEntity.class.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class TileEntity extends stdClass{
|
||||
private $server;
|
||||
function __construct(PocketMinecraftServer $server){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
39
src/classes/Window.class.php
Normal file
39
src/classes/Window.class.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
define("WINDOW_CHEST", 0);
|
||||
define("WINDOW_WORKBENCH", 1);
|
||||
define("WINDOW_FURNACE", 2);
|
||||
|
||||
class Window{
|
||||
private $server;
|
||||
public function __construct(PocketMinecraftServer $server){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -92,6 +92,8 @@ require_once("classes/Utils.class.php");
|
||||
require_once("classes/UDPSocket.class.php");
|
||||
require_once("classes/Packet.class.php");
|
||||
require_once("classes/Entity.class.php");
|
||||
require_once("classes/TileEntity.class.php");
|
||||
require_once("classes/Window.class.php");
|
||||
require_once("classes/ChunkParser.class.php");
|
||||
require_once("classes/NBT.class.php");
|
||||
require_once("classes/Java.class.php");
|
||||
|
@ -76,6 +76,9 @@ $dataName = array(
|
||||
MC_RESPAWN => "Respawn",
|
||||
|
||||
MC_DROP_ITEM => "DropItem",
|
||||
MC_CONTAINER_OPEN => "ContainerOpen",
|
||||
MC_CONTAINER_CLOSE => "ContainerClose",
|
||||
MC_CONTAINER_SET_SLOT => "ContainerSetSlot",
|
||||
|
||||
MC_CLIENT_MESSAGE => "ClientMessage",
|
||||
MC_SIGN_UPDATE => "SignUpdate",
|
||||
|
@ -76,6 +76,9 @@ define("MC_ANIMATE", 0xa7);
|
||||
define("MC_RESPAWN", 0xa8);
|
||||
|
||||
define("MC_DROP_ITEM", 0xaa);
|
||||
define("MC_CONTAINER_OPEN", 0xab);
|
||||
define("MC_CONTAINER_CLOSE", 0xac);
|
||||
define("MC_CONTAINER_SET_SLOT", 0xad);
|
||||
|
||||
define("MC_CLIENT_MESSAGE", 0xb1);
|
||||
define("MC_SIGN_UPDATE", 0xb2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user