code style fix

This commit is contained in:
Sunch 2025-04-27 20:36:24 +08:00
parent fc5c5625cb
commit 5e8e9330e2
361 changed files with 4766 additions and 4650 deletions

View file

@ -7,22 +7,22 @@ class LeavesBlock extends TransparentBlock{
const BIRCH = 2;
public function __construct($meta = 0){
parent::__construct(LEAVES, $meta, "Leaves");
$names = array(
$names = [
LeavesBlock::OAK => "Oak Leaves",
LeavesBlock::SPRUCE => "Spruce Leaves",
LeavesBlock::BIRCH => "Birch Leaves",
3 => "",
);
];
$this->name = $names[$this->meta & 0x03];
$this->hardness = 1;
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
}
public static function createIndex($x, $y, $z){
return $x.".".$y.".".$z;
return $x . "." . $y . "." . $z;
}
public static function findLog(Level $level, $x, $y, $z, array $visited, $distance){ //port from newest pocketmine
$index = self::createIndex($x, $y, $z);
@ -50,7 +50,7 @@ class LeavesBlock extends TransparentBlock{
$meta = $b[1];
if(($meta & 0b00001100) === 0x08){
$meta &= 0x03;
$visited = array();
$visited = [];
if(!self::findLog($level, $x, $y, $z, $visited, 0)){
//$this->level->setBlock($this, new AirBlock(), false, false, true);
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
@ -72,22 +72,22 @@ class LeavesBlock extends TransparentBlock{
$level->fastSetBlockUpdate($x, $y, $z, $id, $meta); //TODO maybe use $level->level->setBlock directly, the client doesnt need to know thism info.
}
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$this->meta |= 0x04;
$this->level->setBlock($this, $this, true, false, true);
}
public function getDrops(Item $item, Player $player){
$drops = array();
$drops = [];
if($item->isShears()){
$drops[] = array(LEAVES, $this->meta & 0x03, 1);
$drops[] = [LEAVES, $this->meta & 0x03, 1];
}else{
if(mt_rand(1,20) === 1){ //Saplings
$drops[] = array(SAPLING, $this->meta & 0x03, 1);
$drops[] = [SAPLING, $this->meta & 0x03, 1];
}
if(($this->meta & 0x03) === LeavesBlock::OAK and mt_rand(1,100) === 1){ //Apples
$drops[] = array(APPLE, 0, 1);
$drops[] = [APPLE, 0, 1];
}
}
return $drops;