mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Renaming "Level" -> "World" (#2907)
This has been a pain point for a long time due to the misleading nature of the name "level". It's also confusing when trying to do things like getting the XP level of the player or such, and also does not translate well to other languages. This transition was already executed on the UI some time ago (language strings) and now it's time for the same change to occur on the API. This will burn a lot of plugins, but they'll acclimatize. Despite the scary size of this PR, there isn't actually so many changes to make. Most of this came from renaming `Position->getLevel()` to `Position->getWorld()`, or cosmetic changes like changing variable names or doc comments.
This commit is contained in:
@ -92,7 +92,7 @@ class Banner extends Transparent{
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileBanner){
|
||||
$this->baseColor = $tile->getBaseColor();
|
||||
$this->setPatterns($tile->getPatterns());
|
||||
@ -101,7 +101,7 @@ class Banner extends Transparent{
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
assert($tile instanceof TileBanner);
|
||||
$tile->setBaseColor($this->baseColor);
|
||||
$tile->setPatterns($this->patterns);
|
||||
@ -164,7 +164,7 @@ class Banner extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::opposite($this->facing))->getId() === BlockLegacyIds::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ abstract class BaseRail extends Flowable{
|
||||
if(isset($otherPossible[$otherSide])){
|
||||
$otherConnections[] = $otherSide;
|
||||
$other->setConnections($otherConnections);
|
||||
$other->level->setBlock($other, $other);
|
||||
$other->world->setBlock($other, $other);
|
||||
|
||||
$changed = true;
|
||||
$thisConnections[] = $thisSide;
|
||||
@ -275,11 +275,11 @@ abstract class BaseRail extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}else{
|
||||
foreach($this->connections as $connection){
|
||||
if(($connection & self::FLAG_ASCEND) !== 0 and $this->getSide($connection & ~self::FLAG_ASCEND)->isTransparent()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ use pocketmine\item\Bed as ItemBed;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\lang\TranslationContainer;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Bearing;
|
||||
use pocketmine\math\Facing;
|
||||
@ -37,6 +36,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Bed as TileBed;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class Bed extends Transparent{
|
||||
private const BITFLAG_OCCUPIED = 0x04;
|
||||
@ -75,7 +75,7 @@ class Bed extends Transparent{
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
//read extra state information from the tile - this is an ugly hack
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileBed){
|
||||
$this->color = $tile->getColor();
|
||||
}
|
||||
@ -84,7 +84,7 @@ class Bed extends Transparent{
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
//extra block properties storage hack
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileBed){
|
||||
$tile->setColor($this->color);
|
||||
}
|
||||
@ -111,11 +111,11 @@ class Bed extends Transparent{
|
||||
|
||||
public function setOccupied(bool $occupied = true) : void{
|
||||
$this->occupied = $occupied;
|
||||
$this->level->setBlock($this, $this, false);
|
||||
$this->world->setBlock($this, $this, false);
|
||||
|
||||
if(($other = $this->getOtherHalf()) !== null){
|
||||
$other->occupied = $occupied;
|
||||
$this->level->setBlock($other, $other, false);
|
||||
$this->world->setBlock($other, $other, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,9 +150,9 @@ class Bed extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
$time = $this->getLevel()->getTime() % Level::TIME_FULL;
|
||||
$time = $this->getWorld()->getTime() % World::TIME_FULL;
|
||||
|
||||
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
|
||||
$isNight = ($time >= World::TIME_NIGHT and $time < World::TIME_SUNRISE);
|
||||
|
||||
if(!$isNight){
|
||||
$player->sendMessage(new TranslationContainer(TextFormat::GRAY . "%tile.bed.noSleep"));
|
||||
@ -188,7 +188,7 @@ class Bed extends Transparent{
|
||||
parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
$nextState = clone $this;
|
||||
$nextState->head = true;
|
||||
$this->getLevel()->setBlock($next, $nextState);
|
||||
$this->getWorld()->setBlock($next, $nextState);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
@ -43,6 +41,8 @@ use pocketmine\network\mcpe\protocol\types\RuntimeBlockMapping;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\tile\TileFactory;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\World;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function dechex;
|
||||
@ -174,16 +174,16 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
}
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
$this->level->getChunkAtPosition($this)->setFullBlock($this->x & 0xf, $this->y, $this->z & 0xf, $this->getFullId());
|
||||
$this->world->getChunkAtPosition($this)->setFullBlock($this->x & 0xf, $this->y, $this->z & 0xf, $this->getFullId());
|
||||
|
||||
$tileType = $this->idInfo->getTileClass();
|
||||
$oldTile = $this->level->getTile($this);
|
||||
$oldTile = $this->world->getTile($this);
|
||||
if($oldTile !== null and ($tileType === null or !($oldTile instanceof $tileType))){
|
||||
$oldTile->close();
|
||||
$oldTile = null;
|
||||
}
|
||||
if($oldTile === null and $tileType !== null){
|
||||
$this->level->addTile(TileFactory::create($tileType, $this->level, $this->asVector3()));
|
||||
$this->world->addTile(TileFactory::create($tileType, $this->world, $this->asVector3()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
* @return bool
|
||||
*/
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
return $this->getLevel()->setBlock($blockReplace, $this);
|
||||
return $this->getWorld()->setBlock($blockReplace, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,10 +312,10 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
* @return bool
|
||||
*/
|
||||
public function onBreak(Item $item, ?Player $player = null) : bool{
|
||||
if(($t = $this->level->getTile($this)) !== null){
|
||||
if(($t = $this->world->getTile($this)) !== null){
|
||||
$t->onBlockDestroyed();
|
||||
}
|
||||
return $this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
return $this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
}
|
||||
|
||||
|
||||
@ -370,7 +370,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this block is updated by the delayed blockupdate scheduler in the level.
|
||||
* Called when this block is updated by the delayed blockupdate scheduler in the world.
|
||||
*/
|
||||
public function onScheduledUpdate() : void{
|
||||
|
||||
@ -494,18 +494,19 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param Level $level
|
||||
* @param World $world
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
*@internal
|
||||
*
|
||||
*/
|
||||
final public function position(Level $level, int $x, int $y, int $z) : void{
|
||||
final public function position(World $world, int $x, int $y, int $z) : void{
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
$this->level = $level;
|
||||
$this->world = $world;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -653,7 +654,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
*/
|
||||
public function getSide(int $side, int $step = 1){
|
||||
if($this->isValid()){
|
||||
return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
|
||||
return $this->getWorld()->getBlock(Vector3::getSide($side, $step));
|
||||
}
|
||||
|
||||
return BlockFactory::get(BlockLegacyIds::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
|
||||
@ -812,13 +813,13 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
|
||||
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
|
||||
if($this->isValid()){
|
||||
$this->level->getBlockMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
|
||||
$this->world->getBlockMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMetadata(string $metadataKey){
|
||||
if($this->isValid()){
|
||||
return $this->level->getBlockMetadata()->getMetadata($this, $metadataKey);
|
||||
return $this->world->getBlockMetadata()->getMetadata($this, $metadataKey);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -826,7 +827,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
|
||||
public function hasMetadata(string $metadataKey) : bool{
|
||||
if($this->isValid()){
|
||||
return $this->level->getBlockMetadata()->hasMetadata($this, $metadataKey);
|
||||
return $this->world->getBlockMetadata()->hasMetadata($this, $metadataKey);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -834,7 +835,7 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
|
||||
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{
|
||||
if($this->isValid()){
|
||||
$this->level->getBlockMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
|
||||
$this->world->getBlockMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\tile\Comparator;
|
||||
use function array_fill;
|
||||
use function array_filter;
|
||||
@ -645,7 +645,7 @@ class BlockFactory{
|
||||
}
|
||||
|
||||
if($pos !== null){
|
||||
$block->position($pos->getLevel(), $pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ());
|
||||
$block->position($pos->getWorld(), $pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ());
|
||||
}
|
||||
|
||||
return $block;
|
||||
|
@ -25,11 +25,11 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataValidator;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\sound\RedstonePowerOffSound;
|
||||
use pocketmine\level\sound\RedstonePowerOnSound;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\sound\RedstonePowerOffSound;
|
||||
use pocketmine\world\sound\RedstonePowerOnSound;
|
||||
|
||||
abstract class Button extends Flowable{
|
||||
|
||||
@ -63,9 +63,9 @@ abstract class Button extends Flowable{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->powered){
|
||||
$this->powered = true;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->scheduleDelayedBlockUpdate($this, $this->getActivationTime());
|
||||
$this->level->addSound($this->add(0.5, 0.5, 0.5), new RedstonePowerOnSound());
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->scheduleDelayedBlockUpdate($this, $this->getActivationTime());
|
||||
$this->world->addSound($this->add(0.5, 0.5, 0.5), new RedstonePowerOnSound());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -74,8 +74,8 @@ abstract class Button extends Flowable{
|
||||
public function onScheduledUpdate() : void{
|
||||
if($this->powered){
|
||||
$this->powered = false;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->addSound($this->add(0.5, 0.5, 0.5), new RedstonePowerOffSound());
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->addSound($this->add(0.5, 0.5, 0.5), new RedstonePowerOffSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ class Cactus extends Transparent{
|
||||
public function onNearbyBlockChange() : void{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() !== BlockLegacyIds::SAND and $down->getId() !== BlockLegacyIds::CACTUS){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}else{
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->isSolid()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -92,23 +92,23 @@ class Cactus extends Transparent{
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::CACTUS){
|
||||
if($this->age === 15){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||
if($b->getId() === BlockLegacyIds::AIR){
|
||||
$ev = new BlockGrowEvent($b, BlockFactory::get(BlockLegacyIds::CACTUS));
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
break;
|
||||
}
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($b, $ev->getNewState());
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->age = 0;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}else{
|
||||
++$this->age;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class Cake extends Transparent implements FoodSource{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){ //Replace with common break method
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,6 +125,6 @@ class Cake extends Transparent implements FoodSource{
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
$this->level->setBlock($this, $this->getResidue());
|
||||
$this->world->setBlock($this, $this->getResidue());
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class Carpet extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class Chest extends Transparent{
|
||||
}
|
||||
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileChest){
|
||||
foreach([
|
||||
Facing::rotateY($this->facing, true),
|
||||
@ -75,7 +75,7 @@ class Chest extends Transparent{
|
||||
] as $side){
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
||||
$pair = $this->level->getTile($c);
|
||||
$pair = $this->world->getTile($c);
|
||||
if($pair instanceof TileChest and !$pair->isPaired()){
|
||||
$pair->pairWith($tile);
|
||||
$tile->pairWith($pair);
|
||||
@ -94,7 +94,7 @@ class Chest extends Transparent{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player instanceof Player){
|
||||
|
||||
$chest = $this->getLevel()->getTile($this);
|
||||
$chest = $this->getWorld()->getTile($this);
|
||||
if($chest instanceof TileChest){
|
||||
if(
|
||||
!$this->getSide(Facing::UP)->isTransparent() or
|
||||
|
@ -34,7 +34,7 @@ class CoarseDirt extends Dirt{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::UP and $item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class CocoaBlock extends Transparent{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($this->age < 2 and $item instanceof Fertilizer){
|
||||
$this->age++;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
|
||||
$item->pop();
|
||||
|
||||
@ -101,7 +101,7 @@ class CocoaBlock extends Transparent{
|
||||
public function onNearbyBlockChange() : void{
|
||||
$side = $this->getSide(Facing::opposite($this->facing));
|
||||
if(!($side instanceof Wood) or $side->getTreeType() !== TreeType::JUNGLE()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ class CocoaBlock extends Transparent{
|
||||
public function onRandomTick() : void{
|
||||
if($this->age < 2 and mt_rand(1, 5) === 1){
|
||||
$this->age++;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class ConcretePowder extends Solid implements Fallable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(($block = $this->checkAdjacentWater()) !== null){
|
||||
$this->level->setBlock($this, $block);
|
||||
$this->world->setBlock($this, $block);
|
||||
}else{
|
||||
$this->startFalling();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ abstract class Crops extends Flowable{
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($this, $ev->getNewState());
|
||||
}
|
||||
|
||||
$item->pop();
|
||||
@ -81,7 +81,7 @@ abstract class Crops extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::FARMLAND){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ abstract class Crops extends Flowable{
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($this, $ev->getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class Dandelion extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ class DaylightSensor extends Transparent{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->inverted = !$this->inverted;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class DeadBush extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Dirt extends Solid{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::UP and $item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::FARMLAND));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::FARMLAND));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataValidator;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\BlockTransaction;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Bearing;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\DoorSound;
|
||||
|
||||
|
||||
abstract class Door extends Transparent{
|
||||
@ -99,7 +99,7 @@ abstract class Door extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){ //Replace with common break method
|
||||
$this->getLevel()->useBreakOn($this); //this will delete both halves if they exist
|
||||
$this->getWorld()->useBreakOn($this); //this will delete both halves if they exist
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ abstract class Door extends Transparent{
|
||||
$topHalf = clone $this;
|
||||
$topHalf->top = true;
|
||||
|
||||
$transaction = new BlockTransaction($this->level);
|
||||
$transaction = new BlockTransaction($this->world);
|
||||
$transaction->addBlock($blockReplace, $this)->addBlock($blockUp, $topHalf);
|
||||
|
||||
return $transaction->apply();
|
||||
@ -140,11 +140,11 @@ abstract class Door extends Transparent{
|
||||
$other = $this->getSide($this->top ? Facing::DOWN : Facing::UP);
|
||||
if($other instanceof Door and $other->isSameType($this)){
|
||||
$other->open = $this->open;
|
||||
$this->level->setBlock($other, $other);
|
||||
$this->world->setBlock($other, $other);
|
||||
}
|
||||
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->addSound($this, new DoorSound());
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->addSound($this, new DoorSound());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\BlockTransaction;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class DoublePlant extends Flowable{
|
||||
private const BITFLAG_TOP = 0x08;
|
||||
@ -53,7 +53,7 @@ class DoublePlant extends Flowable{
|
||||
$top = clone $this;
|
||||
$top->top = true;
|
||||
|
||||
$transaction = new BlockTransaction($this->level);
|
||||
$transaction = new BlockTransaction($this->world);
|
||||
$transaction->addBlock($blockReplace, $this)->addBlock($blockReplace->getSide(Facing::UP), $top);
|
||||
return $transaction->apply();
|
||||
}
|
||||
@ -77,7 +77,7 @@ class DoublePlant extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->isValidHalfPlant() or (!$this->top and $this->getSide(Facing::DOWN)->isTransparent())){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@ use pocketmine\block\utils\FallableTrait;
|
||||
use pocketmine\event\block\BlockTeleportEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\TieredTool;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\particle\DragonEggTeleportParticle;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\particle\DragonEggTeleportParticle;
|
||||
use pocketmine\world\World;
|
||||
use function max;
|
||||
use function min;
|
||||
use function mt_rand;
|
||||
@ -71,9 +71,9 @@ class DragonEgg extends Transparent implements Fallable{
|
||||
|
||||
protected function teleport() : void{
|
||||
for($tries = 0; $tries < 16; ++$tries){
|
||||
$block = $this->level->getBlockAt(
|
||||
$block = $this->world->getBlockAt(
|
||||
$this->x + mt_rand(-16, 16),
|
||||
max(0, min(Level::Y_MAX - 1, $this->y + mt_rand(-8, 8))),
|
||||
max(0, min(World::Y_MAX - 1, $this->y + mt_rand(-8, 8))),
|
||||
$this->z + mt_rand(-16, 16)
|
||||
);
|
||||
if($block instanceof Air){
|
||||
@ -84,9 +84,9 @@ class DragonEgg extends Transparent implements Fallable{
|
||||
}else{
|
||||
$block = $ev->getTo();
|
||||
}
|
||||
$this->level->addParticle($this, new DragonEggTeleportParticle($this->x - $block->x, $this->y - $block->y, $this->z - $block->z));
|
||||
$this->level->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$this->level->setBlock($block, $this);
|
||||
$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($block, $this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class EnderChest extends Transparent{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player instanceof Player){
|
||||
$enderChest = $this->getLevel()->getTile($this);
|
||||
$enderChest = $this->getWorld()->getTile($this);
|
||||
if($enderChest instanceof TileEnderChest and $this->getSide(Facing::UP)->isTransparent()){
|
||||
$player->getEnderChestInventory()->setHolderPosition($enderChest);
|
||||
$player->addWindow($player->getEnderChestInventory());
|
||||
|
@ -60,7 +60,7 @@ class Farmland extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::UP)->isSolid()){
|
||||
$this->level->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,13 +72,13 @@ class Farmland extends Transparent{
|
||||
if(!$this->canHydrate()){
|
||||
if($this->wetness > 0){
|
||||
$this->wetness--;
|
||||
$this->level->setBlock($this, $this, false);
|
||||
$this->world->setBlock($this, $this, false);
|
||||
}else{
|
||||
$this->level->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
}
|
||||
}elseif($this->wetness < 7){
|
||||
$this->wetness = 7;
|
||||
$this->level->setBlock($this, $this, false);
|
||||
$this->world->setBlock($this, $this, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ class Farmland extends Transparent{
|
||||
for($y = $start->y; $y <= $end->y; ++$y){
|
||||
for($z = $start->z; $z <= $end->z; ++$z){
|
||||
for($x = $start->x; $x <= $end->x; ++$x){
|
||||
if($this->level->getBlockAt($x, $y, $z) instanceof Water){
|
||||
if($this->world->getBlockAt($x, $y, $z) instanceof Water){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,12 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataValidator;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Bearing;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\sound\DoorSound;
|
||||
|
||||
class FenceGate extends Transparent{
|
||||
/** @var bool */
|
||||
@ -92,7 +92,7 @@ class FenceGate extends Transparent{
|
||||
$inWall = $this->checkInWall();
|
||||
if($inWall !== $this->inWall){
|
||||
$this->inWall = $inWall;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,8 +105,8 @@ class FenceGate extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->level->addSound($this, new DoorSound());
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
$this->world->addSound($this, new DoorSound());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,9 @@ class Fire extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->getSide(Facing::DOWN)->isSolid() and !$this->hasAdjacentFlammableBlocks()){
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
}else{
|
||||
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,10 +124,10 @@ class Fire extends Flowable{
|
||||
}
|
||||
|
||||
if($result !== null){
|
||||
$this->level->setBlock($this, $result);
|
||||
$this->world->setBlock($this, $result);
|
||||
}
|
||||
|
||||
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(30, 40));
|
||||
|
||||
if($canSpread){
|
||||
//TODO: raise upper bound for chance in humid biomes
|
||||
@ -168,9 +168,9 @@ class Fire extends Flowable{
|
||||
if(mt_rand(0, $this->age + 9) < 5){ //TODO: check rain
|
||||
$fire = clone $this;
|
||||
$fire->age = min(15, $fire->age + (mt_rand(0, 4) >> 2));
|
||||
$this->level->setBlock($block, $fire);
|
||||
$this->world->setBlock($block, $fire);
|
||||
}else{
|
||||
$this->level->setBlock($block, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$this->world->setBlock($block, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class Flower extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class FlowerPot extends Flowable{
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileFlowerPot){
|
||||
$this->setPlant($tile->getPlant());
|
||||
}else{
|
||||
@ -67,7 +67,7 @@ class FlowerPot extends Flowable{
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
assert($tile instanceof TileFlowerPot);
|
||||
$tile->setPlant($this->plant);
|
||||
}
|
||||
@ -121,7 +121,7 @@ class FlowerPot extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ class FlowerPot extends Flowable{
|
||||
|
||||
$this->setPlant($plant);
|
||||
$item->pop();
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -50,17 +50,17 @@ class FrostedIce extends Ice{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->checkAdjacentBlocks(2)){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}else{
|
||||
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
}
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if((!$this->checkAdjacentBlocks(4) or mt_rand(0, 2) === 0) and
|
||||
max( //TODO: move this to Level
|
||||
$this->level->getHighestAdjacentBlockLight($this->x, $this->y, $this->z),
|
||||
$this->level->getHighestAdjacentBlockSkyLight($this->x, $this->y, $this->z) - $this->level->getSkyLightReduction()
|
||||
max( //TODO: move this to World
|
||||
$this->world->getHighestAdjacentBlockLight($this->x, $this->y, $this->z),
|
||||
$this->world->getHighestAdjacentBlockSkyLight($this->x, $this->y, $this->z) - $this->world->getSkyLightReduction()
|
||||
) >= 12 - $this->age){
|
||||
if($this->tryMelt()){
|
||||
foreach($this->getAllSides() as $block){
|
||||
@ -70,7 +70,7 @@ class FrostedIce extends Ice{
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class FrostedIce extends Ice{
|
||||
continue;
|
||||
}
|
||||
if(
|
||||
$this->level->getBlockAt($this->x + $x, $this->y, $this->z + $z) instanceof FrostedIce and
|
||||
$this->world->getBlockAt($this->x + $x, $this->y, $this->z + $z) instanceof FrostedIce and
|
||||
++$found >= $requirement
|
||||
){
|
||||
return true;
|
||||
@ -103,13 +103,13 @@ class FrostedIce extends Ice{
|
||||
*/
|
||||
private function tryMelt() : bool{
|
||||
if($this->age >= 3){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->age++;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->scheduleDelayedBlockUpdate($this, mt_rand(20, 40));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class Furnace extends Solid{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player instanceof Player){
|
||||
$furnace = $this->getLevel()->getTile($this);
|
||||
$furnace = $this->getWorld()->getTile($this);
|
||||
if($furnace instanceof TileFurnace and $furnace->canOpenWith($item->getCustomName())){
|
||||
$player->addWindow($furnace->getInventory());
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ use pocketmine\item\Hoe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\Shovel;
|
||||
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\world\generator\object\TallGrass as TallGrassObject;
|
||||
use function mt_rand;
|
||||
|
||||
class Grass extends Solid{
|
||||
@ -57,13 +57,13 @@ class Grass extends Solid{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
$lightAbove = $this->level->getFullLightAt($this->x, $this->y + 1, $this->z);
|
||||
if($lightAbove < 4 and $this->level->getBlockAt($this->x, $this->y + 1, $this->z)->getLightFilter() >= 2){
|
||||
$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){
|
||||
//grass dies
|
||||
$ev = new BlockSpreadEvent($this, $this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->level->setBlock($this, $ev->getNewState(), false);
|
||||
$this->world->setBlock($this, $ev->getNewState(), false);
|
||||
}
|
||||
}elseif($lightAbove >= 9){
|
||||
//try grass spread
|
||||
@ -72,12 +72,12 @@ class Grass extends Solid{
|
||||
$y = mt_rand($this->y - 3, $this->y + 1);
|
||||
$z = mt_rand($this->z - 1, $this->z + 1);
|
||||
|
||||
$b = $this->level->getBlockAt($x, $y, $z);
|
||||
$b = $this->world->getBlockAt($x, $y, $z);
|
||||
if(
|
||||
!($b instanceof Dirt) or
|
||||
$b instanceof CoarseDirt or
|
||||
$this->level->getFullLightAt($x, $y + 1, $z) < 4 or
|
||||
$this->level->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||
$this->world->getFullLightAt($x, $y + 1, $z) < 4 or
|
||||
$this->world->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||
){
|
||||
continue;
|
||||
}
|
||||
@ -85,7 +85,7 @@ class Grass extends Solid{
|
||||
$ev = new BlockSpreadEvent($b, $this, BlockFactory::get(BlockLegacyIds::GRASS));
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->level->setBlock($b, $ev->getNewState(), false);
|
||||
$this->world->setBlock($b, $ev->getNewState(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,17 +97,17 @@ class Grass extends Solid{
|
||||
}
|
||||
if($item instanceof Fertilizer){
|
||||
$item->pop();
|
||||
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
|
||||
TallGrassObject::growGrass($this->getWorld(), $this, new Random(mt_rand()), 8, 2);
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::FARMLAND));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::FARMLAND));
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Shovel and $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){
|
||||
$item->applyDamage(1);
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::GRASS_PATH));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::GRASS_PATH));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class GrassPath extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::UP)->isSolid()){
|
||||
$this->level->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::DIRT));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class Ice extends Transparent{
|
||||
|
||||
public function onBreak(Item $item, ?Player $player = null) : bool{
|
||||
if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH())){
|
||||
return $this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::WATER));
|
||||
return $this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::WATER));
|
||||
}
|
||||
return parent::onBreak($item, $player);
|
||||
}
|
||||
@ -57,8 +57,8 @@ class Ice extends Transparent{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if($this->level->getHighestAdjacentBlockLight($this->x, $this->y, $this->z) >= 12){
|
||||
$this->level->useBreakOn($this);
|
||||
if($this->world->getHighestAdjacentBlockLight($this->x, $this->y, $this->z) >= 12){
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class ItemFrame extends Flowable{
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileItemFrame){
|
||||
$this->framedItem = $tile->getItem();
|
||||
if($this->framedItem->isNull()){
|
||||
@ -69,7 +69,7 @@ class ItemFrame extends Flowable{
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileItemFrame){
|
||||
$tile->setItem($this->framedItem);
|
||||
$tile->setItemRotation($this->itemRotation);
|
||||
@ -151,7 +151,7 @@ class ItemFrame extends Flowable{
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -161,16 +161,16 @@ class ItemFrame extends Flowable{
|
||||
return false;
|
||||
}
|
||||
if(lcg_value() <= $this->itemDropChance){
|
||||
$this->level->dropItem($this->add(0.5, 0.5, 0.5), $this->getFramedItem());
|
||||
$this->world->dropItem($this->add(0.5, 0.5, 0.5), $this->getFramedItem());
|
||||
}
|
||||
$this->setFramedItem(null);
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->getSide(Facing::opposite($this->facing))->isSolid()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class Ladder extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->getSide(Facing::opposite($this->facing))->isSolid()){ //Replace with common break method
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,9 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\level\sound\BucketEmptyLavaSound;
|
||||
use pocketmine\level\sound\BucketFillLavaSound;
|
||||
use pocketmine\level\sound\Sound;
|
||||
use pocketmine\world\sound\BucketEmptyLavaSound;
|
||||
use pocketmine\world\sound\BucketFillLavaSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class Lava extends Liquid{
|
||||
|
@ -27,10 +27,10 @@ use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\event\block\LeavesDecayEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\World;
|
||||
use function mt_rand;
|
||||
|
||||
class Leaves extends Transparent{
|
||||
@ -74,7 +74,7 @@ class Leaves extends Transparent{
|
||||
|
||||
|
||||
protected function findLog(Block $pos, array &$visited = [], int $distance = 0) : bool{
|
||||
$index = Level::blockHash($pos->x, $pos->y, $pos->z);
|
||||
$index = World::blockHash($pos->x, $pos->y, $pos->z);
|
||||
if(isset($visited[$index])){
|
||||
return false;
|
||||
}
|
||||
@ -98,7 +98,7 @@ class Leaves extends Transparent{
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->noDecay and !$this->checkDecay){
|
||||
$this->checkDecay = true;
|
||||
$this->getLevel()->setBlock($this, $this, false);
|
||||
$this->getWorld()->setBlock($this, $this, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,9 +112,9 @@ class Leaves extends Transparent{
|
||||
$ev->call();
|
||||
if($ev->isCancelled() or $this->findLog($this)){
|
||||
$this->checkDecay = false;
|
||||
$this->getLevel()->setBlock($this, $this, false);
|
||||
$this->getWorld()->setBlock($this, $this, false);
|
||||
}else{
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataValidator;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\sound\RedstonePowerOffSound;
|
||||
use pocketmine\level\sound\RedstonePowerOnSound;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\sound\RedstonePowerOffSound;
|
||||
use pocketmine\world\sound\RedstonePowerOnSound;
|
||||
|
||||
class Lever extends Flowable{
|
||||
protected const BOTTOM = 0;
|
||||
@ -106,14 +106,14 @@ class Lever extends Flowable{
|
||||
}
|
||||
|
||||
if(!$this->getSide($face)->isSolid()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->powered = !$this->powered;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->addSound(
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->addSound(
|
||||
$this->add(0.5, 0.5, 0.5),
|
||||
$this->powered ? new RedstonePowerOnSound() : new RedstonePowerOffSound()
|
||||
);
|
||||
|
@ -28,11 +28,11 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockFormEvent;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\sound\FizzSound;
|
||||
use pocketmine\level\sound\Sound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\world\sound\FizzSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
use pocketmine\world\World;
|
||||
use function array_fill;
|
||||
use function lcg_value;
|
||||
use function min;
|
||||
@ -189,7 +189,7 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$sideBlock = $this->level->getBlockAt($x, $y, $z);
|
||||
$sideBlock = $this->world->getBlockAt($x, $y, $z);
|
||||
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
|
||||
|
||||
if($blockDecay < 0){
|
||||
@ -197,7 +197,7 @@ abstract class Liquid extends Transparent{
|
||||
continue;
|
||||
}
|
||||
|
||||
$blockDecay = $this->getEffectiveFlowDecay($this->level->getBlockAt($x, $y - 1, $z));
|
||||
$blockDecay = $this->getEffectiveFlowDecay($this->world->getBlockAt($x, $y - 1, $z));
|
||||
|
||||
if($blockDecay >= 0){
|
||||
$realDecay = $blockDecay - ($decay - 8);
|
||||
@ -217,14 +217,14 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
if($this->falling){
|
||||
if(
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x, $this->y, $this->z - 1)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x, $this->y, $this->z + 1)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x - 1, $this->y, $this->z)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x + 1, $this->y, $this->z)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x, $this->y + 1, $this->z - 1)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x, $this->y + 1, $this->z + 1)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x - 1, $this->y + 1, $this->z)) or
|
||||
!$this->canFlowInto($this->level->getBlockAt($this->x + 1, $this->y + 1, $this->z))
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x, $this->y, $this->z - 1)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x, $this->y, $this->z + 1)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x - 1, $this->y, $this->z)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x + 1, $this->y, $this->z)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x, $this->y + 1, $this->z - 1)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x, $this->y + 1, $this->z + 1)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x - 1, $this->y + 1, $this->z)) or
|
||||
!$this->canFlowInto($this->world->getBlockAt($this->x + 1, $this->y + 1, $this->z))
|
||||
){
|
||||
$vector = $vector->normalize()->add(0, -6, 0);
|
||||
}
|
||||
@ -255,7 +255,7 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$this->checkForHarden();
|
||||
$this->level->scheduleDelayedBlockUpdate($this, $this->tickRate());
|
||||
$this->world->scheduleDelayedBlockUpdate($this, $this->tickRate());
|
||||
}
|
||||
|
||||
public function onScheduledUpdate() : void{
|
||||
@ -264,10 +264,10 @@ abstract class Liquid extends Transparent{
|
||||
if(!$this->isSource()){
|
||||
$smallestFlowDecay = -100;
|
||||
$this->adjacentSources = 0;
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlockAt($this->x, $this->y, $this->z - 1), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlockAt($this->x, $this->y, $this->z + 1), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlockAt($this->x - 1, $this->y, $this->z), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->level->getBlockAt($this->x + 1, $this->y, $this->z), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->world->getBlockAt($this->x, $this->y, $this->z - 1), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->world->getBlockAt($this->x, $this->y, $this->z + 1), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->world->getBlockAt($this->x - 1, $this->y, $this->z), $smallestFlowDecay);
|
||||
$smallestFlowDecay = $this->getSmallestFlowDecay($this->world->getBlockAt($this->x + 1, $this->y, $this->z), $smallestFlowDecay);
|
||||
|
||||
$newDecay = $smallestFlowDecay + $multiplier;
|
||||
$falling = false;
|
||||
@ -276,12 +276,12 @@ abstract class Liquid extends Transparent{
|
||||
$newDecay = -1;
|
||||
}
|
||||
|
||||
if($this->getEffectiveFlowDecay($this->level->getBlockAt($this->x, $this->y + 1, $this->z)) >= 0){
|
||||
if($this->getEffectiveFlowDecay($this->world->getBlockAt($this->x, $this->y + 1, $this->z)) >= 0){
|
||||
$falling = true;
|
||||
}
|
||||
|
||||
if($this->adjacentSources >= 2 and $this instanceof Water){
|
||||
$bottomBlock = $this->level->getBlockAt($this->x, $this->y - 1, $this->z);
|
||||
$bottomBlock = $this->world->getBlockAt($this->x, $this->y - 1, $this->z);
|
||||
if($bottomBlock->isSolid() or ($bottomBlock instanceof Water and $bottomBlock->isSource())){
|
||||
$newDecay = 0;
|
||||
$falling = false;
|
||||
@ -290,17 +290,17 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
if($falling !== $this->falling or (!$falling and $newDecay !== $this->decay)){
|
||||
if(!$falling and $newDecay < 0){
|
||||
$this->level->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$this->world->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->falling = $falling;
|
||||
$this->decay = $falling ? 0 : $newDecay;
|
||||
$this->level->setBlock($this, $this); //local block update will cause an update to be scheduled
|
||||
$this->world->setBlock($this, $this); //local block update will cause an update to be scheduled
|
||||
}
|
||||
}
|
||||
|
||||
$bottomBlock = $this->level->getBlockAt($this->x, $this->y - 1, $this->z);
|
||||
$bottomBlock = $this->world->getBlockAt($this->x, $this->y - 1, $this->z);
|
||||
|
||||
$this->flowIntoBlock($bottomBlock, 0, true);
|
||||
|
||||
@ -315,19 +315,19 @@ abstract class Liquid extends Transparent{
|
||||
$flags = $this->getOptimalFlowDirections();
|
||||
|
||||
if($flags[0]){
|
||||
$this->flowIntoBlock($this->level->getBlockAt($this->x - 1, $this->y, $this->z), $adjacentDecay, false);
|
||||
$this->flowIntoBlock($this->world->getBlockAt($this->x - 1, $this->y, $this->z), $adjacentDecay, false);
|
||||
}
|
||||
|
||||
if($flags[1]){
|
||||
$this->flowIntoBlock($this->level->getBlockAt($this->x + 1, $this->y, $this->z), $adjacentDecay, false);
|
||||
$this->flowIntoBlock($this->world->getBlockAt($this->x + 1, $this->y, $this->z), $adjacentDecay, false);
|
||||
}
|
||||
|
||||
if($flags[2]){
|
||||
$this->flowIntoBlock($this->level->getBlockAt($this->x, $this->y, $this->z - 1), $adjacentDecay, false);
|
||||
$this->flowIntoBlock($this->world->getBlockAt($this->x, $this->y, $this->z - 1), $adjacentDecay, false);
|
||||
}
|
||||
|
||||
if($flags[3]){
|
||||
$this->flowIntoBlock($this->level->getBlockAt($this->x, $this->y, $this->z + 1), $adjacentDecay, false);
|
||||
$this->flowIntoBlock($this->world->getBlockAt($this->x, $this->y, $this->z + 1), $adjacentDecay, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,10 +345,10 @@ abstract class Liquid extends Transparent{
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
if($block->getId() > 0){
|
||||
$this->level->useBreakOn($block);
|
||||
$this->world->useBreakOn($block);
|
||||
}
|
||||
|
||||
$this->level->setBlock($block, $ev->getNewState());
|
||||
$this->world->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,11 +375,11 @@ abstract class Liquid extends Transparent{
|
||||
++$z;
|
||||
}
|
||||
|
||||
if(!isset($this->flowCostVisited[$hash = Level::blockHash($x, $y, $z)])){
|
||||
$blockSide = $this->level->getBlockAt($x, $y, $z);
|
||||
if(!isset($this->flowCostVisited[$hash = World::blockHash($x, $y, $z)])){
|
||||
$blockSide = $this->world->getBlockAt($x, $y, $z);
|
||||
if(!$this->canFlowInto($blockSide)){
|
||||
$this->flowCostVisited[$hash] = self::BLOCKED;
|
||||
}elseif($this->level->getBlockAt($x, $y - 1, $z)->canBeFlowedInto()){
|
||||
}elseif($this->world->getBlockAt($x, $y - 1, $z)->canBeFlowedInto()){
|
||||
$this->flowCostVisited[$hash] = self::CAN_FLOW_DOWN;
|
||||
}else{
|
||||
$this->flowCostVisited[$hash] = self::CAN_FLOW;
|
||||
@ -428,16 +428,16 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$block = $this->level->getBlockAt($x, $y, $z);
|
||||
$block = $this->world->getBlockAt($x, $y, $z);
|
||||
|
||||
if(!$this->canFlowInto($block)){
|
||||
$this->flowCostVisited[Level::blockHash($x, $y, $z)] = self::BLOCKED;
|
||||
$this->flowCostVisited[World::blockHash($x, $y, $z)] = self::BLOCKED;
|
||||
continue;
|
||||
}elseif($this->level->getBlockAt($x, $y - 1, $z)->canBeFlowedInto()){
|
||||
$this->flowCostVisited[Level::blockHash($x, $y, $z)] = self::CAN_FLOW_DOWN;
|
||||
}elseif($this->world->getBlockAt($x, $y - 1, $z)->canBeFlowedInto()){
|
||||
$this->flowCostVisited[World::blockHash($x, $y, $z)] = self::CAN_FLOW_DOWN;
|
||||
$flowCost[$j] = $maxCost = 0;
|
||||
}elseif($maxCost > 0){
|
||||
$this->flowCostVisited[Level::blockHash($x, $y, $z)] = self::CAN_FLOW;
|
||||
$this->flowCostVisited[World::blockHash($x, $y, $z)] = self::CAN_FLOW;
|
||||
$flowCost[$j] = $this->calculateFlowCost($x, $y, $z, 1, $maxCost, $j ^ 0x01, $j ^ 0x01);
|
||||
$maxCost = min($maxCost, $flowCost[$j]);
|
||||
}
|
||||
@ -480,13 +480,13 @@ abstract class Liquid extends Transparent{
|
||||
$ev = new BlockFormEvent($this, $result);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->level->setBlock($this, $ev->getNewState());
|
||||
$this->level->addSound($this->add(0.5, 0.5, 0.5), new FizzSound(2.6 + (lcg_value() - lcg_value()) * 0.8));
|
||||
$this->world->setBlock($this, $ev->getNewState());
|
||||
$this->world->addSound($this->add(0.5, 0.5, 0.5), new FizzSound(2.6 + (lcg_value() - lcg_value()) * 0.8));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function canFlowInto(Block $block) : bool{
|
||||
return $this->level->isInWorld($block->x, $block->y, $block->z) and $block->canBeFlowedInto() and !($block instanceof Liquid and $block->isSource()); //TODO: I think this should only be liquids of the same type
|
||||
return $this->world->isInWorld($block->x, $block->y, $block->z) and $block->canBeFlowedInto() and !($block instanceof Liquid and $block->isSource()); //TODO: I think this should only be liquids of the same type
|
||||
}
|
||||
}
|
||||
|
@ -54,13 +54,13 @@ class Mycelium extends Solid{
|
||||
$x = mt_rand($this->x - 1, $this->x + 1);
|
||||
$y = mt_rand($this->y - 2, $this->y + 2);
|
||||
$z = mt_rand($this->z - 1, $this->z + 1);
|
||||
$block = $this->getLevel()->getBlockAt($x, $y, $z);
|
||||
$block = $this->getWorld()->getBlockAt($x, $y, $z);
|
||||
if($block->getId() === BlockLegacyIds::DIRT){
|
||||
if($block->getSide(Facing::UP) instanceof Transparent){
|
||||
$ev = new BlockSpreadEvent($block, $this, BlockFactory::get(BlockLegacyIds::MYCELIUM));
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class NetherWartPlant extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SOUL_SAND){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ class NetherWartPlant extends Flowable{
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($this, $ev->getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class RedMushroom extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class RedstoneComparator extends Flowable{
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof Comparator){
|
||||
$this->signalStrength = $tile->getSignalStrength();
|
||||
}
|
||||
@ -78,7 +78,7 @@ class RedstoneComparator extends Flowable{
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
assert($tile instanceof Comparator);
|
||||
$tile->setSignalStrength($this->signalStrength);
|
||||
}
|
||||
@ -158,13 +158,13 @@ class RedstoneComparator extends Flowable{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->isSubtractMode = !$this->isSubtractMode;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,13 +72,13 @@ class RedstoneOre extends Solid{
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
return $this->getLevel()->setBlock($this, $this, false);
|
||||
return $this->getWorld()->setBlock($this, $this, false);
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->lit){
|
||||
$this->lit = true;
|
||||
$this->getLevel()->setBlock($this, $this); //no return here - this shouldn't prevent block placement
|
||||
$this->getWorld()->setBlock($this, $this); //no return here - this shouldn't prevent block placement
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -86,7 +86,7 @@ class RedstoneOre extends Solid{
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->lit){
|
||||
$this->lit = true;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ class RedstoneOre extends Solid{
|
||||
public function onRandomTick() : void{
|
||||
if($this->lit){
|
||||
$this->lit = false;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,13 +98,13 @@ class RedstoneRepeater extends Flowable{
|
||||
if(++$this->delay > 4){
|
||||
$this->delay = 1;
|
||||
}
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,11 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\generator\object\Tree;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\world\generator\object\Tree;
|
||||
use function mt_rand;
|
||||
|
||||
class Sapling extends Flowable{
|
||||
@ -68,7 +68,7 @@ class Sapling extends Flowable{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($item instanceof Fertilizer){
|
||||
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->treeType);
|
||||
Tree::growTree($this->getWorld(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->treeType);
|
||||
|
||||
$item->pop();
|
||||
|
||||
@ -80,7 +80,7 @@ class Sapling extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,12 +89,12 @@ class Sapling extends Flowable{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if($this->level->getFullLightAt($this->x, $this->y, $this->z) >= 8 and mt_rand(1, 7) === 1){
|
||||
if($this->world->getFullLightAt($this->x, $this->y, $this->z) >= 8 and mt_rand(1, 7) === 1){
|
||||
if($this->ready){
|
||||
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->treeType);
|
||||
Tree::growTree($this->getWorld(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->treeType);
|
||||
}else{
|
||||
$this->ready = true;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class Sign extends Transparent{
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileSign){
|
||||
$this->text = $tile->getText();
|
||||
}
|
||||
@ -92,7 +92,7 @@ class Sign extends Transparent{
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
assert($tile instanceof TileSign);
|
||||
$tile->setText($this->text);
|
||||
}
|
||||
@ -128,7 +128,7 @@ class Sign extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::opposite($this->facing))->getId() === BlockLegacyIds::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ class Sign extends Transparent{
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->text = clone $ev->getNewText();
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class Skull extends Flowable{
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileSkull){
|
||||
$this->skullType = $tile->getSkullType();
|
||||
$this->rotation = $tile->getRotation();
|
||||
@ -75,7 +75,7 @@ class Skull extends Flowable{
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
//extra block properties storage hack
|
||||
$tile = $this->level->getTile($this);
|
||||
$tile = $this->world->getTile($this);
|
||||
assert($tile instanceof TileSkull);
|
||||
$tile->setRotation($this->rotation);
|
||||
$tile->setSkullType($this->skullType);
|
||||
|
@ -95,8 +95,8 @@ class SnowLayer extends Flowable implements Fallable{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
if($this->level->getBlockLightAt($this->x, $this->y, $this->z) >= 12){
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR), false);
|
||||
if($this->world->getBlockLightAt($this->x, $this->y, $this->z) >= 12){
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ abstract class Stem extends Crops{
|
||||
$ev = new BlockGrowEvent($this, $block);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($this, $ev->getNewState());
|
||||
}
|
||||
}else{
|
||||
$grow = $this->getPlant();
|
||||
@ -57,7 +57,7 @@ abstract class Stem extends Crops{
|
||||
$ev = new BlockGrowEvent($side, $grow);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($side, $ev->getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,20 +52,20 @@ class Sugarcane extends Flowable{
|
||||
if($item instanceof Fertilizer){
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SUGARCANE_BLOCK){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||
if($b->getId() === BlockLegacyIds::AIR){
|
||||
$ev = new BlockGrowEvent($b, BlockFactory::get(BlockLegacyIds::SUGARCANE_BLOCK));
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
break;
|
||||
}
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState());
|
||||
$this->getWorld()->setBlock($b, $ev->getNewState());
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->age = 0;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}
|
||||
|
||||
$item->pop();
|
||||
@ -79,7 +79,7 @@ class Sugarcane extends Flowable{
|
||||
public function onNearbyBlockChange() : void{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->isTransparent() and $down->getId() !== BlockLegacyIds::SUGARCANE_BLOCK){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,17 +91,17 @@ class Sugarcane extends Flowable{
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SUGARCANE_BLOCK){
|
||||
if($this->age === 15){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||
if($b->getId() === BlockLegacyIds::AIR){
|
||||
$this->getLevel()->setBlock($b, BlockFactory::get(BlockLegacyIds::SUGARCANE_BLOCK));
|
||||
$this->getWorld()->setBlock($b, BlockFactory::get(BlockLegacyIds::SUGARCANE_BLOCK));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->age = 0;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}else{
|
||||
++$this->age;
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->getWorld()->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,14 +90,14 @@ class TNT extends Solid{
|
||||
}
|
||||
|
||||
public function ignite(int $fuse = 80) : void{
|
||||
$this->getLevel()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$this->getWorld()->setBlock($this, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
|
||||
$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->setShort("Fuse", $fuse);
|
||||
|
||||
/** @var PrimedTNT $tnt */
|
||||
$tnt = EntityFactory::create(PrimedTNT::class, $this->getLevel(), $nbt);
|
||||
$tnt = EntityFactory::create(PrimedTNT::class, $this->getWorld(), $nbt);
|
||||
$tnt->spawnToAll();
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class TallGrass extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent()){ //Replace with common break method
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Torch extends Flowable{
|
||||
$face = Facing::opposite($this->facing);
|
||||
|
||||
if($this->getSide($face)->isTransparent() and !($face === Facing::DOWN and ($below->getId() === BlockLegacyIds::FENCE or $below->getId() === BlockLegacyIds::COBBLESTONE_WALL))){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataValidator;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\world\sound\DoorSound;
|
||||
|
||||
class Trapdoor extends Transparent{
|
||||
private const MASK_UPPER = 0x04;
|
||||
@ -79,8 +79,8 @@ class Trapdoor extends Transparent{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->open = !$this->open;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->addSound($this, new DoorSound());
|
||||
$this->world->setBlock($this, $this);
|
||||
$this->world->addSound($this, new DoorSound());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -170,9 +170,9 @@ class Vine extends Flowable{
|
||||
|
||||
if($changed){
|
||||
if(empty($this->faces)){
|
||||
$this->level->useBreakOn($this);
|
||||
$this->world->useBreakOn($this);
|
||||
}else{
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->world->setBlock($this, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\level\sound\BucketEmptyWaterSound;
|
||||
use pocketmine\level\sound\BucketFillWaterSound;
|
||||
use pocketmine\level\sound\Sound;
|
||||
use pocketmine\world\sound\BucketEmptyWaterSound;
|
||||
use pocketmine\world\sound\BucketFillWaterSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
|
||||
class Water extends Liquid{
|
||||
|
||||
|
@ -52,7 +52,7 @@ class WaterLily extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!($this->getSide(Facing::DOWN) instanceof Water)){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
$this->getWorld()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ use pocketmine\block\Fire;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\object\FallingBlock;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
/**
|
||||
* This trait handles falling behaviour for blocks that need them.
|
||||
@ -47,16 +47,16 @@ trait FallableTrait{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$pos = $this->asPosition();
|
||||
$down = $pos->level->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){
|
||||
$pos->level->setBlock($pos, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
$pos->world->setBlock($pos, BlockFactory::get(BlockLegacyIds::AIR));
|
||||
|
||||
$nbt = EntityFactory::createBaseNBT($pos->add(0.5, 0, 0.5));
|
||||
$nbt->setInt("TileID", $this->getId());
|
||||
$nbt->setByte("Data", $this->getMeta());
|
||||
|
||||
/** @var FallingBlock $fall */
|
||||
$fall = EntityFactory::create(FallingBlock::class, $pos->getLevel(), $nbt);
|
||||
$fall = EntityFactory::create(FallingBlock::class, $pos->getWorld(), $nbt);
|
||||
$fall->spawnToAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user