Hello everyone, I'm noob in writing plugins, how to change the standard cobblestone generator (water + lava = cobblestone), instead of cobblestone, for example, iron ore appeared. Desirable sample code Sorry for my English.
This is a development question. It belongs in the development section. You will also have to provide evidence of a previous attempt.
YES) Here so did in a kernel and works PHP: if($colliding){ if($this->getDamage() === 0){ $this->getLevel()->setBlock($this, Block::get(Item::OBSIDIAN), true); }elseif($this->getDamage() <= 4){ //random spawn ore $orerand = mt_rand(1, 100); if($orerand <=5){ $this->getLevel()->setBlock($this, Block::get(Item::DIAMOND_ORE), true); }elseif($orerand <=10){ $this->getLevel()->setBlock($this, Block::get(Item::GOLD_ORE), true); }elseif($orerand <=15){ $this->getLevel()->setBlock($this, Block::get(Item::LAPIS_ORE), true); }elseif($orerand <=25){ $this->getLevel()->setBlock($this, Block::get(Item::IRON_ORE), true); }elseif($orerand <=35){ $this->getLevel()->setBlock($this, Block::get(Item::COAL_ORE), true); }elseif($orerand <=78){ $this->getLevel()->setBlock($this, Block::get(Item::COBBLESTONE), true); } } $this->triggerLavaMixEffects($this); } But how to do it with the plugin? And optimize this code? Sorry for my bad english))
That's still very minimal information. What is $colliding? Does the class in which you wrote that code extend Block? Also, it's not mandatory to optimize, and optimizing while writing the code is the worst thing anyone could do. Optimization should be done once everything in code is written, and only if needed.
Everything happens in a file pocketmine\block\liquid.php PHP: private function checkForHarden(){ if($this instanceof Lava){ $colliding = false; for($side = 0; $side <= 5 and !$colliding; ++$side){ $colliding = $this->getSide($side) instanceof Water; } if($colliding){ if($this->getDamage() === 0){ $this->getLevel()->setBlock($this, Block::get(Item::OBSIDIAN), true); }elseif($this->getDamage() <= 4){ //random spawn ore $orerand = mt_rand(1, 100); if($orerand <=5){ $this->getLevel()->setBlock($this, Block::get(Item::DIAMOND_ORE), true); }elseif($orerand <=10){ $this->getLevel()->setBlock($this, Block::get(Item::GOLD_ORE), true); }elseif($orerand <=15){ $this->getLevel()->setBlock($this, Block::get(Item::LAPIS_ORE), true); }elseif($orerand <=25){ $this->getLevel()->setBlock($this, Block::get(Item::IRON_ORE), true); }elseif($orerand <=35){ $this->getLevel()->setBlock($this, Block::get(Item::COAL_ORE), true); }elseif($orerand <=78){ $this->getLevel()->setBlock($this, Block::get(Item::COBBLESTONE), true); } } $this->triggerLavaMixEffects($this); } } } The code does not work right away, because the lava does not immediately put the block.
So this isn't a plugin, you're directly editing the PocketMine source? And what is PHP: $this->triggerLavaMixEffects($this) ?
yes, and I want to do this with the plugin, but I do not know how.)) PHP: $this->triggerLavaMixEffects($this) It's from tesseract...
You won't get support for spoons here Use PocketMine & come back, everyone here uses PocketMine, so you're not gonna get support for Tesseract
i dont think we give support for how to edit sources either so using PMMP and coming back will probably do you no good either ways
Hmm ... I'm here asking for help in implementing the plugin ... but not in the kernel)) In the kernel I already did as of pmmp and other kernels)) And now I ask how to do this with the help of the plugin, I do not care what kernel it will be)))
I would like not to touch the kernel, that it was free to drag the plugin to the new version of pmmp 1.1.0 without changing the kernel.
no like i said try overwriting the block ONLY without touching the core PMMP via plugins, if that's possible
It may be possible to register a subclass of the water class and/or the lava class and override the block update behaviour. Not compatible with multiple plugins though. Indeed, an API improvement is needed, but water-and-lava-merge is far too specific.