mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-17 00:44:08 +00:00
Better InteractPacket handling and added ACTION_MOUSEOVER constant
This commit is contained in:
parent
9d16f145dd
commit
3d2f9f0e74
@ -2323,16 +2323,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$target = $this->level->getEntity($packet->target);
|
$target = $this->level->getEntity($packet->target);
|
||||||
|
|
||||||
$cancelled = false;
|
$cancelled = false;
|
||||||
|
switch($packet->action){
|
||||||
if($packet->action !== InteractPacket::ACTION_LEFT_CLICK){
|
case InteractPacket::ACTION_LEFT_CLICK: //Attack
|
||||||
// TODO handle
|
if($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false){
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(
|
|
||||||
$target instanceof Player and
|
|
||||||
$this->server->getConfigBoolean("pvp", true) === false
|
|
||||||
){
|
|
||||||
$cancelled = true;
|
$cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2441,6 +2434,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
|
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break; //TODO: handle other actions
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::ANIMATE_PACKET:
|
case ProtocolInfo::ANIMATE_PACKET:
|
||||||
|
@ -30,11 +30,9 @@ class InteractPacket extends DataPacket{
|
|||||||
const ACTION_RIGHT_CLICK = 1;
|
const ACTION_RIGHT_CLICK = 1;
|
||||||
const ACTION_LEFT_CLICK = 2;
|
const ACTION_LEFT_CLICK = 2;
|
||||||
const ACTION_LEAVE_VEHICLE = 3;
|
const ACTION_LEAVE_VEHICLE = 3;
|
||||||
/** @deprecated Do NOT use this. This constant is misleading and will be removed in the future */
|
const ACTION_MOUSEOVER = 4;
|
||||||
const ACTION_JUMP = 3;
|
|
||||||
|
|
||||||
public $action;
|
public $action;
|
||||||
public $eid;
|
|
||||||
public $target;
|
public $target;
|
||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user