Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor
2022-03-22 15:49:58 +00:00
31 changed files with 765 additions and 363 deletions

View File

@ -100,7 +100,7 @@ class Fire extends Flowable{
}
public function onNearbyBlockChange() : void{
if(!$this->getSide(Facing::DOWN)->isSolid() && !$this->hasAdjacentFlammableBlocks()){
if($this->getSide(Facing::DOWN)->isTransparent() && !$this->hasAdjacentFlammableBlocks()){
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR());
}else{
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(30, 40));
@ -130,7 +130,7 @@ class Fire extends Flowable{
}
}elseif(!$this->hasAdjacentFlammableBlocks()){
$canSpread = false;
if(!$down->isSolid() || $this->age > 3){
if($down->isTransparent() || $this->age > 3){
$result = VanillaBlocks::AIR();
}
}
@ -181,14 +181,16 @@ class Fire extends Flowable{
if(!$ev->isCancelled()){
$block->onIncinerate();
$spreadedFire = false;
if(mt_rand(0, $this->age + 9) < 5){ //TODO: check rain
$fire = clone $this;
$fire->age = min(self::MAX_AGE, $fire->age + (mt_rand(0, 4) >> 2));
$spreadedFire = $this->spreadBlock($block, $fire);
}
if(!$spreadedFire){
$this->position->getWorld()->setBlock($block->position, VanillaBlocks::AIR());
if($this->position->getWorld()->getBlock($block->getPosition())->isSameState($block)){
$spreadedFire = false;
if(mt_rand(0, $this->age + 9) < 5){ //TODO: check rain
$fire = clone $this;
$fire->age = min(self::MAX_AGE, $fire->age + (mt_rand(0, 4) >> 2));
$spreadedFire = $this->spreadBlock($block, $fire);
}
if(!$spreadedFire){
$this->position->getWorld()->setBlock($block->position, VanillaBlocks::AIR());
}
}
}
}

View File

@ -31,6 +31,8 @@ use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
use function is_infinite;
use function is_nan;
use function lcg_value;
class ItemFrame extends Flowable{
@ -111,6 +113,9 @@ class ItemFrame extends Flowable{
/** @return $this */
public function setItemDropChance(float $itemDropChance) : self{
if($itemDropChance < 0.0 || $itemDropChance > 1.0 || is_nan($itemDropChance) || is_infinite($itemDropChance)){
throw new \InvalidArgumentException("Drop chance must be in range 0-1");
}
$this->itemDropChance = $itemDropChance;
return $this;
}

View File

@ -50,7 +50,7 @@ class Mycelium extends Opaque{
$y = mt_rand($this->position->y - 2, $this->position->y + 2);
$z = mt_rand($this->position->z - 1, $this->position->z + 1);
$block = $this->position->getWorld()->getBlockAt($x, $y, $z);
if($block->getId() === BlockLegacyIds::DIRT){
if($block instanceof Dirt && !$block->isCoarse()){
if($block->getSide(Facing::UP) instanceof Transparent){
$ev = new BlockSpreadEvent($block, $this, VanillaBlocks::MYCELIUM());
$ev->call();

View File

@ -91,7 +91,7 @@ class ShulkerBox extends Opaque{
$shulker = $this->position->getWorld()->getTile($this->position);
if($shulker instanceof TileShulkerBox){
if(
$this->getSide($this->facing)->getId() !== BlockLegacyIds::AIR ||
$this->getSide($this->facing)->isSolid() ||
!$shulker->canOpenWith($item->getCustomName())
){
return true;

View File

@ -151,9 +151,11 @@ class SweetBerryBush extends Flowable{
}
public function onEntityInside(Entity $entity) : bool{
//TODO: in MCPE, this only triggers if moving while inside the bush block - we don't have the system to deal
//with that reliably right now
if($this->age >= self::STAGE_BUSH_NO_BERRIES && $entity instanceof Living){
$entity->resetFallDistance();
//TODO: in MCPE, this only triggers if moving while inside the bush block - we don't have the system to deal
//with that reliably right now
$entity->attack(new EntityDamageByBlockEvent($this, $entity, EntityDamageByBlockEvent::CAUSE_CONTACT, 1));
}
return true;