Merge branch 'experimental/vanilla-block-registry'

This commit is contained in:
Dylan K. Taylor 2019-07-08 19:38:09 +01:00
commit bda9bd2f2d
58 changed files with 2732 additions and 198 deletions

View File

@ -283,7 +283,7 @@ class Block extends Position implements BlockLegacyIds{
if(($t = $this->world->getTile($this)) !== null){ if(($t = $this->world->getTile($this)) !== null){
$t->onBlockDestroyed(); $t->onBlockDestroyed();
} }
return $this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR)); return $this->getWorld()->setBlock($this, VanillaBlocks::AIR());
} }
/** /**
@ -748,4 +748,16 @@ class Block extends Position implements BlockLegacyIds{
return $currentHit; return $currentHit;
} }
/**
* @param self $self
*
* @return static
*/
public static function cast(self $self){
if(!($self instanceof static)){
throw new \TypeError("Cannot cast from " . self::class . " to " . static::class);
}
return $self;
}
} }

View File

@ -95,7 +95,7 @@ class Cactus extends Transparent{
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z); $b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
if($b->getId() === BlockLegacyIds::AIR){ if($b->getId() === BlockLegacyIds::AIR){
$ev = new BlockGrowEvent($b, BlockFactory::get(BlockLegacyIds::CACTUS)); $ev = new BlockGrowEvent($b, VanillaBlocks::CACTUS());
$ev->call(); $ev->call();
if($ev->isCancelled()){ if($ev->isCancelled()){
break; break;

View File

@ -73,7 +73,7 @@ class Cake extends Transparent implements FoodSource{
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){ //Replace with common break method if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){ //Replace with common break method
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR)); $this->getWorld()->setBlock($this, VanillaBlocks::AIR());
} }
} }
@ -113,7 +113,7 @@ class Cake extends Transparent implements FoodSource{
$clone = clone $this; $clone = clone $this;
$clone->bites++; $clone->bites++;
if($clone->bites > 6){ if($clone->bites > 6){
$clone = BlockFactory::get(BlockLegacyIds::AIR); $clone = VanillaBlocks::AIR();
} }
return $clone; return $clone;
} }

View File

@ -34,7 +34,7 @@ class CoarseDirt extends Dirt{
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($face === Facing::UP and $item instanceof Hoe){ if($face === Facing::UP and $item instanceof Hoe){
$item->applyDamage(1); $item->applyDamage(1);
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT)); $this->getWorld()->setBlock($this, VanillaBlocks::DIRT());
return true; return true;
} }

View File

@ -38,7 +38,7 @@ class Dirt extends Solid{
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($face === Facing::UP and $item instanceof Hoe){ if($face === Facing::UP and $item instanceof Hoe){
$item->applyDamage(1); $item->applyDamage(1);
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::FARMLAND)); $this->getWorld()->setBlock($this, VanillaBlocks::FARMLAND());
return true; return true;
} }

View File

@ -77,7 +77,7 @@ class DragonEgg extends Transparent implements Fallable{
$block = $ev->getTo(); $block = $ev->getTo();
} }
$this->world->addParticle($this, new DragonEggTeleportParticle($this->x - $block->x, $this->y - $block->y, $this->z - $block->z)); $this->world->addParticle($this, new DragonEggTeleportParticle($this->x - $block->x, $this->y - $block->y, $this->z - $block->z));
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR)); $this->world->setBlock($this, VanillaBlocks::AIR());
$this->world->setBlock($block, $this); $this->world->setBlock($block, $this);
break; break;
} }

View File

@ -56,7 +56,7 @@ class Farmland extends Transparent{
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if($this->getSide(Facing::UP)->isSolid()){ if($this->getSide(Facing::UP)->isSolid()){
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT)); $this->world->setBlock($this, VanillaBlocks::DIRT());
} }
} }
@ -70,7 +70,7 @@ class Farmland extends Transparent{
$this->wetness--; $this->wetness--;
$this->world->setBlock($this, $this, false); $this->world->setBlock($this, $this, false);
}else{ }else{
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT)); $this->world->setBlock($this, VanillaBlocks::DIRT());
} }
}elseif($this->wetness < 7){ }elseif($this->wetness < 7){
$this->wetness = 7; $this->wetness = 7;

View File

@ -88,7 +88,7 @@ class Fire extends Flowable{
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if(!$this->getSide(Facing::DOWN)->isSolid() and !$this->hasAdjacentFlammableBlocks()){ if(!$this->getSide(Facing::DOWN)->isSolid() and !$this->hasAdjacentFlammableBlocks()){
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR)); $this->getWorld()->setBlock($this, VanillaBlocks::AIR());
}else{ }else{
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(30, 40)); $this->world->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
} }
@ -113,12 +113,12 @@ class Fire extends Flowable{
if($this->age === 15){ if($this->age === 15){
if(!$down->isFlammable() and mt_rand(0, 3) === 3){ //1/4 chance to extinguish if(!$down->isFlammable() and mt_rand(0, 3) === 3){ //1/4 chance to extinguish
$canSpread = false; $canSpread = false;
$result = BlockFactory::get(BlockLegacyIds::AIR); $result = VanillaBlocks::AIR();
} }
}elseif(!$this->hasAdjacentFlammableBlocks()){ }elseif(!$this->hasAdjacentFlammableBlocks()){
$canSpread = false; $canSpread = false;
if(!$down->isSolid() or $this->age > 3){ if(!$down->isSolid() or $this->age > 3){
$result = BlockFactory::get(BlockLegacyIds::AIR); $result = VanillaBlocks::AIR();
} }
} }
} }
@ -170,7 +170,7 @@ class Fire extends Flowable{
$fire->age = min(15, $fire->age + (mt_rand(0, 4) >> 2)); $fire->age = min(15, $fire->age + (mt_rand(0, 4) >> 2));
$this->world->setBlock($block, $fire); $this->world->setBlock($block, $fire);
}else{ }else{
$this->world->setBlock($block, BlockFactory::get(BlockLegacyIds::AIR)); $this->world->setBlock($block, VanillaBlocks::AIR());
} }
} }
} }

View File

@ -56,7 +56,7 @@ class Grass extends Solid{
$lightAbove = $this->world->getFullLightAt($this->x, $this->y + 1, $this->z); $lightAbove = $this->world->getFullLightAt($this->x, $this->y + 1, $this->z);
if($lightAbove < 4 and $this->world->getBlockAt($this->x, $this->y + 1, $this->z)->getLightFilter() >= 2){ if($lightAbove < 4 and $this->world->getBlockAt($this->x, $this->y + 1, $this->z)->getLightFilter() >= 2){
//grass dies //grass dies
$ev = new BlockSpreadEvent($this, $this, BlockFactory::get(BlockLegacyIds::DIRT)); $ev = new BlockSpreadEvent($this, $this, VanillaBlocks::DIRT());
$ev->call(); $ev->call();
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->world->setBlock($this, $ev->getNewState(), false); $this->world->setBlock($this, $ev->getNewState(), false);
@ -78,7 +78,7 @@ class Grass extends Solid{
continue; continue;
} }
$ev = new BlockSpreadEvent($b, $this, BlockFactory::get(BlockLegacyIds::GRASS)); $ev = new BlockSpreadEvent($b, $this, VanillaBlocks::GRASS());
$ev->call(); $ev->call();
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->world->setBlock($b, $ev->getNewState(), false); $this->world->setBlock($b, $ev->getNewState(), false);
@ -98,12 +98,12 @@ class Grass extends Solid{
return true; return true;
}elseif($item instanceof Hoe){ }elseif($item instanceof Hoe){
$item->applyDamage(1); $item->applyDamage(1);
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::FARMLAND)); $this->getWorld()->setBlock($this, VanillaBlocks::FARMLAND());
return true; return true;
}elseif($item instanceof Shovel and $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){ }elseif($item instanceof Shovel and $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){
$item->applyDamage(1); $item->applyDamage(1);
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::GRASS_PATH)); $this->getWorld()->setBlock($this, VanillaBlocks::GRASS_PATH());
return true; return true;
} }

View File

@ -40,7 +40,7 @@ class GrassPath extends Transparent{
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
if($this->getSide(Facing::UP)->isSolid()){ if($this->getSide(Facing::UP)->isSolid()){
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT)); $this->world->setBlock($this, VanillaBlocks::DIRT());
} }
} }

View File

@ -43,7 +43,7 @@ class Ice extends Transparent{
public function onBreak(Item $item, ?Player $player = null) : bool{ public function onBreak(Item $item, ?Player $player = null) : bool{
if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH())){ if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH())){
return $this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::WATER)); return $this->getWorld()->setBlock($this, VanillaBlocks::WATER());
} }
return parent::onBreak($item, $player); return parent::onBreak($item, $player);
} }

View File

@ -69,16 +69,16 @@ class Lava extends Liquid{
if($colliding !== null){ if($colliding !== null){
if($this->decay === 0){ if($this->decay === 0){
$this->liquidCollide($colliding, BlockFactory::get(BlockLegacyIds::OBSIDIAN)); $this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN());
}elseif($this->decay <= 4){ }elseif($this->decay <= 4){
$this->liquidCollide($colliding, BlockFactory::get(BlockLegacyIds::COBBLESTONE)); $this->liquidCollide($colliding, VanillaBlocks::COBBLESTONE());
} }
} }
} }
protected function flowIntoBlock(Block $block, int $newFlowDecay, bool $falling) : void{ protected function flowIntoBlock(Block $block, int $newFlowDecay, bool $falling) : void{
if($block instanceof Water){ if($block instanceof Water){
$block->liquidCollide($this, BlockFactory::get(BlockLegacyIds::STONE)); $block->liquidCollide($this, VanillaBlocks::STONE());
}else{ }else{
parent::flowIntoBlock($block, $newFlowDecay, $falling); parent::flowIntoBlock($block, $newFlowDecay, $falling);
} }

View File

@ -283,7 +283,7 @@ abstract class Liquid extends Transparent{
if($falling !== $this->falling or (!$falling and $newDecay !== $this->decay)){ if($falling !== $this->falling or (!$falling and $newDecay !== $this->decay)){
if(!$falling and $newDecay < 0){ if(!$falling and $newDecay < 0){
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR)); $this->world->setBlock($this, VanillaBlocks::AIR());
return; return;
} }

View File

@ -26,6 +26,6 @@ namespace pocketmine\block;
class MelonStem extends Stem{ class MelonStem extends Stem{
protected function getPlant() : Block{ protected function getPlant() : Block{
return BlockFactory::get(BlockLegacyIds::MELON_BLOCK); return VanillaBlocks::MELON();
} }
} }

View File

@ -53,7 +53,7 @@ class Mycelium extends Solid{
$block = $this->getWorld()->getBlockAt($x, $y, $z); $block = $this->getWorld()->getBlockAt($x, $y, $z);
if($block->getId() === BlockLegacyIds::DIRT){ if($block->getId() === BlockLegacyIds::DIRT){
if($block->getSide(Facing::UP) instanceof Transparent){ if($block->getSide(Facing::UP) instanceof Transparent){
$ev = new BlockSpreadEvent($block, $this, BlockFactory::get(BlockLegacyIds::MYCELIUM)); $ev = new BlockSpreadEvent($block, $this, VanillaBlocks::MYCELIUM());
$ev->call(); $ev->call();
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->getWorld()->setBlock($block, $ev->getNewState()); $this->getWorld()->setBlock($block, $ev->getNewState());

View File

@ -26,6 +26,6 @@ namespace pocketmine\block;
class PumpkinStem extends Stem{ class PumpkinStem extends Stem{
protected function getPlant() : Block{ protected function getPlant() : Block{
return BlockFactory::get(BlockLegacyIds::PUMPKIN); return VanillaBlocks::PUMPKIN();
} }
} }

View File

@ -89,7 +89,7 @@ class SnowLayer extends Flowable implements Fallable{
public function onRandomTick() : void{ public function onRandomTick() : void{
if($this->world->getBlockLightAt($this->x, $this->y, $this->z) >= 12){ if($this->world->getBlockLightAt($this->x, $this->y, $this->z) >= 12){
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR), false); $this->getWorld()->setBlock($this, VanillaBlocks::AIR(), false);
} }
} }

View File

@ -59,7 +59,7 @@ class Sugarcane extends Flowable{
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z); $b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
if($b->getId() === BlockLegacyIds::AIR){ if($b->getId() === BlockLegacyIds::AIR){
$ev = new BlockGrowEvent($b, BlockFactory::get(BlockLegacyIds::SUGARCANE_BLOCK)); $ev = new BlockGrowEvent($b, VanillaBlocks::SUGARCANE());
$ev->call(); $ev->call();
if($ev->isCancelled()){ if($ev->isCancelled()){
break; break;
@ -98,7 +98,7 @@ class Sugarcane extends Flowable{
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z); $b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
if($b->getId() === BlockLegacyIds::AIR){ if($b->getId() === BlockLegacyIds::AIR){
$this->getWorld()->setBlock($b, BlockFactory::get(BlockLegacyIds::SUGARCANE_BLOCK)); $this->getWorld()->setBlock($b, VanillaBlocks::SUGARCANE());
break; break;
} }
} }

View File

@ -90,7 +90,7 @@ class TNT extends Solid{
} }
public function ignite(int $fuse = 80) : void{ public function ignite(int $fuse = 80) : void{
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR)); $this->getWorld()->setBlock($this, VanillaBlocks::AIR());
$mot = (new Random())->nextSignedFloat() * M_PI * 2; $mot = (new Random())->nextSignedFloat() * M_PI * 2;
$nbt = EntityFactory::createBaseNBT($this->add(0.5, 0, 0.5), new Vector3(-sin($mot) * 0.02, 0.2, -cos($mot) * 0.02)); $nbt = EntityFactory::createBaseNBT($this->add(0.5, 0, 0.5), new Vector3(-sin($mot) * 0.02, 0.2, -cos($mot) * 0.02));

File diff suppressed because it is too large Load Diff

View File

@ -23,10 +23,10 @@ declare(strict_types=1);
namespace pocketmine\block\utils; namespace pocketmine\block\utils;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\BlockLegacyIds;
use pocketmine\block\Fire; use pocketmine\block\Fire;
use pocketmine\block\Liquid; use pocketmine\block\Liquid;
use pocketmine\block\VanillaBlocks;
use pocketmine\entity\EntityFactory; use pocketmine\entity\EntityFactory;
use pocketmine\entity\object\FallingBlock; use pocketmine\entity\object\FallingBlock;
use pocketmine\math\Facing; use pocketmine\math\Facing;
@ -49,7 +49,7 @@ trait FallableTrait{
$pos = $this->asPosition(); $pos = $this->asPosition();
$down = $pos->world->getBlock($pos->getSide(Facing::DOWN)); $down = $pos->world->getBlock($pos->getSide(Facing::DOWN));
if($down->getId() === BlockLegacyIds::AIR or $down instanceof Liquid or $down instanceof Fire){ if($down->getId() === BlockLegacyIds::AIR or $down instanceof Liquid or $down instanceof Fire){
$pos->world->setBlock($pos, BlockFactory::get(BlockLegacyIds::AIR)); $pos->world->setBlock($pos, VanillaBlocks::AIR());
$nbt = EntityFactory::createBaseNBT($pos->add(0.5, 0, 0.5)); $nbt = EntityFactory::createBaseNBT($pos->add(0.5, 0, 0.5));
$nbt->setInt("TileID", $this->getId()); $nbt->setInt("TileID", $this->getId());

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\entity\object; namespace pocketmine\entity\object;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -109,7 +108,7 @@ class Painting extends Entity{
//non-living entities don't have a way to create drops generically yet //non-living entities don't have a way to create drops generically yet
$this->world->dropItem($this, ItemFactory::get(Item::PAINTING)); $this->world->dropItem($this, ItemFactory::get(Item::PAINTING));
} }
$this->world->addParticle($this->add(0.5, 0.5, 0.5), new DestroyBlockParticle(BlockFactory::get(BlockLegacyIds::PLANKS))); $this->world->addParticle($this->add(0.5, 0.5, 0.5), new DestroyBlockParticle(VanillaBlocks::OAK_PLANKS()));
} }
protected function recalculateBoundingBox() : void{ protected function recalculateBoundingBox() : void{

View File

@ -23,8 +23,8 @@ declare(strict_types=1);
namespace pocketmine\entity\projectile; namespace pocketmine\entity\projectile;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\BlockLegacyIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\entity\effect\EffectInstance; use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\effect\InstantEffect; use pocketmine\entity\effect\InstantEffect;
use pocketmine\entity\Living; use pocketmine\entity\Living;
@ -123,11 +123,11 @@ class SplashPotion extends Throwable{
$blockIn = $event->getBlockHit()->getSide($event->getRayTraceResult()->getHitFace()); $blockIn = $event->getBlockHit()->getSide($event->getRayTraceResult()->getHitFace());
if($blockIn->getId() === BlockLegacyIds::FIRE){ if($blockIn->getId() === BlockLegacyIds::FIRE){
$this->world->setBlock($blockIn, BlockFactory::get(BlockLegacyIds::AIR)); $this->world->setBlock($blockIn, VanillaBlocks::AIR());
} }
foreach($blockIn->getHorizontalSides() as $horizontalSide){ foreach($blockIn->getHorizontalSides() as $horizontalSide){
if($horizontalSide->getId() === BlockLegacyIds::FIRE){ if($horizontalSide->getId() === BlockLegacyIds::FIRE){
$this->world->setBlock($horizontalSide, BlockFactory::get(BlockLegacyIds::AIR)); $this->world->setBlock($horizontalSide, VanillaBlocks::AIR());
} }
} }
} }

View File

@ -25,11 +25,10 @@ namespace pocketmine\item;
use Ds\Deque; use Ds\Deque;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\tile\Banner as TileBanner; use pocketmine\block\tile\Banner as TileBanner;
use pocketmine\block\utils\BannerPattern; use pocketmine\block\utils\BannerPattern;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\block\VanillaBlocks;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
@ -54,7 +53,7 @@ class Banner extends Item{
} }
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::STANDING_BANNER); return VanillaBlocks::BANNER();
} }
public function getMaxStackSize() : int{ public function getMaxStackSize() : int{

View File

@ -24,9 +24,8 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\block\VanillaBlocks;
class Bed extends Item{ class Bed extends Item{
@ -46,7 +45,7 @@ class Bed extends Item{
} }
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::BED_BLOCK); return VanillaBlocks::BED();
} }
public function getMaxStackSize() : int{ public function getMaxStackSize() : int{

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class BeetrootSeeds extends Item{ class BeetrootSeeds extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::BEETROOT_BLOCK); return VanillaBlocks::BEETROOTS();
} }
} }

View File

@ -24,9 +24,8 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\Liquid; use pocketmine\block\Liquid;
use pocketmine\block\VanillaBlocks;
use pocketmine\event\player\PlayerBucketFillEvent; use pocketmine\event\player\PlayerBucketFillEvent;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -47,7 +46,7 @@ class Bucket extends Item{
$ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem); $ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem);
$ev->call(); $ev->call();
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$player->getWorld()->setBlock($blockClicked, BlockFactory::get(BlockLegacyIds::AIR)); $player->getWorld()->setBlock($blockClicked, VanillaBlocks::AIR());
$player->getWorld()->addSound($blockClicked->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound()); $player->getWorld()->addSound($blockClicked->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound());
if($player->hasFiniteResources()){ if($player->hasFiniteResources()){
if($stack->getCount() === 0){ if($stack->getCount() === 0){

View File

@ -24,13 +24,12 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class Carrot extends Food{ class Carrot extends Food{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::CARROT_BLOCK); return VanillaBlocks::CARROTS();
} }
public function getFoodRestore() : int{ public function getFoodRestore() : int{

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class CocoaBeans extends Item{ class CocoaBeans extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::COCOA); return VanillaBlocks::COCOA_POD();
} }
} }

View File

@ -24,8 +24,8 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\BlockLegacyIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
use pocketmine\world\sound\FlintSteelSound; use pocketmine\world\sound\FlintSteelSound;
@ -37,7 +37,7 @@ class FlintSteel extends Tool{
if($blockReplace->getId() === BlockLegacyIds::AIR){ if($blockReplace->getId() === BlockLegacyIds::AIR){
$world = $player->getWorld(); $world = $player->getWorld();
assert($world !== null); assert($world !== null);
$world->setBlock($blockReplace, BlockFactory::get(BlockLegacyIds::FIRE)); $world->setBlock($blockReplace, VanillaBlocks::FIRE());
$world->addSound($blockReplace->add(0.5, 0.5, 0.5), new FlintSteelSound()); $world->addSound($blockReplace->add(0.5, 0.5, 0.5), new FlintSteelSound());
$this->applyDamage(1); $this->applyDamage(1);

View File

@ -28,9 +28,8 @@ namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockBreakInfo; use pocketmine\block\BlockBreakInfo;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockToolType; use pocketmine\block\BlockToolType;
use pocketmine\block\VanillaBlocks;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\item\enchantment\Enchantment; use pocketmine\item\enchantment\Enchantment;
use pocketmine\item\enchantment\EnchantmentInstance; use pocketmine\item\enchantment\EnchantmentInstance;
@ -529,7 +528,7 @@ class Item implements ItemIds, \JsonSerializable{
* @return Block * @return Block
*/ */
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::AIR); return VanillaBlocks::AIR();
} }
/** /**

View File

@ -28,6 +28,7 @@ use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\SkullType; use pocketmine\block\utils\SkullType;
use pocketmine\block\utils\TreeType; use pocketmine\block\utils\TreeType;
use pocketmine\block\VanillaBlocks;
use pocketmine\entity\EntityFactory; use pocketmine\entity\EntityFactory;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
@ -218,8 +219,8 @@ class ItemFactory{
self::register(new Leggings(Item::LEATHER_LEGGINGS, 0, "Leather Pants", new ArmorTypeInfo(2, 76))); self::register(new Leggings(Item::LEATHER_LEGGINGS, 0, "Leather Pants", new ArmorTypeInfo(2, 76)));
//TODO: fix metadata for buckets with still liquid in them //TODO: fix metadata for buckets with still liquid in them
//the meta values are intentionally hardcoded because block IDs will change in the future //the meta values are intentionally hardcoded because block IDs will change in the future
self::register(new LiquidBucket(Item::BUCKET, 8, "Water Bucket", BlockLegacyIds::FLOWING_WATER)); self::register(new LiquidBucket(Item::BUCKET, 8, "Water Bucket", VanillaBlocks::WATER()));
self::register(new LiquidBucket(Item::BUCKET, 10, "Lava Bucket", BlockLegacyIds::FLOWING_LAVA)); self::register(new LiquidBucket(Item::BUCKET, 10, "Lava Bucket", VanillaBlocks::LAVA()));
self::register(new Melon(Item::MELON, 0, "Melon")); self::register(new Melon(Item::MELON, 0, "Melon"));
self::register(new MelonSeeds(Item::MELON_SEEDS, 0, "Melon Seeds")); self::register(new MelonSeeds(Item::MELON_SEEDS, 0, "Melon Seeds"));
self::register(new MilkBucket(Item::BUCKET, 1, "Milk Bucket")); self::register(new MilkBucket(Item::BUCKET, 1, "Milk Bucket"));

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\Lava; use pocketmine\block\Lava;
use pocketmine\block\Liquid; use pocketmine\block\Liquid;
use pocketmine\event\player\PlayerBucketEmptyEvent; use pocketmine\event\player\PlayerBucketEmptyEvent;
@ -32,12 +31,13 @@ use pocketmine\math\Vector3;
use pocketmine\player\Player; use pocketmine\player\Player;
class LiquidBucket extends Item{ class LiquidBucket extends Item{
/** @var int|null */
protected $liquidId;
public function __construct(int $id, int $meta, string $name, int $liquidId){ /** @var Liquid */
private $liquid;
public function __construct(int $id, int $meta, string $name, Liquid $liquid){
parent::__construct($id, $meta, $name); parent::__construct($id, $meta, $name);
$this->liquidId = $liquidId; $this->liquid = $liquid;
} }
public function getMaxStackSize() : int{ public function getMaxStackSize() : int{
@ -45,7 +45,7 @@ class LiquidBucket extends Item{
} }
public function getFuelTime() : int{ public function getFuelTime() : int{
if(BlockFactory::get($this->liquidId) instanceof Lava){ if($this->liquid instanceof Lava){
return 20000; return 20000;
} }
@ -58,23 +58,20 @@ class LiquidBucket extends Item{
} }
//TODO: move this to generic placement logic //TODO: move this to generic placement logic
$resultBlock = BlockFactory::get($this->liquidId); $resultBlock = clone $this->liquid;
if($resultBlock instanceof Liquid){ //TODO: this should never be false
$ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, ItemFactory::get(Item::BUCKET));
$ev->call();
if(!$ev->isCancelled()){
$player->getWorld()->setBlock($blockReplace, $resultBlock->getFlowingForm());
$player->getWorld()->addSound($blockClicked->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
if($player->hasFiniteResources()){ $ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, ItemFactory::get(Item::BUCKET));
$player->getInventory()->setItemInHand($ev->getItem()); $ev->call();
} if(!$ev->isCancelled()){
return ItemUseResult::SUCCESS(); $player->getWorld()->setBlock($blockReplace, $resultBlock->getFlowingForm());
$player->getWorld()->addSound($blockClicked->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
if($player->hasFiniteResources()){
$player->getInventory()->setItemInHand($ev->getItem());
} }
return ItemUseResult::SUCCESS();
return ItemUseResult::FAIL();
} }
return ItemUseResult::NONE(); return ItemUseResult::FAIL();
} }
} }

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class MelonSeeds extends Item{ class MelonSeeds extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::MELON_STEM); return VanillaBlocks::MELON_STEM();
} }
} }

View File

@ -24,13 +24,12 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class Potato extends Food{ class Potato extends Food{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::POTATO_BLOCK); return VanillaBlocks::POTATOES();
} }
public function getFoodRestore() : int{ public function getFoodRestore() : int{

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class PumpkinSeeds extends Item{ class PumpkinSeeds extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::PUMPKIN_STEM); return VanillaBlocks::PUMPKIN_STEM();
} }
} }

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class Redstone extends Item{ class Redstone extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::REDSTONE_WIRE); return VanillaBlocks::REDSTONE_WIRE();
} }
} }

View File

@ -24,9 +24,8 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\SkullType; use pocketmine\block\utils\SkullType;
use pocketmine\block\VanillaBlocks;
class Skull extends Item{ class Skull extends Item{
@ -39,7 +38,7 @@ class Skull extends Item{
} }
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::SKULL_BLOCK); return VanillaBlocks::MOB_HEAD();
} }
public function getSkullType() : SkullType{ public function getSkullType() : SkullType{

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class StringItem extends Item{ class StringItem extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::TRIPWIRE); return VanillaBlocks::TRIPWIRE();
} }
} }

View File

@ -24,12 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item; namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
class WheatSeeds extends Item{ class WheatSeeds extends Item{
public function getBlock() : Block{ public function getBlock() : Block{
return BlockFactory::get(BlockLegacyIds::WHEAT_BLOCK); return VanillaBlocks::WHEAT();
} }
} }

View File

@ -24,9 +24,9 @@ declare(strict_types=1);
namespace pocketmine\player; namespace pocketmine\player;
use pocketmine\block\Bed; use pocketmine\block\Bed;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\BlockLegacyIds;
use pocketmine\block\UnknownBlock; use pocketmine\block\UnknownBlock;
use pocketmine\block\VanillaBlocks;
use pocketmine\command\CommandSender; use pocketmine\command\CommandSender;
use pocketmine\crafting\CraftingGrid; use pocketmine\crafting\CraftingGrid;
use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\Effect;
@ -1767,7 +1767,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$block = $target->getSide($face); $block = $target->getSide($face);
if($block->getId() === BlockLegacyIds::FIRE){ if($block->getId() === BlockLegacyIds::FIRE){
$this->world->setBlock($block, BlockFactory::get(BlockLegacyIds::AIR)); $this->world->setBlock($block, VanillaBlocks::AIR());
return true; return true;
} }

View File

@ -25,8 +25,8 @@ namespace pocketmine\world;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\TNT; use pocketmine\block\TNT;
use pocketmine\block\VanillaBlocks;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\event\block\BlockUpdateEvent; use pocketmine\event\block\BlockUpdateEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent; use pocketmine\event\entity\EntityDamageByBlockEvent;
@ -200,7 +200,7 @@ class Explosion{
$air = ItemFactory::air(); $air = ItemFactory::air();
$airBlock = BlockFactory::get(BlockLegacyIds::AIR); $airBlock = VanillaBlocks::AIR();
foreach($this->affectedBlocks as $block){ foreach($this->affectedBlocks as $block){
if($block instanceof TNT){ if($block instanceof TNT){

View File

@ -25,7 +25,7 @@ namespace pocketmine\world;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory; use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\VanillaBlocks;
use pocketmine\world\format\Chunk; use pocketmine\world\format\Chunk;
use pocketmine\world\utils\SubChunkIteratorManager; use pocketmine\world\utils\SubChunkIteratorManager;
use const INT32_MAX; use const INT32_MAX;
@ -55,7 +55,7 @@ class SimpleChunkManager implements ChunkManager{
if($this->terrainPointer->moveTo($x, $y, $z, false)){ if($this->terrainPointer->moveTo($x, $y, $z, false)){
return BlockFactory::fromFullBlock($this->terrainPointer->currentSubChunk->getFullBlock($x & 0xf, $y & 0xf, $z & 0xf)); return BlockFactory::fromFullBlock($this->terrainPointer->currentSubChunk->getFullBlock($x & 0xf, $y & 0xf, $z & 0xf));
} }
return BlockFactory::get(BlockLegacyIds::AIR); return VanillaBlocks::AIR();
} }
public function setBlockAt(int $x, int $y, int $z, Block $block) : bool{ public function setBlockAt(int $x, int $y, int $z, Block $block) : bool{

View File

@ -23,18 +23,17 @@ declare(strict_types=1);
namespace pocketmine\world\biome; namespace pocketmine\world\biome;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
abstract class GrassyBiome extends Biome{ abstract class GrassyBiome extends Biome{
public function __construct(){ public function __construct(){
$this->setGroundCover([ $this->setGroundCover([
BlockFactory::get(BlockLegacyIds::GRASS), VanillaBlocks::GRASS(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT) VanillaBlocks::DIRT()
]); ]);
} }
} }

View File

@ -23,19 +23,18 @@ declare(strict_types=1);
namespace pocketmine\world\biome; namespace pocketmine\world\biome;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\world\generator\populator\TallGrass; use pocketmine\world\generator\populator\TallGrass;
class OceanBiome extends Biome{ class OceanBiome extends Biome{
public function __construct(){ public function __construct(){
$this->setGroundCover([ $this->setGroundCover([
BlockFactory::get(BlockLegacyIds::GRAVEL), VanillaBlocks::GRAVEL(),
BlockFactory::get(BlockLegacyIds::GRAVEL), VanillaBlocks::GRAVEL(),
BlockFactory::get(BlockLegacyIds::GRAVEL), VanillaBlocks::GRAVEL(),
BlockFactory::get(BlockLegacyIds::GRAVEL), VanillaBlocks::GRAVEL(),
BlockFactory::get(BlockLegacyIds::GRAVEL) VanillaBlocks::GRAVEL()
]); ]);
$tallGrass = new TallGrass(); $tallGrass = new TallGrass();

View File

@ -23,19 +23,18 @@ declare(strict_types=1);
namespace pocketmine\world\biome; namespace pocketmine\world\biome;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\world\generator\populator\TallGrass; use pocketmine\world\generator\populator\TallGrass;
class RiverBiome extends Biome{ class RiverBiome extends Biome{
public function __construct(){ public function __construct(){
$this->setGroundCover([ $this->setGroundCover([
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT) VanillaBlocks::DIRT()
]); ]);
$tallGrass = new TallGrass(); $tallGrass = new TallGrass();

View File

@ -23,18 +23,17 @@ declare(strict_types=1);
namespace pocketmine\world\biome; namespace pocketmine\world\biome;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
abstract class SandyBiome extends Biome{ abstract class SandyBiome extends Biome{
public function __construct(){ public function __construct(){
$this->setGroundCover([ $this->setGroundCover([
BlockFactory::get(BlockLegacyIds::SAND), VanillaBlocks::SAND(),
BlockFactory::get(BlockLegacyIds::SAND), VanillaBlocks::SAND(),
BlockFactory::get(BlockLegacyIds::SANDSTONE), VanillaBlocks::SANDSTONE(),
BlockFactory::get(BlockLegacyIds::SANDSTONE), VanillaBlocks::SANDSTONE(),
BlockFactory::get(BlockLegacyIds::SANDSTONE) VanillaBlocks::SANDSTONE()
]); ]);
} }
} }

View File

@ -23,18 +23,17 @@ declare(strict_types=1);
namespace pocketmine\world\biome; namespace pocketmine\world\biome;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
abstract class SnowyBiome extends Biome{ abstract class SnowyBiome extends Biome{
public function __construct(){ public function __construct(){
$this->setGroundCover([ $this->setGroundCover([
BlockFactory::get(BlockLegacyIds::SNOW_LAYER), VanillaBlocks::SNOW_LAYER(),
BlockFactory::get(BlockLegacyIds::GRASS), VanillaBlocks::GRASS(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT), VanillaBlocks::DIRT(),
BlockFactory::get(BlockLegacyIds::DIRT) VanillaBlocks::DIRT()
]); ]);
} }
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator; namespace pocketmine\world\generator;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\item\ItemFactory; use pocketmine\item\ItemFactory;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
use pocketmine\world\format\Chunk; use pocketmine\world\format\Chunk;
@ -73,14 +72,14 @@ class Flat extends Generator{
if(isset($this->options["decoration"])){ if(isset($this->options["decoration"])){
$ores = new Ore(); $ores = new Ore();
$ores->setOreTypes([ $ores->setOreTypes([
new OreType(BlockFactory::get(BlockLegacyIds::COAL_ORE), 20, 16, 0, 128), new OreType(VanillaBlocks::COAL_ORE(), 20, 16, 0, 128),
new OreType(BlockFactory::get(BlockLegacyIds::IRON_ORE), 20, 8, 0, 64), new OreType(VanillaBlocks::IRON_ORE(), 20, 8, 0, 64),
new OreType(BlockFactory::get(BlockLegacyIds::REDSTONE_ORE), 8, 7, 0, 16), new OreType(VanillaBlocks::REDSTONE_ORE(), 8, 7, 0, 16),
new OreType(BlockFactory::get(BlockLegacyIds::LAPIS_ORE), 1, 6, 0, 32), new OreType(VanillaBlocks::LAPIS_LAZULI_ORE(), 1, 6, 0, 32),
new OreType(BlockFactory::get(BlockLegacyIds::GOLD_ORE), 2, 8, 0, 32), new OreType(VanillaBlocks::GOLD_ORE(), 2, 8, 0, 32),
new OreType(BlockFactory::get(BlockLegacyIds::DIAMOND_ORE), 1, 7, 0, 16), new OreType(VanillaBlocks::DIAMOND_ORE(), 1, 7, 0, 16),
new OreType(BlockFactory::get(BlockLegacyIds::DIRT), 20, 32, 0, 128), new OreType(VanillaBlocks::DIRT(), 20, 32, 0, 128),
new OreType(BlockFactory::get(BlockLegacyIds::GRAVEL), 10, 16, 0, 128) new OreType(VanillaBlocks::GRAVEL(), 10, 16, 0, 128)
]); ]);
$this->populators[] = $ores; $this->populators[] = $ores;
} }

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\hell; namespace pocketmine\world\generator\hell;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\world\biome\Biome; use pocketmine\world\biome\Biome;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
use pocketmine\world\generator\Generator; use pocketmine\world\generator\Generator;
@ -85,9 +84,9 @@ class Nether extends Generator{
$chunk = $this->world->getChunk($chunkX, $chunkZ); $chunk = $this->world->getChunk($chunkX, $chunkZ);
$bedrock = BlockFactory::get(BlockLegacyIds::BEDROCK)->getFullId(); $bedrock = VanillaBlocks::BEDROCK()->getFullId();
$netherrack = BlockFactory::get(BlockLegacyIds::NETHERRACK)->getFullId(); $netherrack = VanillaBlocks::NETHERRACK()->getFullId();
$stillLava = BlockFactory::get(BlockLegacyIds::STILL_LAVA)->getFullId(); $stillLava = VanillaBlocks::LAVA()->getFullId();
for($x = 0; $x < 16; ++$x){ for($x = 0; $x < 16; ++$x){
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\normal; namespace pocketmine\world\generator\normal;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\world\biome\Biome; use pocketmine\world\biome\Biome;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
use pocketmine\world\generator\biome\BiomeSelector; use pocketmine\world\generator\biome\BiomeSelector;
@ -120,14 +119,14 @@ class Normal extends Generator{
$ores = new Ore(); $ores = new Ore();
$ores->setOreTypes([ $ores->setOreTypes([
new OreType(BlockFactory::get(BlockLegacyIds::COAL_ORE), 20, 16, 0, 128), new OreType(VanillaBlocks::COAL_ORE(), 20, 16, 0, 128),
new OreType(BlockFactory::get(BlockLegacyIds::IRON_ORE), 20, 8, 0, 64), new OreType(VanillaBlocks::IRON_ORE(), 20, 8, 0, 64),
new OreType(BlockFactory::get(BlockLegacyIds::REDSTONE_ORE), 8, 7, 0, 16), new OreType(VanillaBlocks::REDSTONE_ORE(), 8, 7, 0, 16),
new OreType(BlockFactory::get(BlockLegacyIds::LAPIS_ORE), 1, 6, 0, 32), new OreType(VanillaBlocks::LAPIS_LAZULI_ORE(), 1, 6, 0, 32),
new OreType(BlockFactory::get(BlockLegacyIds::GOLD_ORE), 2, 8, 0, 32), new OreType(VanillaBlocks::GOLD_ORE(), 2, 8, 0, 32),
new OreType(BlockFactory::get(BlockLegacyIds::DIAMOND_ORE), 1, 7, 0, 16), new OreType(VanillaBlocks::DIAMOND_ORE(), 1, 7, 0, 16),
new OreType(BlockFactory::get(BlockLegacyIds::DIRT), 20, 32, 0, 128), new OreType(VanillaBlocks::DIRT(), 20, 32, 0, 128),
new OreType(BlockFactory::get(BlockLegacyIds::GRAVEL), 10, 16, 0, 128) new OreType(VanillaBlocks::GRAVEL(), 10, 16, 0, 128)
]); ]);
$this->populators[] = $ores; $this->populators[] = $ores;
} }
@ -173,9 +172,9 @@ class Normal extends Generator{
$biomeCache = []; $biomeCache = [];
$bedrock = BlockFactory::get(BlockLegacyIds::BEDROCK)->getFullId(); $bedrock = VanillaBlocks::BEDROCK()->getFullId();
$stillWater = BlockFactory::get(BlockLegacyIds::STILL_WATER)->getFullId(); $stillWater = VanillaBlocks::WATER()->getFullId();
$stone = BlockFactory::get(BlockLegacyIds::STONE)->getFullId(); $stone = VanillaBlocks::STONE()->getFullId();
for($x = 0; $x < 16; ++$x){ for($x = 0; $x < 16; ++$x){
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){

View File

@ -23,9 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object; namespace pocketmine\world\generator\object;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\TreeType;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
@ -34,7 +32,7 @@ class BirchTree extends Tree{
protected $superBirch = false; protected $superBirch = false;
public function __construct(bool $superBirch = false){ public function __construct(bool $superBirch = false){
parent::__construct(BlockFactory::get(BlockLegacyIds::LOG, TreeType::BIRCH()->getMagicNumber()), BlockFactory::get(BlockLegacyIds::LEAVES, TreeType::BIRCH()->getMagicNumber())); parent::__construct(VanillaBlocks::BIRCH_LOG(), VanillaBlocks::BIRCH_LEAVES());
$this->superBirch = $superBirch; $this->superBirch = $superBirch;
} }

View File

@ -23,13 +23,11 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object; namespace pocketmine\world\generator\object;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\TreeType;
class JungleTree extends Tree{ class JungleTree extends Tree{
public function __construct(){ public function __construct(){
parent::__construct(BlockFactory::get(BlockLegacyIds::LOG, TreeType::JUNGLE()->getMagicNumber()), BlockFactory::get(BlockLegacyIds::LEAVES, TreeType::JUNGLE()->getMagicNumber()), 8); parent::__construct(VanillaBlocks::JUNGLE_LOG(), VanillaBlocks::JUNGLE_LEAVES(), 8);
} }
} }

View File

@ -23,16 +23,14 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object; namespace pocketmine\world\generator\object;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\TreeType;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
class OakTree extends Tree{ class OakTree extends Tree{
public function __construct(){ public function __construct(){
parent::__construct(BlockFactory::get(BlockLegacyIds::LOG, TreeType::OAK()->getMagicNumber()), BlockFactory::get(BlockLegacyIds::LEAVES, TreeType::OAK()->getMagicNumber())); parent::__construct(VanillaBlocks::OAK_LOG(), VanillaBlocks::OAK_LEAVES());
} }
public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random $random) : void{ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random $random) : void{

View File

@ -23,9 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object; namespace pocketmine\world\generator\object;
use pocketmine\block\BlockFactory; use pocketmine\block\VanillaBlocks;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\utils\TreeType;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
@ -34,7 +32,7 @@ use function abs;
class SpruceTree extends Tree{ class SpruceTree extends Tree{
public function __construct(){ public function __construct(){
parent::__construct(BlockFactory::get(BlockLegacyIds::LOG, TreeType::SPRUCE()->getMagicNumber()), BlockFactory::get(BlockLegacyIds::LEAVES, TreeType::SPRUCE()->getMagicNumber()), 10); parent::__construct(VanillaBlocks::SPRUCE_LOG(), VanillaBlocks::SPRUCE_LEAVES(), 10);
} }
protected function generateChunkHeight(Random $random) : int{ protected function generateChunkHeight(Random $random) : int{

View File

@ -24,8 +24,8 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object; namespace pocketmine\world\generator\object;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\BlockLegacyIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
@ -36,9 +36,9 @@ class TallGrass{
public static function growGrass(ChunkManager $world, Vector3 $pos, Random $random, int $count = 15, int $radius = 10) : void{ public static function growGrass(ChunkManager $world, Vector3 $pos, Random $random, int $count = 15, int $radius = 10) : void{
/** @var Block[] $arr */ /** @var Block[] $arr */
$arr = [ $arr = [
BlockFactory::get(BlockLegacyIds::DANDELION), VanillaBlocks::DANDELION(),
BlockFactory::get(BlockLegacyIds::POPPY), VanillaBlocks::POPPY(),
$tallGrass = BlockFactory::get(BlockLegacyIds::TALL_GRASS, 1), $tallGrass = VanillaBlocks::TALL_GRASS(),
$tallGrass, $tallGrass,
$tallGrass, $tallGrass,
$tallGrass $tallGrass

View File

@ -24,11 +24,10 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object; namespace pocketmine\world\generator\object;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\Leaves; use pocketmine\block\Leaves;
use pocketmine\block\Sapling; use pocketmine\block\Sapling;
use pocketmine\block\utils\TreeType; use pocketmine\block\utils\TreeType;
use pocketmine\block\VanillaBlocks;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\world\BlockTransaction; use pocketmine\world\BlockTransaction;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
@ -121,7 +120,7 @@ abstract class Tree{
protected function placeTrunk(int $x, int $y, int $z, Random $random, int $trunkHeight, BlockTransaction $transaction) : void{ protected function placeTrunk(int $x, int $y, int $z, Random $random, int $trunkHeight, BlockTransaction $transaction) : void{
// The base dirt block // The base dirt block
$transaction->addBlockAt($x, $y - 1, $z, BlockFactory::get(BlockLegacyIds::DIRT)); $transaction->addBlockAt($x, $y - 1, $z, VanillaBlocks::DIRT());
for($yy = 0; $yy < $trunkHeight; ++$yy){ for($yy = 0; $yy < $trunkHeight; ++$yy){
if($this->canOverride($transaction->fetchBlockAt($x, $y + $yy, $z))){ if($this->canOverride($transaction->fetchBlockAt($x, $y + $yy, $z))){

View File

@ -23,8 +23,8 @@ declare(strict_types=1);
namespace pocketmine\world\generator\populator; namespace pocketmine\world\generator\populator;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds; use pocketmine\block\BlockLegacyIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\world\ChunkManager; use pocketmine\world\ChunkManager;
@ -46,7 +46,7 @@ class TallGrass extends Populator{
$this->world = $world; $this->world = $world;
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount; $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
$block = BlockFactory::get(BlockLegacyIds::TALL_GRASS, 1); $block = VanillaBlocks::TALL_GRASS();
for($i = 0; $i < $amount; ++$i){ for($i = 0; $i < $amount; ++$i){
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);