mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Fixed "player.interact" event only being fired with weird conditions
This commit is contained in:
parent
d552042094
commit
34ca8baa29
@ -963,7 +963,7 @@ class Player{
|
||||
break;
|
||||
}elseif($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){
|
||||
break;
|
||||
}elseif($this->handle("player.interact", $data) !== false){
|
||||
}elseif($this->server->handle("player.interact", $data) !== false){
|
||||
switch($this->equipment->getID()){
|
||||
case WOODEN_SWORD:
|
||||
case GOLD_SWORD:
|
||||
@ -1223,7 +1223,7 @@ class Player{
|
||||
}*/
|
||||
$inv = array();
|
||||
foreach($this->inventory as $s => $data){
|
||||
if($data[0] > 0 and $data[2] >= 0){
|
||||
if($data[0] > AIR and $data[2] >= 0){
|
||||
$inv[] = BlockAPI::getItem($data[0], $data[1], $data[2]);
|
||||
}else{
|
||||
$inv[] = BlockAPI::getItem(AIR, 0, 0);
|
||||
|
@ -32,7 +32,7 @@ class CustomPacketHandler{
|
||||
public $data;
|
||||
public $name = "";
|
||||
|
||||
private function get($len = true, $check = true){
|
||||
public function get($len = true, $check = true){
|
||||
if($len === true){
|
||||
$data = substr($this->raw, $this->offset);
|
||||
if($check === true){
|
||||
@ -600,14 +600,14 @@ class CustomPacketHandler{
|
||||
$this->data["count"] = Utils::readShort($this->get(2), false);
|
||||
$this->data["slots"] = array();
|
||||
for($s = 0; $s < $this->data["count"]; ++$s){
|
||||
$this->data["slots"][$s] = Utils::readSlot($this->get(5));
|
||||
$this->data["slots"][$s] = Utils::readSlot($this);
|
||||
}
|
||||
if($this->data["windowid"] === 1){ //Armor is also sent
|
||||
$this->data["armor"] = array(
|
||||
Utils::readSlot($this->get(5)),
|
||||
Utils::readSlot($this->get(5)),
|
||||
Utils::readSlot($this->get(5)),
|
||||
Utils::readSlot($this->get(5))
|
||||
Utils::readSlot($this),
|
||||
Utils::readSlot($this),
|
||||
Utils::readSlot($this),
|
||||
Utils::readSlot($this)
|
||||
);
|
||||
}
|
||||
}else{
|
||||
@ -681,7 +681,7 @@ class CustomPacketHandler{
|
||||
$this->data["count"] = Utils::readShort($this->get(2), false);
|
||||
$this->data["slots"] = array();
|
||||
for($s = 0; $s < $this->data["count"]; ++$s){
|
||||
$this->data["slots"][$s] = Utils::readSlot($this->get(5));
|
||||
$this->data["slots"][$s] = Utils::readSlot($this);
|
||||
}
|
||||
}else{
|
||||
$this->raw .= chr($this->data["windowid"]);
|
||||
|
@ -155,11 +155,13 @@ class Utils{
|
||||
return Utils::writeShort($item->getID()).chr($item->count).Utils::writeShort($item->getMetadata());
|
||||
}
|
||||
|
||||
public static function readSlot($str){
|
||||
public static function readSlot($ob){
|
||||
$id = Utils::readShort($ob->get(2));
|
||||
$cnt = ord($ob->get(1));
|
||||
return BlockAPI::getItem(
|
||||
Utils::readShort(substr($str, 0, 2), false),
|
||||
Utils::readShort(substr($str, 3, 2), false),
|
||||
ord($str{2})
|
||||
$id,
|
||||
Utils::readShort($ob->get(2)),
|
||||
$cnt
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user