mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
New block touch event
This commit is contained in:
parent
8a345e6582
commit
9510cbd716
@ -165,6 +165,11 @@ class BlockAPI{
|
||||
|
||||
$target = $this->getBlock($vector);
|
||||
$item = $player->equipment;
|
||||
|
||||
if($this->server->api->dhandle("player.block.touch", array("type" => "break", "player" => $player, "target" => $target, "item" => $item)) === false){
|
||||
return $this->cancelAction($target, $player);
|
||||
}
|
||||
|
||||
if(!$target->isBreakable($item, $player) or $player->gamemode === ADVENTURE or ($player->lastBreak + $target->getBreakTime($item, $player)) >= microtime(true)){
|
||||
return $this->cancelAction($target, $player);
|
||||
}
|
||||
@ -224,12 +229,17 @@ class BlockAPI{
|
||||
$this->cancelAction($target, $player);
|
||||
return $this->cancelAction($block, $player);
|
||||
}
|
||||
|
||||
if($this->server->api->dhandle("player.block.touch", array("type" => "place", "player" => $player, "block" => $block, "target" => $target, "item" => $item)) === false){
|
||||
return $this->cancelAction($block, $player);
|
||||
}
|
||||
|
||||
if($target->isActivable === true){
|
||||
if($this->server->api->dhandle("player.block.activate", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== false and $target->onActivate($this, $item, $player) === true){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if($player->gamemode === ADVENTURE){ //Adventure mode!!
|
||||
return $this->cancelAction($block, $player);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user