Closed Endermanbugzjfc closed 3 years ago
Otherwise I can't measure the perfect chance of elements in default random generation regex
Hello! @Endermanbugzjfc i would use this for random ores
use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\math\Vector3; use pocketmine\Player; use pocketmine\event\block\BlockUpdateEvent; use pocketmine\item\Item; use pocketmine\event\Listener; use pocketmine\level\Level; use pocketmine\block\Block; use pocketmine\block\Iron; use pocketmine\block\Cobblestone; use pocketmine\block\Diamond; use pocketmine\block\Emerald; use pocketmine\block\Gold; use pocketmine\block\Coal; use pocketmine\block\Lava; use pocketmine\block\Lapis; use pocketmine\block\Redstone; use pocketmine\block\Water;
class Generate extends PluginBase implements Listener{
public function onEnable(){
$this->getLogger()->info("Plugin Enabled!");
$this->getServer()->getPluginManager()->registerEvents($this,$this);
}
public function onBlockSet(BlockUpdateEvent $event){
$block = $event->getBlock();
$water = false;
$lava = false;
for ($i = 2; $i <= 5; $i++) {
$nearBlock = $block->getSide($i);
if ($nearBlock instanceof Water) {
$water = true;
} else if ($nearBlock instanceof Lava) {
$lava = true;
}
if ($water && $lava) {
$id = mt_rand(1, 20);
switch ($id) {
case 2;
$newBlock = new Iron();
break;
case 4;
$newBlock = new Gold();
break;
case 6;
$newBlock = new Emerald();
break;
case 8;
$newBlock = new Coal();
break;
case 10;
$newBlock = new Redstone();
break;
case 12;
$newBlock = new Diamond();
break;
case 14;
$newBlock = new Lapis();
break;
default:
$newBlock = new Cobblestone();
}
$block->getLevel()->setBlock($block, $newBlock, true, false);
return;
}
}
}
}`
Hello! @Endermanbugzjfc i would use this for random ores
use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\math\Vector3; use pocketmine\Player; use pocketmine\event\block\BlockUpdateEvent; use pocketmine\item\Item; use pocketmine\event\Listener; use pocketmine\level\Level; use pocketmine\block\Block; use pocketmine\block\Iron; use pocketmine\block\Cobblestone; use pocketmine\block\Diamond; use pocketmine\block\Emerald; use pocketmine\block\Gold; use pocketmine\block\Coal; use pocketmine\block\Lava; use pocketmine\block\Lapis; use pocketmine\block\Redstone; use pocketmine\block\Water;
class Generate extends PluginBase implements Listener{
public function onEnable(){ $this->getLogger()->info("Plugin Enabled!"); $this->getServer()->getPluginManager()->registerEvents($this,$this); } public function onBlockSet(BlockUpdateEvent $event){ $block = $event->getBlock(); $water = false; $lava = false; for ($i = 2; $i <= 5; $i++) { $nearBlock = $block->getSide($i); if ($nearBlock instanceof Water) { $water = true; } else if ($nearBlock instanceof Lava) { $lava = true; } if ($water && $lava) { $id = mt_rand(1, 20); switch ($id) { case 2; $newBlock = new Iron(); break; case 4; $newBlock = new Gold(); break; case 6; $newBlock = new Emerald(); break; case 8; $newBlock = new Coal(); break; case 10; $newBlock = new Redstone(); break; case 12; $newBlock = new Diamond(); break; case 14; $newBlock = new Lapis(); break; default: $newBlock = new Cobblestone(); } $block->getLevel()->setBlock($block, $newBlock, true, false); return; } } }
}`
Thanks for the suggestion
:)
@Endermanbugzjfc what is next to do in the plugin. i will help you
@Endermanbugzjfc what is next to do in the plugin. i will help you
The generator class, I am still thinking whether I should make it so island exports are actually a php clas file which extends the template island generator class (hacky way) and include that php file on plugin enable. Or I should make the template island generator reads the template island data by the generator name, and update the chest position and spawn position with an event listener.
which one would you feel easier making?
which one would you feel easier making?
The latter.
do you need me to do anything? @Endermanbugzjfc also are there any free spaces in the clouria network development team?
Allow user to add default random generation regex in the config, the config will also bring some "default" default regex (see below) when the config file gets generated(or gets updated).