crnw-dev / IslandArchitect

An plugin to create custom sky island generators for the SkyBlock plugin
Apache License 2.0
13 stars 4 forks source link

Add default random generation regex #5

Closed Endermanbugzjfc closed 3 years ago

Endermanbugzjfc commented 3 years ago

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).

Endermanbugzjfc commented 3 years ago

I'll do this after the generator class is done

Otherwise I can't measure the perfect chance of elements in default random generation regex

callumrawlinson commented 3 years ago

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;
        }
    }
}

}`

Endermanbugzjfc commented 3 years ago

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

callumrawlinson commented 3 years ago

:)

callumrawlinson commented 3 years ago

@Endermanbugzjfc what is next to do in the plugin. i will help you

Endermanbugzjfc commented 3 years ago

@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.

callumrawlinson commented 3 years ago

which one would you feel easier making?

Endermanbugzjfc commented 3 years ago

which one would you feel easier making?

The latter.

callumrawlinson commented 3 years ago

do you need me to do anything? @Endermanbugzjfc also are there any free spaces in the clouria network development team?

Endermanbugzjfc commented 3 years ago

Random ores (bb8cdbb2)

Endermanbugzjfc commented 3 years ago

Random chest directions (20affd2e)

Endermanbugzjfc commented 3 years ago

Random flowers (ef04146c)

Endermanbugzjfc commented 3 years ago

Random coloured blocks (41c2ac25)