mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Merge branch 'master' into mcpe-1.2
This commit is contained in:
commit
159b2e3d5e
@ -2587,7 +2587,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
$block = $target->getSide($packet->face);
|
||||
if($block->getId() === Block::FIRE){
|
||||
$this->level->setBlock($block, new Air());
|
||||
$this->level->setBlock($block, Block::get(Block::AIR));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -30,4 +30,6 @@ class ActivatorRail extends Rail{
|
||||
public function getName() : string{
|
||||
return "Activator Rail";
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -377,12 +377,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*/
|
||||
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
|
||||
try{
|
||||
$block = self::$fullList[($id << 4) | $meta];
|
||||
if($block !== null){
|
||||
$block = clone $block;
|
||||
}else{
|
||||
$block = new UnknownBlock($id, $meta);
|
||||
}
|
||||
$block = clone self::$fullList[($id << 4) | $meta];
|
||||
}catch(\RuntimeException $e){
|
||||
//TODO: this probably should return null (out of bounds IDs may cause unexpected behaviour)
|
||||
$block = new UnknownBlock($id, $meta);
|
||||
@ -398,8 +393,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
return $block;
|
||||
}
|
||||
|
||||
|
||||
/** @var int */
|
||||
protected $id;
|
||||
/** @var int */
|
||||
protected $meta = 0;
|
||||
/** @var string */
|
||||
protected $fallbackName;
|
||||
@ -460,6 +456,19 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
$this->meta = $meta & 0x0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitmask to use to remove superfluous information from block meta when getting its item form or name.
|
||||
* This defaults to -1 (don't remove any data). Used to remove rotation data and bitflags from block drops.
|
||||
*
|
||||
* If your block should not have any meta value when it's dropped as an item, override this to return 0 in
|
||||
* descendent classes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getVariantBitmask() : int{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
|
||||
*
|
||||
@ -497,7 +506,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
* @return bool
|
||||
*/
|
||||
public function onBreak(Item $item) : bool{
|
||||
return $this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
return $this->getLevel()->setBlock($this, Block::get(Block::AIR), true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,7 +667,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*/
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage(), 1),
|
||||
Item::get($this->getItemId(), $this->getDamage() & $this->getVariantBitmask(), 1),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -44,4 +44,10 @@ class BrewingStand extends Transparent{
|
||||
public function getToolType() : int{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
@ -67,7 +67,7 @@ class BrownMushroom extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -118,11 +118,13 @@ class BurningFurnace extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -90,7 +90,7 @@ class Cactus extends Transparent{
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getId() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, Block::get(Block::CACTUS)));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
}
|
||||
@ -125,9 +125,7 @@ class Cactus extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -76,7 +76,7 @@ class Cake extends Transparent implements FoodSource{
|
||||
public function onUpdate(int $type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
@ -114,7 +114,7 @@ class Cake extends Transparent implements FoodSource{
|
||||
$clone = clone $this;
|
||||
$clone->meta++;
|
||||
if($clone->meta >= 0x06){
|
||||
$clone = new Air();
|
||||
$clone = Block::get(Block::AIR);
|
||||
}
|
||||
return $clone;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class Chest extends Transparent{
|
||||
if($t instanceof TileChest){
|
||||
$t->unpair();
|
||||
}
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -169,10 +169,8 @@ class Chest extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
|
@ -34,4 +34,6 @@ class CocoaBlock extends Solid{
|
||||
public function getName() : string{
|
||||
return "Cocoa Block";
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -42,4 +42,6 @@ class DaylightSensor extends Transparent{
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -30,4 +30,6 @@ class DetectorRail extends Rail{
|
||||
public function getName() : string{
|
||||
return "Detector Rail";
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -204,9 +204,9 @@ abstract class Door extends Transparent{
|
||||
public function onUpdate(int $type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), false);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), false);
|
||||
if($this->getSide(Vector3::SIDE_UP) instanceof Door){
|
||||
$this->getLevel()->setBlock($this->getSide(Vector3::SIDE_UP), new Air(), false);
|
||||
$this->getLevel()->setBlock($this->getSide(Vector3::SIDE_UP), Block::get(Block::AIR), false);
|
||||
}
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
@ -250,15 +250,15 @@ abstract class Door extends Transparent{
|
||||
if(($this->getDamage() & 0x08) === 0x08){
|
||||
$down = $this->getSide(Vector3::SIDE_DOWN);
|
||||
if($down->getId() === $this->getId()){
|
||||
$this->getLevel()->setBlock($down, new Air(), true);
|
||||
$this->getLevel()->setBlock($down, Block::get(Block::AIR), true);
|
||||
}
|
||||
}else{
|
||||
$up = $this->getSide(Vector3::SIDE_UP);
|
||||
if($up->getId() === $this->getId()){
|
||||
$this->getLevel()->setBlock($up, new Air(), true);
|
||||
$this->getLevel()->setBlock($up, Block::get(Block::AIR), true);
|
||||
}
|
||||
}
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -282,4 +282,8 @@ abstract class Door extends Transparent{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -104,6 +104,10 @@ class DoublePlant extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x07;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if(!$item->isShears() and ($this->meta === 2 or $this->meta === 3)){ //grass or fern
|
||||
if(mt_rand(0, 24) === 0){
|
||||
@ -115,8 +119,6 @@ class DoublePlant extends Flowable{
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x07, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
}
|
@ -92,9 +92,7 @@ class EnchantingTable extends Transparent{
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -19,8 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -97,10 +98,7 @@ class EndRod extends Flowable{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -75,10 +75,8 @@ class FenceGate extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
|
@ -87,14 +87,14 @@ class Fire extends Flowable{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== self::NETHERRACK){
|
||||
if(mt_rand(0, 2) === 0){
|
||||
if($this->meta === 0x0F){
|
||||
$this->level->setBlock($this, new Air());
|
||||
$this->level->setBlock($this, Block::get(Block::AIR));
|
||||
}else{
|
||||
$this->meta++;
|
||||
$this->level->setBlock($this, $this);
|
||||
|
@ -52,11 +52,13 @@ class GlazedTerracotta extends Solid{
|
||||
return $this->getLevel()->setBlock($block, $this, true, true);
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -105,12 +105,12 @@ class Grass extends Solid{
|
||||
return true;
|
||||
}elseif($item->isHoe()){
|
||||
$item->useOn($this);
|
||||
$this->getLevel()->setBlock($this, new Farmland());
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::FARMLAND));
|
||||
|
||||
return true;
|
||||
}elseif($item->isShovel() and $this->getSide(Vector3::SIDE_UP)->getId() === Block::AIR){
|
||||
$item->useOn($this);
|
||||
$this->getLevel()->setBlock($this, new GrassPath());
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::GRASS_PATH));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -53,9 +53,7 @@ class Gravel extends Fallable{
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
Item::get(Item::GRAVEL, 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
}
|
@ -58,10 +58,7 @@ class HayBale extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x03;
|
||||
}
|
||||
|
||||
}
|
@ -52,7 +52,7 @@ class Ice extends Transparent{
|
||||
}
|
||||
|
||||
public function onBreak(Item $item) : bool{
|
||||
$this->getLevel()->setBlock($this, new Water(), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::WATER), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -46,11 +46,13 @@ class IronBars extends Thin{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -139,10 +139,7 @@ class ItemFrame extends Flowable{
|
||||
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -149,9 +149,7 @@ class Ladder extends Transparent{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -241,7 +241,7 @@ abstract class Liquid extends Transparent{
|
||||
if($k !== $decay){
|
||||
$decay = $k;
|
||||
if($decay < 0){
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true, true);
|
||||
}else{
|
||||
$this->getLevel()->setBlock($this, Block::get($this->id, $decay), true, true);
|
||||
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
|
||||
@ -442,7 +442,7 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class MelonStem extends Crops{
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(Vector3::SIDE_DOWN);
|
||||
if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, Block::get(Block::MELON_BLOCK)));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class MossyCobblestone extends Cobblestone{
|
||||
|
||||
|
@ -65,7 +65,7 @@ class Mycelium extends Solid{
|
||||
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
if($block->getId() === Block::DIRT){
|
||||
if($block->getSide(Vector3::SIDE_UP) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, Block::get(Block::MYCELIUM)));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
|
@ -29,6 +29,10 @@ class NetherBrickStairs extends Stair{
|
||||
|
||||
protected $id = self::NETHER_BRICK_STAIRS;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
return "Nether Brick Stairs";
|
||||
}
|
||||
@ -41,8 +45,4 @@ class NetherBrickStairs extends Stair{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
}
|
@ -55,11 +55,13 @@ class Prismarine extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x03;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -56,4 +56,7 @@ class Pumpkin extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -68,7 +68,7 @@ class PumpkinStem extends Crops{
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(Vector3::SIDE_DOWN);
|
||||
if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Pumpkin()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, Block::get(Block::PUMPKIN)));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -57,11 +57,13 @@ class Quartz extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x03;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -75,4 +75,8 @@ class Rail extends Flowable{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -55,11 +55,13 @@ class Sandstone extends Solid{
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x03;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -55,7 +55,7 @@ class SignPost extends Transparent{
|
||||
return "Sign Post";
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -114,4 +114,8 @@ class SignPost extends Transparent{
|
||||
public function getToolType() : int{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -24,16 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorBlockMetaHelper;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class StainedGlass extends Glass{
|
||||
|
||||
protected $id = self::STAINED_GLASS;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Stained Glass";
|
||||
}
|
||||
|
@ -24,16 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorBlockMetaHelper;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class StainedGlassPane extends GlassPane{
|
||||
|
||||
protected $id = self::STAINED_GLASS_PANE;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Stained Glass Pane";
|
||||
}
|
||||
|
@ -145,11 +145,13 @@ abstract class Stair extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -58,9 +58,7 @@ class StoneBricks extends Solid{
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -38,4 +38,8 @@ class StoneButton extends Flowable{
|
||||
public function getHardness() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -42,4 +42,8 @@ class StonePressurePlate extends Transparent{
|
||||
public function getHardness() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Sugarcane extends Flowable{
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getId() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, Block::get(Block::SUGARCANE_BLOCK)));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
}
|
||||
@ -84,7 +84,7 @@ class Sugarcane extends Flowable{
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getId() === self::AIR){
|
||||
$this->getLevel()->setBlock($b, new Sugarcane(), true);
|
||||
$this->getLevel()->setBlock($b, Block::get(Block::SUGARCANE_BLOCK), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ class Sugarcane extends Flowable{
|
||||
public function place(Item $item, Block $block, Block $target, int $face, float $fx, float $fy, float $fz, Player $player = null) : bool{
|
||||
$down = $this->getSide(Vector3::SIDE_DOWN);
|
||||
if($down->getId() === self::SUGARCANE_BLOCK){
|
||||
$this->getLevel()->setBlock($block, new Sugarcane(), true);
|
||||
$this->getLevel()->setBlock($block, Block::get(Block::SUGARCANE_BLOCK), true);
|
||||
|
||||
return true;
|
||||
}elseif($down->getId() === self::GRASS or $down->getId() === self::DIRT or $down->getId() === self::SAND){
|
||||
@ -114,7 +114,7 @@ class Sugarcane extends Flowable{
|
||||
$block2 = $down->getSide(Vector3::SIDE_WEST);
|
||||
$block3 = $down->getSide(Vector3::SIDE_EAST);
|
||||
if(($block0 instanceof Water) or ($block1 instanceof Water) or ($block2 instanceof Water) or ($block3 instanceof Water)){
|
||||
$this->getLevel()->setBlock($block, new Sugarcane(), true);
|
||||
$this->getLevel()->setBlock($block, Block::get(Block::SUGARCANE_BLOCK), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -122,4 +122,8 @@ class Sugarcane extends Flowable{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ class TNT extends Solid{
|
||||
}
|
||||
|
||||
public function ignite(int $fuse = 80){
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true);
|
||||
|
||||
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
|
||||
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel(), new CompoundTag("", [
|
||||
|
@ -64,7 +64,7 @@ class TallGrass extends Flowable{
|
||||
public function onUpdate(int $type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true, true);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -93,9 +93,7 @@ class Torch extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -140,10 +140,8 @@ class Trapdoor extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
|
@ -34,4 +34,10 @@ class TripwireHook extends Flowable{
|
||||
public function getName() : string{
|
||||
return "Tripwire Hook";
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -174,11 +174,13 @@ class Vine extends Transparent{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
if($item->isShears()){
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
return parent::getDrops($item);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -80,9 +80,7 @@ class WaterLily extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -42,4 +42,8 @@ class WeightedPressurePlateLight extends Transparent{
|
||||
public function getHardness() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public function getVariantBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -69,10 +69,8 @@ class Wood extends Solid{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x03, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x03;
|
||||
}
|
||||
|
||||
public function getToolType() : int{
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class WoodenDoor extends Door{
|
||||
@ -35,10 +34,4 @@ class WoodenDoor extends Door{
|
||||
public function getToolType() : int{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -129,10 +129,8 @@ class WoodenSlab extends Transparent{
|
||||
return Tool::TYPE_AXE;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
return [
|
||||
Item::get($this->getItemId(), $this->getDamage() & 0x07, 1)
|
||||
];
|
||||
public function getVariantBitmask() : int{
|
||||
return 0x07;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
|
@ -41,8 +41,9 @@ class WoodenStairs extends Stair{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item) : array{
|
||||
//TODO: Hierarchy problem (base class is for stone stairs)
|
||||
return [
|
||||
Item::get($this->getItemId(), 0, 1)
|
||||
Item::get($this->getItemId(), $this->getDamage() & $this->getVariantBitmask(), 1)
|
||||
];
|
||||
}
|
||||
}
|
@ -28,6 +28,9 @@ use pocketmine\event\Cancellable;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
* Called when a player destroys a block somewhere in the world.
|
||||
*/
|
||||
class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
@ -42,30 +45,56 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
/** @var Item[] */
|
||||
protected $blockDrops = [];
|
||||
|
||||
public function __construct(Player $player, Block $block, Item $item, $instaBreak = false){
|
||||
$this->block = $block;
|
||||
public function __construct(Player $player, Block $block, Item $item, bool $instaBreak = false){
|
||||
parent::__construct($block);
|
||||
$this->item = $item;
|
||||
$this->player = $player;
|
||||
$this->instaBreak = (bool) $instaBreak;
|
||||
$this->blockDrops = $player->isSurvival() ? $block->getDrops($item) : [];
|
||||
|
||||
$this->instaBreak = $instaBreak;
|
||||
|
||||
if($player->isSurvival()){
|
||||
$this->setDrops($block->getDrops($item));
|
||||
}
|
||||
}
|
||||
|
||||
public function getPlayer(){
|
||||
/**
|
||||
* Returns the player who is destroying the block.
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer() : Player{
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
public function getItem(){
|
||||
/**
|
||||
* Returns the item used to destroy the block.
|
||||
* @return Item
|
||||
*/
|
||||
public function getItem() : Item{
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
public function getInstaBreak(){
|
||||
/**
|
||||
* Returns whether the block may be broken in less than the amount of time calculated. This is usually true for
|
||||
* creative players.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getInstaBreak() : bool{
|
||||
return $this->instaBreak;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $instaBreak
|
||||
*/
|
||||
public function setInstaBreak(bool $instaBreak){
|
||||
$this->instaBreak = $instaBreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getDrops(){
|
||||
public function getDrops() : array{
|
||||
return $this->blockDrops;
|
||||
}
|
||||
|
||||
@ -73,13 +102,15 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
* @param Item[] $drops
|
||||
*/
|
||||
public function setDrops(array $drops){
|
||||
$this->blockDrops = $drops;
|
||||
$this->setDropsVariadic(...$drops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $instaBreak
|
||||
* Variadic hack for easy array member type enforcement.
|
||||
*
|
||||
* @param Item[] ...$drops
|
||||
*/
|
||||
public function setInstaBreak($instaBreak){
|
||||
$this->instaBreak = (bool) $instaBreak;
|
||||
public function setDropsVariadic(Item ...$drops){
|
||||
$this->blockDrops = $drops;
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ abstract class BlockEvent extends Event{
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlock(){
|
||||
public function getBlock() : Block{
|
||||
return $this->block;
|
||||
}
|
||||
}
|
@ -26,6 +26,9 @@ namespace pocketmine\event\block;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
|
||||
/**
|
||||
* Called when plants or crops grow.
|
||||
*/
|
||||
class BlockGrowEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
@ -40,7 +43,7 @@ class BlockGrowEvent extends BlockEvent implements Cancellable{
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getNewState(){
|
||||
public function getNewState() : Block{
|
||||
return $this->newState;
|
||||
}
|
||||
|
||||
|
@ -40,36 +40,46 @@ class BlockPlaceEvent extends BlockEvent implements Cancellable{
|
||||
/** @var Item */
|
||||
protected $item;
|
||||
|
||||
|
||||
/** @var Block */
|
||||
protected $blockReplace;
|
||||
/** @var Block */
|
||||
protected $blockAgainst;
|
||||
|
||||
public function __construct(Player $player, Block $blockPlace, Block $blockReplace, Block $blockAgainst, Item $item){
|
||||
$this->block = $blockPlace;
|
||||
parent::__construct($blockPlace);
|
||||
$this->blockReplace = $blockReplace;
|
||||
$this->blockAgainst = $blockAgainst;
|
||||
$this->item = $item;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function getPlayer(){
|
||||
/**
|
||||
* Returns the player who is placing the block.
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer() : Player{
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item in hand
|
||||
*
|
||||
* @return mixed
|
||||
* @return Item
|
||||
*/
|
||||
public function getItem(){
|
||||
public function getItem() : Item{
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
public function getBlockReplaced(){
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlockReplaced() : Block{
|
||||
return $this->blockReplace;
|
||||
}
|
||||
|
||||
public function getBlockAgainst(){
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlockAgainst() : Block{
|
||||
return $this->blockAgainst;
|
||||
}
|
||||
}
|
@ -25,6 +25,9 @@ namespace pocketmine\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
|
||||
/**
|
||||
* Called when a block spreads to another block, such as grass spreading to nearby dirt blocks.
|
||||
*/
|
||||
class BlockSpreadEvent extends BlockFormEvent{
|
||||
public static $handlerList = null;
|
||||
|
||||
@ -39,7 +42,7 @@ class BlockSpreadEvent extends BlockFormEvent{
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getSource(){
|
||||
public function getSource() : Block{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
|
@ -23,14 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
|
||||
/**
|
||||
* Called when leaves decay due to not being attached to wood.
|
||||
*/
|
||||
class LeavesDecayEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
public function __construct(Block $block){
|
||||
parent::__construct($block);
|
||||
}
|
||||
|
||||
}
|
@ -52,14 +52,14 @@ class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer(){
|
||||
public function getPlayer() : Player{
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getLines(){
|
||||
public function getLines() : array{
|
||||
return $this->lines;
|
||||
}
|
||||
|
||||
@ -67,16 +67,21 @@ class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
* @param int $index 0-3
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException if the index is out of bounds
|
||||
*/
|
||||
public function getLine($index){
|
||||
public function getLine(int $index) : string{
|
||||
if($index < 0 or $index > 3){
|
||||
throw new \InvalidArgumentException("Index must be in the range 0-3!");
|
||||
}
|
||||
|
||||
return $this->lines[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $lines
|
||||
*
|
||||
* @throws \InvalidArgumentException if there are more or less than 4 lines in the passed array
|
||||
*/
|
||||
public function setLines(array $lines){
|
||||
if(count($lines) !== 4){
|
||||
@ -88,8 +93,10 @@ class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
/**
|
||||
* @param int $index 0-3
|
||||
* @param string $line
|
||||
*
|
||||
* @throws \InvalidArgumentException if the index is out of bounds
|
||||
*/
|
||||
public function setLine($index, $line){
|
||||
public function setLine(int $index, string $line){
|
||||
if($index < 0 or $index > 3){
|
||||
throw new \InvalidArgumentException("Index must be in the range 0-3!");
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class Bucket extends Item{
|
||||
$result->setDamage($target->getId());
|
||||
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
|
||||
if(!$ev->isCancelled()){
|
||||
$player->getLevel()->setBlock($target, new Air(), true, true);
|
||||
$player->getLevel()->setBlock($target, Block::get(Block::AIR), true, true);
|
||||
if($player->isSurvival()){
|
||||
$player->getInventory()->setItemInHand($ev->getItem());
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class FlintSteel extends Tool{
|
||||
|
||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->getId() === self::AIR and ($target instanceof Solid)){
|
||||
$level->setBlock($block, new Fire(), true);
|
||||
$level->setBlock($block, Block::get(Block::FIRE), true);
|
||||
if(($player->gamemode & 0x01) === 0 and $this->useOn($block)){
|
||||
if($this->getDamage() >= $this->getMaxDurability()){
|
||||
$player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0));
|
||||
|
@ -1652,7 +1652,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$above = $this->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
|
||||
if($above !== null){
|
||||
if($above->getId() === Item::FIRE){
|
||||
$this->setBlock($above, new Air(), true);
|
||||
$this->setBlock($above, Block::get(Block::AIR), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,17 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\generator;
|
||||
|
||||
use pocketmine\block\CoalOre;
|
||||
use pocketmine\block\DiamondOre;
|
||||
use pocketmine\block\Dirt;
|
||||
use pocketmine\block\GoldOre;
|
||||
use pocketmine\block\Gravel;
|
||||
use pocketmine\block\IronOre;
|
||||
use pocketmine\block\LapisOre;
|
||||
use pocketmine\block\RedstoneOre;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\ChunkManager;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\generator\object\OreType;
|
||||
use pocketmine\level\generator\populator\Ore;
|
||||
use pocketmine\level\generator\populator\Populator;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -67,14 +61,14 @@ class Flat extends Generator{
|
||||
if(isset($this->options["decoration"])){
|
||||
$ores = new Ore();
|
||||
$ores->setOreTypes([
|
||||
new object\OreType(new CoalOre(), 20, 16, 0, 128),
|
||||
new object\OreType(new IronOre(), 20, 8, 0, 64),
|
||||
new object\OreType(new RedstoneOre(), 8, 7, 0, 16),
|
||||
new object\OreType(new LapisOre(), 1, 6, 0, 32),
|
||||
new object\OreType(new GoldOre(), 2, 8, 0, 32),
|
||||
new object\OreType(new DiamondOre(), 1, 7, 0, 16),
|
||||
new object\OreType(new Dirt(), 20, 32, 0, 128),
|
||||
new object\OreType(new Gravel(), 10, 16, 0, 128)
|
||||
new OreType(Block::get(Block::COAL_ORE), 20, 16, 0, 128),
|
||||
new OreType(Block::get(Block::IRON_ORE), 20, 8, 0, 64),
|
||||
new OreType(Block::get(Block::REDSTONE_ORE), 8, 7, 0, 16),
|
||||
new OreType(Block::get(Block::LAPIS_ORE), 1, 6, 0, 32),
|
||||
new OreType(Block::get(Block::GOLD_ORE), 2, 8, 0, 32),
|
||||
new OreType(Block::get(Block::DIAMOND_ORE), 1, 7, 0, 16),
|
||||
new OreType(Block::get(Block::DIRT), 20, 32, 0, 128),
|
||||
new OreType(Block::get(Block::GRAVEL), 10, 16, 0, 128)
|
||||
]);
|
||||
$this->populators[] = $ores;
|
||||
}
|
||||
|
@ -24,14 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\level\generator\normal;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\CoalOre;
|
||||
use pocketmine\block\DiamondOre;
|
||||
use pocketmine\block\Dirt;
|
||||
use pocketmine\block\GoldOre;
|
||||
use pocketmine\block\Gravel;
|
||||
use pocketmine\block\IronOre;
|
||||
use pocketmine\block\LapisOre;
|
||||
use pocketmine\block\RedstoneOre;
|
||||
use pocketmine\level\ChunkManager;
|
||||
use pocketmine\level\generator\biome\Biome;
|
||||
use pocketmine\level\generator\biome\BiomeSelector;
|
||||
@ -179,14 +171,14 @@ class Normal extends Generator{
|
||||
|
||||
$ores = new Ore();
|
||||
$ores->setOreTypes([
|
||||
new OreType(new CoalOre(), 20, 16, 0, 128),
|
||||
new OreType(New IronOre(), 20, 8, 0, 64),
|
||||
new OreType(new RedstoneOre(), 8, 7, 0, 16),
|
||||
new OreType(new LapisOre(), 1, 6, 0, 32),
|
||||
new OreType(new GoldOre(), 2, 8, 0, 32),
|
||||
new OreType(new DiamondOre(), 1, 7, 0, 16),
|
||||
new OreType(new Dirt(), 20, 32, 0, 128),
|
||||
new OreType(new Gravel(), 10, 16, 0, 128)
|
||||
new OreType(Block::get(Block::COAL_ORE), 20, 16, 0, 128),
|
||||
new OreType(Block::get(Block::IRON_ORE), 20, 8, 0, 64),
|
||||
new OreType(Block::get(Block::REDSTONE_ORE), 8, 7, 0, 16),
|
||||
new OreType(Block::get(Block::LAPIS_ORE), 1, 6, 0, 32),
|
||||
new OreType(Block::get(Block::GOLD_ORE), 2, 8, 0, 32),
|
||||
new OreType(Block::get(Block::DIAMOND_ORE), 1, 7, 0, 16),
|
||||
new OreType(Block::get(Block::DIRT), 20, 32, 0, 128),
|
||||
new OreType(Block::get(Block::GRAVEL), 10, 16, 0, 128)
|
||||
]);
|
||||
$this->populators[] = $ores;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\generator\populator;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Water;
|
||||
use pocketmine\level\ChunkManager;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -38,7 +39,7 @@ class Pond extends Populator{
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 16);
|
||||
$y = $random->nextBoundedInt(128);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 16);
|
||||
$pond = new \pocketmine\level\generator\object\Pond($random, new Water());
|
||||
$pond = new \pocketmine\level\generator\object\Pond($random, Block::get(Block::WATER));
|
||||
if($pond->canPlaceObject($level, $v = new Vector3($x, $y, $z))){
|
||||
$pond->placeObject($level, $v);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class ExplodePacket extends DataPacket{
|
||||
$this->putUnsignedVarInt(count($this->records));
|
||||
if(count($this->records) > 0){
|
||||
foreach($this->records as $record){
|
||||
$this->putSignedBlockPosition($record->x, $record->y, $record->z);
|
||||
$this->putSignedBlockPosition((int) $record->x, (int) $record->y, (int) $record->z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,4 +70,4 @@ class ExplodePacket extends DataPacket{
|
||||
return $session->handleExplode($this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user