mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +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);
|
$target = $this->getBlock($vector);
|
||||||
$item = $player->equipment;
|
$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)){
|
if(!$target->isBreakable($item, $player) or $player->gamemode === ADVENTURE or ($player->lastBreak + $target->getBreakTime($item, $player)) >= microtime(true)){
|
||||||
return $this->cancelAction($target, $player);
|
return $this->cancelAction($target, $player);
|
||||||
}
|
}
|
||||||
@ -225,11 +230,16 @@ class BlockAPI{
|
|||||||
return $this->cancelAction($block, $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($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){
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($player->gamemode === ADVENTURE){ //Adventure mode!!
|
if($player->gamemode === ADVENTURE){ //Adventure mode!!
|
||||||
return $this->cancelAction($block, $player);
|
return $this->cancelAction($block, $player);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user