Undefined fixes

This commit is contained in:
thebigsmileXD 2017-05-11 14:07:26 +02:00
parent 796c10f51a
commit 055014aa88
33 changed files with 620 additions and 632 deletions

View file

@ -14,29 +14,26 @@
namespace Ad5001\BetterGen; namespace Ad5001\BetterGen;
use Ad5001\BetterGen\biome\BetterForest;
use Ad5001\BetterGen\generator\BetterNormal;
use Ad5001\BetterGen\loot\LootTable;
use pocketmine\block\Block;
use pocketmine\command\Command; use pocketmine\command\Command;
use pocketmine\command\CommandSender; use pocketmine\command\CommandSender;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\level\ChunkPopulateEvent;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase; use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\Generator; use pocketmine\level\generator\Generator;
use pocketmine\level\generator\normal\Normal;
use pocketmine\event\level\ChunkPopulateEvent;
use Ad5001\BetterGen\generator\BetterNormal;
use Ad5001\BetterGen\biome\BetterForest;
use Ad5001\BetterGen\loot\LootTable;
use pocketmine\utils\Config;
use pocketmine\block\Block;
use pocketmine\tile\Chest;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\tag\IntTag; use pocketmine\plugin\PluginBase;
use pocketmine\tile\Chest;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
use pocketmine\item\Item; use pocketmine\utils\Config;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\block\BlockBreakEvent;
class Main extends PluginBase implements Listener { class Main extends PluginBase implements Listener {
const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f "; const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f ";
@ -214,7 +211,6 @@ class Main extends PluginBase implements Listener {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
if($event->getBlock()->getId() !== Block::CHEST) return; if($event->getBlock()->getId() !== Block::CHEST) return;
if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
$chest = new \pocketmine\block\Chest(0);
$nbt = new CompoundTag("", [ $nbt = new CompoundTag("", [
new ListTag("Items", []), new ListTag("Items", []),
new StringTag("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
@ -222,12 +218,10 @@ class Main extends PluginBase implements Listener {
new IntTag("y", $event->getBlock()->y), new IntTag("y", $event->getBlock()->y),
new IntTag("z", $event->getBlock()->z) new IntTag("z", $event->getBlock()->z)
]); ]);
$chest->setLevel($event->getBlock()->getLevel()); /** @var Chest $chest */
$cItem = Item::get(Item::CHEST, 0); $chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
$cItem->setCustomName("§k(Fake)§r Minecart chest"); $chest->setName("§k(Fake)§r Minecart chest");
$chest->place($cItem, $event->getBlock()->getLevel()->getBlock($event->getBlock()), $chest, 0, 0, 0, 0); LootTable::fillChest($chest->getInventory(), $event->getBlock());
$inv = $event->getBlock()->getLevel()->getTile($event->getBlock());
LootTable::fillChest($inv->getInventory(), $event->getBlock());
} }
@ -238,21 +232,18 @@ class Main extends PluginBase implements Listener {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
if($event->getBlock()->getId() !== Block::CHEST) return; if($event->getBlock()->getId() !== Block::CHEST) return;
if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
$chest = new \pocketmine\block\Chest(0);
$nbt = new CompoundTag("", [ $nbt = new CompoundTag("", [
new ListTag("Items", []), new ListTag("Items", []),
new StringTag("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
new IntTag("x", $event->getBlock()->x), new IntTag("x", $event->getBlock()->x),
new IntTag("y", $event->getBlock()->y), new IntTag("y", $event->getBlock()->y),
new IntTag("z", $event->getBlock()->z) new IntTag("z", $event->getBlock()->z)
]); ]);
$chest->setLevel($event->getBlock()->getLevel()); /** @var Chest $chest */
$cItem = Item::get(Item::CHEST, 0); $chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
$cItem->setCustomName("§k(Fake)§r Minecart chest"); $chest->setName("§k(Fake)§r Minecart chest");
$chest->place($cItem, $event->getBlock()->getLevel()->getBlock($event->getBlock()), $chest, 0, 0, 0, 0); LootTable::fillChest($chest->getInventory(), $event->getBlock());
$inv = $event->getBlock()->getLevel()->getTile($event->getBlock()); // $event->setCancelled(); //i think nope. You want to break it with items
LootTable::fillChest($inv->getInventory(), $event->getBlock());
$event->setCancelled();
} }
/* /*

View file

@ -13,14 +13,14 @@
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SandyBiome;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use Ad5001\BetterGen\populator\TemplePopulator;
use Ad5001\BetterGen\populator\WellPopulator;
use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator; use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\populator\TemplePopulator;
use Ad5001\BetterGen\populator\WellPopulator;
use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterDesert extends SandyBiome implements Mountainable { class BetterDesert extends SandyBiome implements Mountainable {
public function __construct() { public function __construct() {

View file

@ -15,12 +15,12 @@
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\ForestBiome;
use pocketmine\level\generator\biome\Biome;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\TreePopulator;
use Ad5001\BetterGen\populator\BushPopulator; use Ad5001\BetterGen\populator\BushPopulator;
use Ad5001\BetterGen\populator\FallenTreePopulator; use Ad5001\BetterGen\populator\FallenTreePopulator;
use Ad5001\BetterGen\populator\TreePopulator;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\ForestBiome;
class BetterForest extends ForestBiome implements Mountainable { class BetterForest extends ForestBiome implements Mountainable {

View file

@ -14,11 +14,11 @@
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SnowyBiome;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use Ad5001\BetterGen\populator\IglooPopulator;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\IglooPopulator;
use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\SnowyBiome;
class BetterIcePlains extends SnowyBiome implements Mountainable { class BetterIcePlains extends SnowyBiome implements Mountainable {
public function __construct() { public function __construct() {

View file

@ -14,17 +14,14 @@
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SandyBiome;
use pocketmine\level\generator\populator\Ore;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\TreePopulator;
use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator; use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\populator\TreePopulator;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterMesa extends SandyBiome { class BetterMesa extends SandyBiome {
public function __construct() { public function __construct() {

View file

@ -14,15 +14,13 @@
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SandyBiome; use Ad5001\BetterGen\Main;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator; use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\Main; use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterMesaPlains extends SandyBiome { class BetterMesaPlains extends SandyBiome {
public function __construct() { public function __construct() {

View file

@ -14,8 +14,8 @@
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
class BetterRiver extends Biome { class BetterRiver extends Biome {
public function __construct() { public function __construct() {

View file

@ -13,10 +13,10 @@
*/ */
namespace Ad5001\BetterGen\generator; namespace Ad5001\BetterGen\generator;
use pocketmine\level\generator\biome\BiomeSelector;
use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\biome\Biome;
use pocketmine\utils\Random; use pocketmine\level\generator\biome\BiomeSelector;
use pocketmine\level\generator\noise\Simplex; use pocketmine\level\generator\noise\Simplex;
use pocketmine\utils\Random;
class BetterBiomeSelector extends BiomeSelector { class BetterBiomeSelector extends BiomeSelector {
@ -30,7 +30,6 @@ class BetterBiomeSelector extends BiomeSelector {
/** @var Biome[] */ /** @var Biome[] */
private $biomes = [ ]; private $biomes = [ ];
private $map = [ ];
private $lookup; private $lookup;
public function __construct(Random $random, callable $lookup, Biome $fallback) { public function __construct(Random $random, callable $lookup, Biome $fallback) {
parent::__construct($random, $lookup, $fallback); parent::__construct($random, $lookup, $fallback);

View file

@ -14,15 +14,18 @@
namespace Ad5001\BetterGen\generator; namespace Ad5001\BetterGen\generator;
use pocketmine\level\ChunkManager; use Ad5001\BetterGen\biome\BetterDesert;
use pocketmine\math\Vector3; use Ad5001\BetterGen\biome\BetterForest;
use pocketmine\utils\Random; use Ad5001\BetterGen\biome\BetterIcePlains;
use pocketmine\level\generator\biome\Biome; use Ad5001\BetterGen\biome\BetterMesa;
use pocketmine\level\generator\Generator; use Ad5001\BetterGen\biome\BetterMesaPlains;
use pocketmine\level\generator\noise\Simplex; use Ad5001\BetterGen\biome\BetterRiver;
use pocketmine\level\generator\object\OreType; use Ad5001\BetterGen\biome\Mountainable;
use pocketmine\level\generator\normal\object\OreType as OreType2; use Ad5001\BetterGen\Main;
use pocketmine\level\generator\populator\Ore; use Ad5001\BetterGen\populator\CavePopulator;
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
use Ad5001\BetterGen\populator\MineshaftPopulator;
use Ad5001\BetterGen\populator\RavinePopulator;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\CoalOre; use pocketmine\block\CoalOre;
use pocketmine\block\DiamondOre; use pocketmine\block\DiamondOre;
@ -32,20 +35,15 @@ use pocketmine\block\Gravel;
use pocketmine\block\IronOre; use pocketmine\block\IronOre;
use pocketmine\block\LapisOre; use pocketmine\block\LapisOre;
use pocketmine\block\RedstoneOre; use pocketmine\block\RedstoneOre;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\Generator;
use pocketmine\level\generator\noise\Simplex;
use pocketmine\level\generator\normal\object\OreType as OreType2;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\Level; use pocketmine\level\Level;
use Ad5001\BetterGen\biome\BetterForest; use pocketmine\math\Vector3;
use Ad5001\BetterGen\biome\BetterDesert; use pocketmine\utils\Random;
use Ad5001\BetterGen\biome\BetterIcePlains;
use Ad5001\BetterGen\biome\BetterMesa;
use Ad5001\BetterGen\biome\BetterMesaPlains;
use Ad5001\BetterGen\biome\BetterRiver;
use Ad5001\BetterGen\biome\Mountainable;
use Ad5001\BetterGen\populator\CavePopulator;
use Ad5001\BetterGen\populator\RavinePopulator;
use Ad5001\BetterGen\populator\LakePopulator;
use Ad5001\BetterGen\populator\MineshaftPopulator;
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
use Ad5001\BetterGen\Main;
class BetterNormal extends Generator { class BetterNormal extends Generator {
const NOT_OVERWRITABLE = [ const NOT_OVERWRITABLE = [
@ -61,9 +59,11 @@ class BetterNormal extends Generator {
Block::WATER, Block::WATER,
Block::STILL_WATER Block::STILL_WATER
]; ];
/** @var BetterBiomeSelector */
protected $selector; protected $selector;
/** @var Level */ /** @var Level */
protected $level; protected $level;
/** @var Random */
protected $random; protected $random;
protected $populators = [ ]; protected $populators = [ ];
protected $generationPopulators = [ ]; protected $generationPopulators = [ ];
@ -78,7 +78,8 @@ class BetterNormal extends Generator {
] ]
]; ];
protected $waterHeight = 63; protected $waterHeight = 63;
private $noiseBase;
/* /*
* Picks a biome by X and Z * Picks a biome by X and Z
* @param $x int * @param $x int

View file

@ -14,12 +14,12 @@
namespace Ad5001\BetterGen\loot; namespace Ad5001\BetterGen\loot;
use pocketmine\inventory\BaseInventory;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\utils\Config; use pocketmine\utils\Config;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\item\Item;
use pocketmine\inventory\BaseInventory;
use pocketmine\nbt\NBT;
/* /*
* This class is used for loot setting. * This class is used for loot setting.

View file

@ -14,8 +14,8 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random;
use pocketmine\level\generator\populator\Populator; use pocketmine\level\generator\populator\Populator;
use pocketmine\utils\Random;
abstract class AmountPopulator extends Populator { abstract class AmountPopulator extends Populator {
protected $baseAmount = 0; protected $baseAmount = 0;

View file

@ -14,13 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\structure\Bush;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\populator\TreePopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\Bush;
class BushPopulator extends AmountPopulator { class BushPopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -15,12 +15,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\structure\Cactus;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\Cactus;
use Ad5001\BetterGen\populator\AmountPopulator;
class CactusPopulator extends AmountPopulator { class CactusPopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,13 +14,12 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
use Ad5001\BetterGen\populator\AmountPopulator;
class CavePopulator extends AmountPopulator { class CavePopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */
@ -93,7 +92,7 @@ class CavePopulator extends AmountPopulator {
foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) { foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) {
$generatedBranches --; $generatedBranches --;
if ($generatedBranches <= 0) { if ($generatedBranches <= 0) {
$gen->send(self::STOP); $gen->send(self::STOP); // send not found.. @Ad5001 what is that
} else { } else {
$gen->send(self::CONTINUE); $gen->send(self::CONTINUE);
} }

View file

@ -18,7 +18,6 @@ use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\populator\AmountPopulator;
class DeadbushPopulator extends AmountPopulator { class DeadbushPopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\structure\FallenTree;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\FallenTree;
use Ad5001\BetterGen\populator\AmountPopulator;
class FallenTreePopulator extends AmountPopulator { class FallenTreePopulator extends AmountPopulator {

View file

@ -14,22 +14,21 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\ChunkManager;
use pocketmine\level\format\Chunk;
use pocketmine\level\Level;
use pocketmine\utils\Random;
use Ad5001\BetterGen\generator\BetterNormal; use Ad5001\BetterGen\generator\BetterNormal;
use pocketmine\block\Block;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\normal\object\OreType as OreType2;
use pocketmine\math\Vector3;
use pocketmine\block\CoalOre;
use pocketmine\block\IronOre;
use pocketmine\block\RedstoneOre;
use pocketmine\block\LapisOre;
use pocketmine\block\GoldOre;
use pocketmine\block\DiamondOre;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use pocketmine\block\Block;
use pocketmine\block\CoalOre;
use pocketmine\block\DiamondOre;
use pocketmine\block\GoldOre;
use pocketmine\block\IronOre;
use pocketmine\block\LapisOre;
use pocketmine\block\RedstoneOre;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\normal\object\OreType as OreType2;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class FloatingIslandPopulator extends AmountPopulator { class FloatingIslandPopulator extends AmountPopulator {
@ -162,6 +161,6 @@ class FloatingIslandPopulator extends AmountPopulator {
new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4)) new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
]); ]);
$ores->populate($level, $x >> 4, $z >> 4, $random);//x z undefined $ores->populate($level, $pos->x >> 4, $pos->z >> 4, $random);//x z undefined
} }
} }

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\structure\Igloo;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\structure\Igloo; use pocketmine\utils\Random;
class IglooPopulator extends AmountPopulator { class IglooPopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,13 +14,12 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
use Ad5001\BetterGen\populator\AmountPopulator;
class LakePopulator extends AmountPopulator { class LakePopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,12 +14,12 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\math\Vector3;
use pocketmine\block\Block;
use Ad5001\BetterGen\loot\LootTable; use Ad5001\BetterGen\loot\LootTable;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class MineshaftPopulator extends AmountPopulator { class MineshaftPopulator extends AmountPopulator {
protected $maxPath; protected $maxPath;
@ -131,13 +131,13 @@ class MineshaftPopulator extends AmountPopulator {
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 )); BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 ));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x - 4, $y - 1, $z + 1 ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x - 4, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x - 4, $y, $z ), function ($v3, $level, $random) { BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x - 4, $y, $z ), function ($v3, ChunkManager $level, Random $random) {
if ($random->nextBoundedInt(3 ) !== 0) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
@ -213,13 +213,13 @@ class MineshaftPopulator extends AmountPopulator {
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z - 4 )); BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z - 4 ));
// Then, making sure the floor is solid. // Then, making sure the floor is solid.
BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z - 4 ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z - 4 ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // Putting rails
BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z - 4 ), function ($v3, $level, $random) { BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z - 4 ), function ($v3, ChunkManager $level, Random $random) {
if ($random->nextBoundedInt(3 ) !== 0) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
@ -310,7 +310,7 @@ class MineshaftPopulator extends AmountPopulator {
self::DIR_ZMIN self::DIR_ZMIN
] : [ ]) ] : [ ])
]; ];
for($i = 7; $i > $newfloor; $i --) { for($i = 7; $i > $newFloor; $i --) {
$chooseNew =(int ) $newFloor && $random->nextBoolean (); $chooseNew =(int ) $newFloor && $random->nextBoolean ();
$choose = $random->nextBoundedInt(4); $choose = $random->nextBoundedInt(4);
unset($possiblePathes [$chooseNew] [$choose]); unset($possiblePathes [$chooseNew] [$choose]);
@ -366,17 +366,17 @@ class MineshaftPopulator extends AmountPopulator {
} }
// Building stairs // Building stairs
for($i = 0; $i < 4; $i ++) { for($i = 0; $i < 4; $i ++) {
switch ($path) { switch ($i) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -384,7 +384,7 @@ class MineshaftPopulator extends AmountPopulator {
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -392,7 +392,7 @@ class MineshaftPopulator extends AmountPopulator {
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -402,7 +402,7 @@ class MineshaftPopulator extends AmountPopulator {
} }
// Next one // Next one
switch ($path) { switch ($i) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart($x + 4, $y - 4, $z, self::DIR_XPLUS, $random); $this->generateMineshaftPart($x + 4, $y - 4, $z, self::DIR_XPLUS, $random);
break; break;

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
class RavinePopulator extends AmountPopulator { class RavinePopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\structure\SugarCane;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\SugarCane;
use Ad5001\BetterGen\populator\AmountPopulator;
class SugarCanePopulator extends AmountPopulator { class SugarCanePopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\structure\Temple;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\structure\Temple; use pocketmine\level\Level;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\utils\Random;
class TemplePopulator extends AmountPopulator { class TemplePopulator extends AmountPopulator {
/** @var Level */ /** @var Level */

View file

@ -14,14 +14,12 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\Main;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Tree; use pocketmine\level\generator\object\Tree;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\structure\SakuraTree;
use Ad5001\BetterGen\populator\AmountPopulator;
use Ad5001\BetterGen\Main;
class TreePopulator extends AmountPopulator { class TreePopulator extends AmountPopulator {

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\Level; use Ad5001\BetterGen\structure\Well;
use pocketmine\utils\Random;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\structure\Well; use pocketmine\level\Level;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\utils\Random;
class WellPopulator extends AmountPopulator { class WellPopulator extends AmountPopulator {
/** @var ChunkManager */ /** @var ChunkManager */

View file

@ -14,12 +14,11 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Leaves;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class Bush extends Object { class Bush extends Object {
public $overridable = [ public $overridable = [

View file

@ -15,9 +15,9 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\utils\Random;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class Cactus extends Object { class Cactus extends Object {
@ -29,10 +29,12 @@ class Cactus extends Object {
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
private $totalHeight;
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt(3); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z); $below = $level->getBlockIdAt($x, $y - 1, $z);
for($yy = $y; $yy <= $y + $totalHeight; $yy ++) { for($yy = $y; $yy <= $y + $this->totalHeight; $yy ++) {
if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) { if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) {
return false; return false;
} }

View file

@ -16,8 +16,8 @@ namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class Igloo extends Object { class Igloo extends Object {
public $overridable = [ public $overridable = [

File diff suppressed because it is too large Load diff

View file

@ -16,9 +16,9 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\utils\Random;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class SugarCane extends Object { class SugarCane extends Object {
@ -30,6 +30,8 @@ class SugarCane extends Object {
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
private $totalHeight;
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt(3); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z); $below = $level->getBlockIdAt($x, $y - 1, $z);

View file

@ -14,13 +14,13 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\level\generator\object\Object;
use Ad5001\BetterGen\loot\LootTable; use Ad5001\BetterGen\loot\LootTable;
use Ad5001\BetterGen\utils\BuildingUtils; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class Temple extends Object { class Temple extends Object {
const DIRECTION_PLUSX = 0; const DIRECTION_PLUSX = 0;
@ -109,6 +109,7 @@ class Temple extends Object {
1 1
] ]
]; ];
private $direction;
/* /*
* Checks if a temple is placeable * Checks if a temple is placeable

View file

@ -17,8 +17,8 @@ namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class Well extends Object { class Well extends Object {

View file

@ -14,9 +14,9 @@
namespace Ad5001\BetterGen\utils; namespace Ad5001\BetterGen\utils;
use pocketmine\math\Vector3;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\math\Vector3;
use pocketmine\utils\Random; use pocketmine\utils\Random;
class BuildingUtils { class BuildingUtils {