mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Added Redstone Ore block update
This commit is contained in:
parent
d8bf5ce711
commit
2790f60491
@ -30,6 +30,7 @@ define("BLOCK_UPDATE_NORMAL", 0);
|
||||
define("BLOCK_UPDATE_RANDOM", 1);
|
||||
define("BLOCK_UPDATE_SCHEDULED", 2);
|
||||
define("BLOCK_UPDATE_WEAK", 3);
|
||||
define("BLOCK_UPDATE_TOUCH", 4);
|
||||
|
||||
|
||||
|
||||
@ -244,6 +245,7 @@ class BlockAPI{
|
||||
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);
|
||||
}
|
||||
$this->blockUpdate($target, BLOCK_UPDATE_TOUCH);
|
||||
|
||||
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){
|
||||
@ -690,12 +692,16 @@ class BlockAPI{
|
||||
}
|
||||
|
||||
public function blockUpdate(Vector3 $pos, $type = BLOCK_UPDATE_NORMAL){
|
||||
$pos = $pos->floor();
|
||||
$block = $this->getBlock($pos);
|
||||
if(!($pos instanceof Block)){
|
||||
$pos = $pos->floor();
|
||||
$block = $this->getBlock($pos);
|
||||
}else{
|
||||
$block = $pos;
|
||||
}
|
||||
return $block->onUpdate($this, $type);
|
||||
}
|
||||
|
||||
public function scheduleBlockUpdate(Vector3 $pos, $delay, $type = BLOCK_UPDATE_NORMAL){
|
||||
public function scheduleBlockUpdate(Vector3 $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
|
||||
$type = (int) $type;
|
||||
if($delay < 0){
|
||||
return false;
|
||||
|
@ -255,7 +255,7 @@ class ServerAPI{
|
||||
foreach($this->plugin->getList() as $p){
|
||||
$plist .= str_replace(array(";", ":"), "", $p["name"]).":".str_replace(array(";", ":"), "", $p["version"]).";";
|
||||
}
|
||||
Utils::curl_post("http://stats.pocketmine.net/usage.php",array(
|
||||
Utils::curl_post("http://stats.pocketmine.net/usage.php", array(
|
||||
"serverid" => $this->server->serverID,
|
||||
"os" => Utils::getOS(),
|
||||
"version" => MAJOR_VERSION,
|
||||
|
@ -29,5 +29,25 @@ class GlowingRedstoneOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
|
||||
}
|
||||
|
||||
public function onUpdate(BlockAPI $level, $type){
|
||||
if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){
|
||||
$level->setBlock($this, REDSTONE_ORE, $this->getMetadata(), false);
|
||||
return BLOCK_UPDATE_WEAK;
|
||||
}else{
|
||||
$level->scheduleBlockUpdate($this, mt_rand(45, 100));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->isPickaxe() >= 2){
|
||||
return array(
|
||||
//array(331, 4, mt_rand(4, 5)),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -29,6 +29,16 @@ class RedstoneOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(REDSTONE_ORE, 0, "Redstone Ore");
|
||||
}
|
||||
|
||||
public function onUpdate(BlockAPI $level, $type){
|
||||
if($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH){
|
||||
$level->setBlock($this, GLOWING_REDSTONE_ORE, $this->getMetadata(), false);
|
||||
$level->scheduleBlockUpdate($this, mt_rand(45, 100));
|
||||
return BLOCK_UPDATE_WEAK;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
if($item->isPickaxe() >= 2){
|
||||
return array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user