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