Merge pull request #60 from Sunch233/master

Unify the code style
This commit is contained in:
enirboreHemaG 2025-04-29 02:07:18 +03:00 • committed by GitHub
commit 682de0f723
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
359 changed files with 3160 additions and 3276 deletions

27
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
codestyle:
name: Code Style checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup PHP and tools
uses: shivammathur/setup-php@2.31.1
with:
php-version: 8.0
tools: php-cs-fixer:3.60
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --diff --ansi

3
.gitignore vendored
View file

@ -10,6 +10,9 @@ server.lock
*.txt
*.properties
# php-cs-fixer
/.php_cs.cache
/.php-cs-fixer.cache
############
## Windows

36
.php-cs-fixer.php Normal file
View file

@ -0,0 +1,36 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src');
return (new PhpCsFixer\Config)
->setRules([
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short'
],
'binary_operator_spaces' => [
'default' => 'single_space'
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'cast_spaces' => [
'space' => 'single'
],
'elseif' => true,
'indentation_type' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_extra_blank_lines' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_whitespace_in_blank_line' => true,
'unary_operator_spaces' => true
])
->setFinder($finder)
->setIndent("\t")
->setLineEnding("\n")
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());

View file

@ -92,7 +92,6 @@ class AchievementAPI{
* Add an achievement
* @param string $achievementId
* @param string $achievementName
* @param array $requires
* @return boolean
*/
public static function addAchievement($achievementId, $achievementName, array $requires = []){

View file

@ -412,7 +412,6 @@ class BlockAPI{
return $this->cancelAction($target, $player, false);
}
if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
foreach($drops as $drop){
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
@ -541,8 +540,6 @@ class BlockAPI{
return $level;
}
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
if($type == BLOCK_UPDATE_NORMAL){

View file

@ -103,8 +103,6 @@ class ChatAPI{
/**
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
* @param string $text
* @param $whitelist
* @param $blacklist
*/
public function send($owner, $text, $whitelist = false, $blacklist = false){
$message = [

View file

@ -20,7 +20,6 @@ class EntityAPI{
$this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
}
public function commandHandler($cmd, $args, $issuer, $alias){
$mob = [
"chicken" => 10,

View file

@ -49,7 +49,6 @@ class LevelAPI{
}
}
$entities = new Config($path . "entities.yml", CONFIG_YAML);
if(file_exists($path . "tileEntities.yml")){
@rename($path . "tileEntities.yml", $path . "tiles.yml");

View file

@ -312,4 +312,3 @@ class RequiredPluginEntry{ //Use this as object of requirements array
}
}

View file

@ -175,5 +175,4 @@ class TimeAPI{
return $this->set("sunset");
}
}

View file

@ -1,6 +1,5 @@
<?php
class Deprecation{
public static $events = [

View file

@ -1,6 +1,5 @@
<?php
class Player{
public static $smallChunks = false, $experimentalHotbar = false;
@ -139,7 +138,6 @@ class Player{
}
/**
* @param Vector3 $pos
*
* @return boolean
*/
@ -175,7 +173,6 @@ class Player{
}
/**
* @param Vector3 $pos
* @param float|boolean $yaw
* @param float|boolean $pitch
* @param float|boolean $terrain
@ -340,8 +337,6 @@ class Player{
}
/**
* @param integer $id
* @param array $data
*
* @return array|bool
*/
@ -441,7 +436,6 @@ class Player{
/**
* @param integer $slot
* @param Item $item
* @param boolean $send
*
* @return boolean
@ -650,9 +644,6 @@ class Player{
$this->server->schedule(MAX_CHUNK_RATE, [$this, "getNextChunk"], $world);
}
/**
* @param Vector3 $pos
*/
public function setSpawn(Vector3 $pos){
if(!($pos instanceof Position)){
$level = $this->entity->level;
@ -687,9 +678,6 @@ class Player{
$this->dataPacket($pk);
}
/**
* @param $type
* @param $damage
* @param $count
*
* @return boolean
*/
@ -902,8 +890,6 @@ class Player{
}
/**
* @param $type
* @param $damage
* @param integer $count
* @param boolean $send
*
@ -1652,7 +1638,6 @@ class Player{
$this->server->api->player->saveOffline($this->data);
$pk = new LoginStatusPacket;
$pk->status = 0;
$this->dataPacket($pk);
@ -1724,7 +1709,6 @@ class Player{
$pk->started = !$this->level->isTimeStopped();
$this->dataPacket($pk);
console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
break;
case ProtocolInfo::READY_PACKET:
@ -1829,7 +1813,6 @@ class Player{
$packet->slot -= 9;
}
if(($this->gamemode & 0x01) === SURVIVAL){
$data["item"] = $this->getSlot($packet->slot);
if(!($data["item"] instanceof Item)){
@ -2672,9 +2655,6 @@ class Player{
}
/**
* @param array $craft
* @param array $recipe
* @param $type
*
* @return array|bool
*/

View file

@ -26,7 +26,6 @@ class PocketMinecraftServer{
public static $SAVE_PLAYER_DATA = true;
private function load(){
global $dolog;
/*if(defined("DEBUG") and DEBUG >= 0){
@ -347,7 +346,6 @@ class PocketMinecraftServer{
/**
* @param string $event
* @param callable $callable
* @param integer $priority
*
* @return boolean
@ -524,7 +522,6 @@ class PocketMinecraftServer{
}
}
}
public function packetHandler(Packet $packet){

View file

@ -1,4 +1,5 @@
<?php
class TileNavigator
{
@ -57,7 +58,6 @@ class TileNavigator
return $b;
}
public function navigate(Level $level, $fromX, $fromY, $fromZ, $toX, $toY, $toZ, $maxDist)
{
$from = $fromX << 16 | $fromZ << 8 | $fromY;
@ -150,7 +150,6 @@ class TileNavigator
$diffZ = ($toZ - ($neighbor >> 8 & 0xff));
$targetDist = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
$diffX = ($currentX - ($neighbor >> 16 & 0xff));
$diffY = ($currentY - ($neighbor & 0xff));
$diffZ = ($currentZ - ($neighbor >> 8 & 0xff));
@ -191,6 +190,5 @@ class TileNavigator
return null;
}
}

View file

@ -1,4 +1,5 @@
<?php
set_time_limit(0);
function parseOffset(string $offset) : string|false{

View file

@ -109,7 +109,6 @@ define("SOUL_SAND", 88);
define("GLOWSTONE", 89);
define("GLOWSTONE_BLOCK", 89);
define("LIT_PUMPKIN", 91);
define("JACK_O_LANTERN", 91);
define("CAKE_BLOCK", 92);

View file

@ -103,7 +103,6 @@ require_once(FILE_PATH . "/src/pmf/PMF.php");
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
require_once(FILE_PATH . "/src/entity/Rideable.php");
@ -138,8 +137,6 @@ require_once(FILE_PATH . "/src/world/generator/vanilla/feature/Feature.php");
require_all(FILE_PATH . "src/");
$inc = get_included_files();
$inc[] = array_shift($inc);
$srcdir = realpath(FILE_PATH . "src/");

View file

@ -7,8 +7,6 @@ abstract class Animal extends Creature implements Ageable, Breedable{
public $age;
public $loveTimeout;
public $closestPlayerThatCanFeedEID = false;
public $closestPlayerThatCanFeedDist = INF;

View file

@ -7,7 +7,6 @@ abstract class Creature extends Living{
public $closestPlayerEID = false;
public $closestPlayerDist = INF;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->inPanic = false; //force for now
parent::__construct($level, $eid, $class, $type, $data);
@ -21,7 +20,6 @@ abstract class Creature extends Living{
return parent::update($now);
}
public function handlePrePlayerSearcher(){
parent::handlePrePlayerSearcher();
if($this->closestPlayerEID !== false){

View file

@ -65,7 +65,7 @@ class Entity extends Position
public $fallStart;
private $state;
private $tickCounter;
private $speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
private $speedMeasure = [0, 0, 0, 0, 0, 0, 0];
public $server;
private $isStatic;
public $level;
@ -131,7 +131,7 @@ class Entity extends Position
$this->status = 0;
$this->health = 20;
$this->hasGravity = false;
$this->dmgcounter = array(0, 0, 0);
$this->dmgcounter = [0, 0, 0];
$this->air = $this->maxAir;
$this->fire = 0;
$this->crouched = false;
@ -154,14 +154,14 @@ class Entity extends Position
$this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"] : 0;
$this->headYaw = $this->data["headYaw"] ?? $this->yaw;
$this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"] : 0;
$this->position = array(
$this->position = [
"level" => $this->level,
"x" => &$this->x,
"y" => &$this->y,
"z" => &$this->z,
"yaw" => &$this->yaw,
"pitch" => &$this->pitch
);
];
$this->moveTime = 0;
$this->lookTime = 0;
$this->onGround = false;
@ -349,22 +349,22 @@ class Entity extends Position
$slot = $this->player->getSlot($i);
$this->player->setSlot($i, BlockAPI::getItem(AIR, 0, 0));
if($slot->getID() !== AIR and $slot->count > 0){
$inv[] = array(
$inv[] = [
$slot->getID(),
$slot->getMetadata(),
$slot->count
);
];
}
}
for($re = 0; $re < 4; $re++){
$slot = $this->player->getArmor($re);
$this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0));
if($slot->getID() !== AIR and $slot->count > 0){
$inv[] = array(
$inv[] = [
$slot->getID(),
$slot->getMetadata(),
$slot->count
);
];
}
}
return $inv;
@ -427,14 +427,14 @@ class Entity extends Position
foreach($this->server->api->entity->getRadius($this, 2, false) as $item){
if($item->class === ENTITY_ITEM && !$item->closed && $item->spawntime > 0 && $item->delayBeforePickup <= 0){
if($item->boundingBox->intersectsWith($myBB)){
if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->itemID, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", array(
if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->itemID, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", [
"eid" => $this->player->eid,
"player" => $this->player,
"entity" => $item,
"block" => $item->itemID,
"meta" => $item->meta,
"target" => $item->eid
)) !== false){
]) !== false){
$item->close();
}
}
@ -589,14 +589,12 @@ class Entity extends Position
$this->speedX = $this->speedY = $this->speedZ = 0;
}
$savedDX = $dx;
$savedDY = $dy;
$savedDZ = $dz;
$oldBB = clone $this->boundingBox;
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
foreach($aaBBs as $bb){
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
@ -613,7 +611,6 @@ class Entity extends Position
}
$this->boundingBox->offset(0, 0, $dz);
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
@ -665,13 +662,10 @@ class Entity extends Position
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
$this->updateFallState($this->speedY);
if($savedDX != $dx) $this->speedX = 0;
if($savedDY != $dy) $this->speedY = 0;
if($savedDZ != $dz) $this->speedZ = 0;
//TODO more stuff -> onEntityWalking
$this->doBlocksCollision();
@ -840,7 +834,6 @@ class Entity extends Position
}
}
if($this->isOnLadder()){
$this->fallDistance = 0;
$this->notOnGroundTicks = 0;
@ -880,7 +873,6 @@ class Entity extends Position
}
}
$this->counterUpdate();
if($this->isPlayer()){
@ -1179,7 +1171,6 @@ class Entity extends Position
--$this->idleTime;
}
if($this->inAction){
++$this->inActionCounter;
}
@ -1283,7 +1274,7 @@ class Entity extends Position
public function resetSpeed()
{
$this->speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
$this->speedMeasure = [0, 0, 0, 0, 0, 0, 0];
}
public function getSpeed()
@ -1490,7 +1481,6 @@ class Entity extends Position
$this->server->api->dhandle("entity.link", ["rider" => $this->eid, "riding" => $e->eid, "type" => 0]);
}
}
public function isPlayer()
@ -1557,12 +1547,12 @@ class Entity extends Position
$harm = true;
}
if($this->server->api->dhandle("entity.health.change", array(
if($this->server->api->dhandle("entity.health.change", [
"entity" => $this,
"eid" => $this->eid,
"health" => $health,
"cause" => $cause
)) !== false or $force === true){
]) !== false or $force === true){
$this->health = min(127, max(-127, $health));
if($harm === true && $allowHarm){
$pk = new EntityEventPacket;
@ -1703,7 +1693,6 @@ class Entity extends Position
throw new Exception("Use getHeightOf or getWidthOf method instead of this.");
}
/**
*
* @deprecated Use {@link getHeight} or {@link getWidth} instead

View file

@ -6,7 +6,6 @@ abstract class Living extends Entity implements Pathfindable{
public static $pathfinderTest = false;
/**
* @var Entity $target
* @var EntityAI $ai
@ -21,7 +20,7 @@ abstract class Living extends Entity implements Pathfindable{
public $renderYawOffset = 0.0; //used by head rotation, TODO better name
public $jumping, $jumpTicks;
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->target = false;
$this->ai = new EntityAI($this);
$this->pathFinder = new TileNavigator($this);
@ -147,7 +146,6 @@ abstract class Living extends Entity implements Pathfindable{
);
}
/*if($this->path){
console("Found path of length ".count($this->path));
@ -172,7 +170,6 @@ abstract class Living extends Entity implements Pathfindable{
$this->pathFollower->followPath();
}
//not exactly here
if($this->jumping){
if(!$this->inWater && !$this->inLava){
@ -187,7 +184,6 @@ abstract class Living extends Entity implements Pathfindable{
$this->jumpTicks = 0;
}
$this->ai->mobController->movementTick();
$this->ai->mobController->rotateTick();
$this->ai->mobController->jumpTick();
@ -220,7 +216,6 @@ abstract class Living extends Entity implements Pathfindable{
if($this->jumpTicks > 0) --$this->jumpTicks;
}
public function moveEntityWithHeading($strafe, $forward){
if($this->inWater){ //also check is player, and can it fly or not
$prevPosY = $this->y;
@ -231,7 +226,6 @@ abstract class Living extends Entity implements Pathfindable{
$this->speedZ *= 0.8;
$this->speedY -= 0.02;
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
$this->speedY = 0.3;
}

View file

@ -1,4 +1,5 @@
<?php
class Monster extends Creature{
public $closestPlayerToAttackEID = false;

View file

@ -1,4 +1,5 @@
<?php
abstract class Projectile extends Entity{
const CLASS_TYPE = ENTITY_OBJECT;
public $shooterEID;

View file

@ -24,7 +24,6 @@ class EntityAI
$this->mobController = new MobController($entity);
}
public function canSee(Entity $entity){
//TODO caches
return $this->entity->canSee($entity);
@ -32,7 +31,6 @@ class EntityAI
/**
* Add a task for entity
* @param TaskBase $task
*/
public function addTask(TaskBase $task){
$this->tasks[$task->__toString()] = $task;

View file

@ -208,7 +208,6 @@ class MobController
$dz = $z / $len;
}
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
$thetaOffset = $dz < 0 ? 90 : 270;
$calcYaw = ($thetaOffset + $tan);

View file

@ -28,7 +28,6 @@ class PathFollower{
$this->entity->currentNode = null;
}
if($this->entity->currentIndex >= count($this->entity->path)){
console("path finished.");
$this->entity->currentNode = null;

View file

@ -17,7 +17,6 @@ class TaskAttackPlayer extends TaskBase
$this->selfCounter = 1;
}
public function onUpdate(EntityAI $ai)
{
if(!$this->isTargetValid($ai)){
@ -47,7 +46,6 @@ class TaskAttackPlayer extends TaskBase
}
public function isTargetValid(EntityAI $ai){
$e = $ai->entity;
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){

View file

@ -8,25 +8,21 @@ abstract class TaskBase
/**
* Executed when entity starts task. It is recommended to set counter here.
* @param EntityAI $ai
*/
abstract function onStart(EntityAI $ai);
/**
* Every tick until counter will be not equal to 0. It is recommended to update value of counter here.
* @param EntityAI $ai
*/
abstract function onUpdate(EntityAI $ai);
/**
* On task end.
* @param EntityAI $ai
*/
abstract function onEnd(EntityAI $ai);
/**
* Can start the task
* @param EntityAI $ai
*/
abstract function canBeExecuted(EntityAI $ai);

View file

@ -28,7 +28,6 @@ class TaskMate extends TaskBase
return;
}
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed());
$ai->mobController->setMovingTarget($movTo->x, $movTo->y, $movTo->z, $this->speedMultiplier);

View file

@ -42,6 +42,5 @@ class TaskPanic extends TaskBase
return $ai->entity instanceof Animal && $ai->entity->inPanic && $ai->entity->knockbackTime <= 0;
}
}

View file

@ -43,5 +43,4 @@ class TaskRandomWalk extends TaskBase
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskFollowParent") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
}
}

View file

@ -37,7 +37,6 @@ class TaskRangedAttack extends \TaskBase
$this->seenTicks = 0;
}
$dist = $ai->entity->distanceSquared($ai->entity->target);
if($dist > 100 || $this->seenTicks < 20){
@ -89,7 +88,6 @@ class TaskRangedAttack extends \TaskBase
}
}
public function isTargetValid(EntityAI $ai){
$e = $ai->entity;
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
@ -123,7 +121,6 @@ class TaskRangedAttack extends \TaskBase
return false;
}
public function canBeExecuted(EntityAI $ai)
{
return $this->tryTargeting($ai);

View file

@ -37,7 +37,6 @@ class TaskTempt extends TaskBase
$ai->mobController->headYawIsYaw = true;
}
}
public function isTargetValid(EntityAI $ai){

View file

@ -1,4 +1,5 @@
<?php
class Pig extends Animal implements Rideable{
const TYPE = MOB_PIG;

View file

@ -1,4 +1,5 @@
<?php
class Creeper extends Monster{
const TYPE = MOB_CREEPER;
const EXPL_TIME = 30;
@ -27,8 +28,6 @@ class Creeper extends Monster{
$this->setState($v === null ? !$this->getState() : $v);
}
/**
* @return boolean
*/

View file

@ -1,4 +1,5 @@
<?php
class PigZombie extends Monster{ //TODO extends zombie
const TYPE = MOB_PIGMAN;
function __construct(Level $level, $eid, $class, $type = 0, $data = []){

View file

@ -1,4 +1,5 @@
<?php
class Skeleton extends Monster{
const TYPE = MOB_SKELETON;
function __construct(Level $level, $eid, $class, $type = 0, $data = []){

View file

@ -1,8 +1,9 @@
<?php
class Spider extends Monster{
const TYPE = MOB_SPIDER;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(1.4, 0.9);
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth($this->data["Health"] ?? 8, "generic");

View file

@ -1,7 +1,8 @@
<?php
class Zombie extends Monster{
const TYPE = MOB_ZOMBIE;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(0.6, 1.85);
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth($this->data["Health"] ?? 12, "generic");

View file

@ -120,7 +120,6 @@ class Arrow extends Entity{
}
//Entity::update end
if($this->lastPitch == $this->lastYaw && $this->lastYaw == 0){
$v1 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
$this->lastYaw = $this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
@ -163,7 +162,6 @@ class Arrow extends Entity{
$end = new Vector3($this->x + $this->speedX, $this->y + $this->speedY, $this->z + $this->speedZ);
}
$entities = $this->level->getEntitiesInAABB($this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ)->expand(1, 1, 1));
$bestDist = 0;
$bestEnt = null;
@ -197,7 +195,6 @@ class Arrow extends Entity{
$damage += mt_rand(0, $damage / 2 + 1);
}
if($v4->entityHit->harm($damage, $this->eid)){
//vanilla seems to increase arrow count if $v4->entity is mob
$this->close();
@ -256,8 +253,6 @@ class Arrow extends Entity{
$this->doBlocksCollision();
}
}
public function spawn($player){

View file

@ -7,7 +7,7 @@ class ItemEntity extends Entity{
public $meta, $stack, $itemID;
public function __construct(Level $level, $eid, $class, $type = 0, $data = array())
public function __construct(Level $level, $eid, $class, $type = 0, $data = [])
{
parent::__construct($level, $eid, $class, $type, $data);
$this->setSize(0.25, 0.25);
@ -64,7 +64,6 @@ class ItemEntity extends Entity{
$player->dataPacket($pk);
}
public function tryCombining(Entity $another){
if($another->eid == $this->eid) return false;

View file

@ -281,7 +281,6 @@ class Minecart extends Vehicle{
}
public function applyNaturalSlowdown(){
$mult = $this->linkedEntity != 0 && !$this->isRider ? 0.997 : 0.96;

View file

@ -87,7 +87,7 @@ class Painting extends Entity{
public function setDirection($dir){
$this->direction = $dir;
$this->lastYaw = $this->yaw = $dir * 90;
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
$width = $size[0] * 16;
$height = $size[1] * 16;
if($dir == 2 || $dir == 0){
@ -144,7 +144,7 @@ class Painting extends Entity{
$cubes = $this->level->getCubes($this, $this->boundingBox);
if(count($cubes) == 0){
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
$width = $size[0];
$width2 = $width * 16 / 32;
$height = $size[1];

View file

@ -1,4 +1,5 @@
<?php
class ThrownEgg extends Projectile{
const TYPE = OBJECT_EGG;
@ -28,5 +29,4 @@ class ThrownEgg extends Projectile{
$this->close();
}
}

View file

@ -1,4 +1,5 @@
<?php
class ThrownSnowball extends Projectile{
const TYPE = OBJECT_SNOWBALL;
public function onHit(MovingObjectPosition $hitResult){

View file

@ -1,6 +1,5 @@
<?php
/**
* Plugins that create events must use this class as the base
*/

View file

@ -25,7 +25,6 @@ class PacketReceiveEvent extends ServerEvent implements CancellableEvent{
private $packet;
public function __construct(Packet $packet){
$this->packet = $packet;
}

View file

@ -25,7 +25,6 @@ class PacketSendEvent extends ServerEvent implements CancellableEvent{
private $packet;
public function __construct(Packet $packet){
$this->packet = $packet;
}

View file

@ -11,7 +11,6 @@ if(!function_exists("cli_set_process_title")){
}
}
function dummy(){
}
@ -69,8 +68,6 @@ function nullsafe(&$a, $null){
return $a ?? $null;
}
function require_all($path, &$count = 0){
$dir = dir($path . "/");
$dirs = [];

View file

@ -143,13 +143,12 @@ LICENSE;
$config->save();
echo "[*] ".$this->lang->ip_get."\n";
$externalIP = Utils::getIP();
$internalIP = gethostbyname(trim(`hostname`));
echo "[!] ".$this->lang->get("ip_warning", array("{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"), array($externalIP, $internalIP))."\n";
echo "[!] ".$this->lang->get("ip_warning", ["{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"], [$externalIP, $internalIP])."\n";
echo "[!] ".$this->lang->ip_confirm;
$this->getInput();
}
@ -166,11 +165,10 @@ LICENSE;
return $input === "" ? $default:$input;
}
}
class InstallerLang{
public static $languages = array(
public static $languages = [
"ru" => "Pyccĸий",
"en" => "English",
"es" => "Español",
@ -189,8 +187,8 @@ LICENSE;
"tr" => "Türkçe",
"uk" => "Український"
//"et" => "Eesti",
);
private $texts = array();
];
private $texts = [];
private $lang;
private $langfile;
public function __construct($lang = ""){
@ -200,7 +198,7 @@ LICENSE;
}else{
$l = glob(FILE_PATH."src/lang/Installer/".$lang."_*.ini");
if(count($l) > 0){
$files = array();
$files = [];
foreach($l as $file){
$files[$file] = filesize($file);
}
@ -228,19 +226,19 @@ LICENSE;
}
public function loadLang($langfile, $lang = "en"){
$this->texts[$lang] = array();
$texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile)));
$this->texts[$lang] = [];
$texts = explode("\n", str_replace(["\r", "\/\/"], ["", "//"], file_get_contents($langfile)));
foreach($texts as $line){
$line = trim($line);
if($line === ""){
continue;
}
$line = explode("=", $line);
$this->texts[$lang][array_shift($line)] = str_replace(array("\\n", "\\N",), "\n", implode("=", $line));
$this->texts[$lang][array_shift($line)] = str_replace(["\\n", "\\N",], "\n", implode("=", $line));
}
}
public function get($name, $search = array(), $replace = array()){
public function get($name, $search = [], $replace = []){
if(!isset($this->texts[$this->lang][$name])){
if($this->lang !== "en" and isset($this->texts["en"][$name])){
return $this->texts["en"][$name];

View file

@ -1,7 +1,7 @@
<?php
abstract class Block extends Position{
public static $class = array(
public static $class = [
AIR => "AirBlock",
STONE => "StoneBlock",
GRASS => "GrassBlock",
@ -132,7 +132,7 @@ abstract class Block extends Position{
INFO_UPDATE => "InfoUpdateBlock",
INFO_UPDATE2 => "InfoUpdate2Block",
RESERVED6 => "Reserved6Block",
);
];
public $id;
public $meta;
public $name;
@ -230,7 +230,6 @@ abstract class Block extends Position{
}
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){}
public function __construct($id, $meta = 0, $name = "Unknown"){
$this->id = (int) $id;
$this->meta = (int) $meta;
@ -269,11 +268,11 @@ abstract class Block extends Position{
public function getDrops(Item $item, Player $player){
if(!isset(Block::$class[$this->id])){ //Unknown blocks
return array();
return [];
}else{
return array(
array($this->id, $this->meta, 1),
);
return [
[$this->id, $this->meta, 1],
];
}
}

View file

@ -9,7 +9,7 @@ class Item{
const DEF_DAMAGE = 1;
public static $class = array(
public static $class = [
//armor
LEATHER_CAP => "LeatherCapItem",
@ -128,7 +128,7 @@ class Item{
CLOCK => "ClockItem",
SHEARS => "ShearsItem",
);
];
public $block;
public $id;
public $meta;

View file

@ -1,4 +1,5 @@
<?php
/*value - durability*/
class Material{
const LEATHER = 5; //when enums

View file

@ -135,7 +135,6 @@ class StaticBlock
return $bb->setBounds($x + $bb->minX, $y + $bb->minY, $z + $bb->minZ, $x + $bb->maxX, $y + $bb->maxY, $z + $bb->maxZ);
}
public static function getSlipperiness($id){
return self::$slipperiness[$id] ?? StaticBlock::DEFAULT_SLIPPERINESS;
}

View file

@ -87,7 +87,6 @@ class DoorBlock extends TransparentBlock{
break;
}
return [$aabb->offset($x, $y, $z)];
}
@ -105,7 +104,6 @@ class DoorBlock extends TransparentBlock{
return $metaLower & 7 | (($myMeta & 8) != 0 ? 8 : 0) | (($metaUpper & 1 != 0) ? 16 : 0);
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
@ -121,12 +119,7 @@ class DoorBlock extends TransparentBlock{
}
}
/**
* @param Item $item
* @param Player $player
* @param Block $block
* @param Block $target
* @param integer $face
* @param integer $fx
* @param integer $fy
@ -142,12 +135,12 @@ class DoorBlock extends TransparentBlock{
return false;
}
$direction = $player->entity->getDirection();
$face = array(
$face = [
0 => 3,
1 => 4,
2 => 2,
3 => 5,
);
];
$next = $this->getSide($face[(($direction + 2) % 4)]);
$next2 = $this->getSide($face[$direction]);
$metaUp = 0x08;
@ -164,8 +157,6 @@ class DoorBlock extends TransparentBlock{
}
/**
* @param Item $item
* @param Player $player
*
* @return boolean
*/
@ -186,8 +177,6 @@ class DoorBlock extends TransparentBlock{
}
/**
* @param Item $item
* @param Player $player
*
* @return boolean
*/

View file

@ -12,10 +12,6 @@ class FallableBlock extends SolidBlock{
}
/**
* @param Item $item
* @param Player $player
* @param Block $block
* @param Block $target
* @param int $face
* @param int $fx
* @param int $fy

View file

@ -1,6 +1,5 @@
<?php
class GenericBlock extends Block{
/**
* @param int $id
@ -12,10 +11,6 @@ class GenericBlock extends Block{
}
/**
* @param Item $item
* @param Player $player
* @param Block $block
* @param Block $target
* @param integer $face
* @param integer $fx
* @param integer $fy
@ -28,8 +23,6 @@ class GenericBlock extends Block{
}
/**
* @param Item $item
* @param Player $player
*
* @return boolean
*/
@ -38,8 +31,6 @@ class GenericBlock extends Block{
}
/**
* @param Item $item
* @param Player $player
*
* @return mixed
*/
@ -60,12 +51,12 @@ class GenericBlock extends Block{
[$id, $meta] = $level->level->getBlock($x, $y, $z);
$down = $level->level->getBlockID($x, $y - 1, $z);
if($down == AIR || StaticBlock::getIsLiquid($down)){
$data = array(
$data = [
"x" => $x + 0.5,
"y" => $y - 0.5,
"z" => $z + 0.5,
"Tile" => $id,
);
];
$server = ServerAPI::request();
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
@ -74,7 +65,6 @@ class GenericBlock extends Block{
}
/**
* @param integer $type
*
* @return boolean
*/
@ -86,8 +76,6 @@ class GenericBlock extends Block{
}
/**
* @param Item $item
* @param Player $player
*
* @return boolean
*/

View file

@ -184,9 +184,8 @@ class LiquidBlock extends TransparentBlock{
}
}
public function getDrops(Item $item, Player $player){
return array();
return [];
}
public function getLiquidHeight(){

View file

@ -319,10 +319,6 @@ class StairBlock extends TransparentBlock{
}
/**
* @param Item $item
* @param Player $player
* @param Block $block
* @param Block $target
* @param int $face
* @param int $fx
* @param int $fy
@ -331,12 +327,12 @@ class StairBlock extends TransparentBlock{
* @return bool|mixed
*/
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array(
$faces = [
0 => 0,
1 => 2,
2 => 1,
3 => 3,
);
];
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
if(($fy > 0.5 and $face !== 1) or $face === 0){
$this->meta |= 0x04; //Upside-down stairs
@ -346,18 +342,16 @@ class StairBlock extends TransparentBlock{
}
/**
* @param Item $item
* @param Player $player
*
* @return array
*/
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}else{
return array();
return [];
}
}
}

View file

@ -59,8 +59,8 @@ class LadderBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -47,8 +47,8 @@ class SignPostBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array(SIGN, 0, 1),
);
return [
[SIGN, 0, 1],
];
}
}

View file

@ -33,13 +33,13 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->isTransparent === false and $face !== 0){
$faces = array(
$faces = [
1 => 5,
2 => 4,
3 => 3,
4 => 2,
5 => 1,
);
];
$this->meta = $faces[$face];
$this->level->setBlock($block, $this, true, false, true);
return true;
@ -51,8 +51,8 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -59,21 +59,21 @@ class TrapdoorBlock extends TransparentBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
$faces = array(
$faces = [
2 => 0,
3 => 1,
4 => 2,
5 => 3,
);
];
$this->meta = $faces[$face] & 0x03;
$this->level->setBlock($block, $this, true, false, true);
return true;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
$attach = match($level->level->getBlockDamage($x, $y, $z)){

View file

@ -1,4 +1,5 @@
<?php
require_once("LiquidBlockDynamic.php"); //TODO class loader?
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{

View file

@ -22,5 +22,4 @@ class LiquidBlockStatic extends LiquidBlock{
}
}
}

View file

@ -1,4 +1,5 @@
<?php
require_once("LiquidBlockStatic.php"); //TODO class loader?
class StillLavaBlock extends LiquidBlockStatic{

View file

@ -1,6 +1,5 @@
<?php
/***REM_START***/
require_once("WaterBlock.php"); //TODO class loader?
require_once("LiquidBlockStatic.php"); //TODO class loader?

View file

@ -1,4 +1,5 @@
<?php
require_once("LiquidBlockDynamic.php"); //TODO class loader?
class WaterBlock extends LiquidBlockDynamic{

View file

@ -172,9 +172,9 @@ class BedBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array(BED, 0, 1),
);
return [
[BED, 0, 1],
];
}
}

View file

@ -35,7 +35,7 @@ class FireBlock extends FlowableBlock implements LightingBlock{
}
public function getDrops(Item $item, Player $player){
return array();
return [];
}
public function getMaxLightValue(){
return 15;
@ -79,6 +79,5 @@ class FireBlock extends FlowableBlock implements LightingBlock{
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
}
}

View file

@ -15,24 +15,24 @@ class NetherReactorBlock extends SolidBlock{
$this->meta = 1;
$this->level->setBlock($this,$this);
$server = ServerAPI::request();
$server->schedule(40, array($this, "glow"), 1);
$server->schedule(60, array($this, "glow"), 2);
$server->schedule(80, array($this, "glow"), 3);
$server->schedule(140, array($this, "glow"), 4);
$server->schedule(200, array($this, "spawnItems"), [0,15,2,true]); //200
$server->schedule(260, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
$server->schedule(300, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
$server->schedule(340, array($this, "spawnItems"), [11,20,"checkPigmen",false]);
$server->schedule(400, array($this, "spawnItems"), [0,10,"checkPigmen",false]);
$server->schedule(500, array($this, "spawnItems"), [17,32, "checkPigmen",false]); //500
$server->schedule(580, array($this, "spawnItems"), [17,32, "checkPigmen",false]);
$server->schedule(620, array($this, "spawnItems"), [1,32, "checkPigmen",false]);
$server->schedule(660, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
$server->schedule(700, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
$server->schedule(860, array($this, "glow"), 5);
$server->schedule(880, array($this, "glow"), 6);
$server->schedule(900, array($this, "glow"), 7);
$server->schedule(920, array($this, "destroy"));
$server->schedule(40, [$this, "glow"], 1);
$server->schedule(60, [$this, "glow"], 2);
$server->schedule(80, [$this, "glow"], 3);
$server->schedule(140, [$this, "glow"], 4);
$server->schedule(200, [$this, "spawnItems"], [0,15,2,true]); //200
$server->schedule(260, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
$server->schedule(300, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
$server->schedule(340, [$this, "spawnItems"], [11,20,"checkPigmen",false]);
$server->schedule(400, [$this, "spawnItems"], [0,10,"checkPigmen",false]);
$server->schedule(500, [$this, "spawnItems"], [17,32, "checkPigmen",false]); //500
$server->schedule(580, [$this, "spawnItems"], [17,32, "checkPigmen",false]);
$server->schedule(620, [$this, "spawnItems"], [1,32, "checkPigmen",false]);
$server->schedule(660, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
$server->schedule(700, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
$server->schedule(860, [$this, "glow"], 5);
$server->schedule(880, [$this, "glow"], 6);
$server->schedule(900, [$this, "glow"], 7);
$server->schedule(920, [$this, "destroy"]);
return true;
}
//}
@ -105,11 +105,11 @@ class NetherReactorBlock extends SolidBlock{
$randomRange = floor(lcg_value() * 5 + 3);
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
$data = array(
$data = [
"x" => $x + ($shiftX * $randomRange) + 0.5,
"y" => $y,
"z" => $z + ($shiftZ * $randomRange) + 0.5,
);
];
$e = $server->api->entity->add($this->level, ENTITY_MOB, MOB_PIGMAN, $data);
$server->api->entity->spawnToAll($e);
}

View file

@ -13,13 +13,13 @@ class TNTBlock extends SolidBlock{
if(($player->gamemode & 0x01) === 0){
$item->useOn($this);
}
$data = array(
$data = [
"x" => $this->x + 0.5,
"y" => $this->y,
"z" => $this->z + 0.5,
"power" => 3,
"fuse" => 20 * 4, //4 seconds
);
];
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, 0, 0, true);
$e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
ServerAPI::request()->api->entity->spawnToAll($e);

View file

@ -37,7 +37,7 @@ class CakeBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array();
return [];
}
public function onActivate(Item $item, Player $player){

View file

@ -4,7 +4,7 @@ class CarpetBlock extends FlowableBlock{
public static $blockID;
public function __construct($meta = 0){
parent::__construct(CARPET, $meta, "Carpet");
$names = array(
$names = [
0 => "White Carpet",
1 => "Orange Carpet",
2 => "Magenta Carpet",
@ -21,7 +21,7 @@ class CarpetBlock extends FlowableBlock{
13 => "Green Carpet",
14 => "Red Carpet",
15 => "Black Carpet",
);
];
$this->name = $names[$this->meta];
$this->hardness = 0;
$this->isFullBlock = false;

View file

@ -14,12 +14,12 @@ class ChestBlock extends TransparentBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$server = ServerAPI::request();
$faces = array(
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
);
];
$chest = false;
$this->meta = $faces[$player->entity->getDirection()];
@ -40,13 +40,13 @@ class ChestBlock extends TransparentBlock{
}
$this->level->setBlock($block, $this, true, false, true);
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
"Items" => array(),
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
"Items" => [],
"id" => TILE_CHEST,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z
));
]);
$server->api->tile->spawnToAll($tile);
if($chest instanceof Tile){
@ -77,17 +77,15 @@ class ChestBlock extends TransparentBlock{
if($t !== false){
$chest = $t;
}else{
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
"Items" => array(),
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
"Items" => [],
"id" => TILE_CHEST,
"x" => $this->x,
"y" => $this->y,
"z" => $this->z
));
]);
}
if(($player->gamemode & 0x01) === 0x01){
return true;
}
@ -97,15 +95,15 @@ class ChestBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
$drops = array(
array($this->id, 0, 1),
);
$drops = [
[$this->id, 0, 1],
];
$t = ServerAPI::request()->api->tile->get($this);
if($t !== false and $t->class === TILE_CHEST){
for($s = 0; $s < CHEST_SLOTS; ++$s){
$slot = $t->getSlot($s);
if($slot->getID() > AIR and $slot->count > 0){
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
}
}
}

View file

@ -21,7 +21,7 @@ class CobwebBlock extends FlowableBlock{
}
elseif ($item->isShears()){
return [
array(COBWEB, 0, 1),
[COBWEB, 0, 1],
];
}
}

View file

@ -7,9 +7,9 @@ class FarmlandBlock extends TransparentBlock{
$this->hardness = 3;
}
public function getDrops(Item $item, Player $player){
return array(
array(DIRT, 0, 1),
);
return [
[DIRT, 0, 1],
];
}
public function hasCrops(){
//TODO vanilla 0.8.1 detection method
@ -42,7 +42,6 @@ class FarmlandBlock extends TransparentBlock{
}
}
}
public static function checkWaterStatic(Level $level, $x, $y, $z)

View file

@ -33,20 +33,20 @@ class FenceGateBlock extends TransparentBlock{
$this->hardness = 15;
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array(
$faces = [
0 => 3,
1 => 0,
2 => 1,
3 => 2,
);
];
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
$this->level->setBlock($block, $this, true, false, true);
return true;
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
public function onActivate(Item $item, Player $player){

View file

@ -66,8 +66,8 @@ class GlassPaneBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array(GLASS_PANE, 0, 0),
);
return [
[GLASS_PANE, 0, 0],
];
}
}

View file

@ -24,11 +24,11 @@ class IronDoorBlock extends DoorBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array(IRON_DOOR, 0, 1),
);
return [
[IRON_DOOR, 0, 1],
];
}else{
return array();
return [];
}
}
}

View file

@ -1,4 +1,5 @@
<?php
require_once("RailBaseBlock.php");
class PoweredRailBlock extends RailBaseBlock{
public static $blockID;

View file

@ -1,4 +1,5 @@
<?php
require_once("RailBaseBlock.php");
class RailBlock extends RailBaseBlock{
public static $blockID;

View file

@ -106,11 +106,11 @@ class SlabBlock extends TransparentBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array($this->id, $this->meta & 0x07, 1),
);
return [
[$this->id, $this->meta & 0x07, 1],
];
}else{
return array();
return [];
}
}
}

View file

@ -29,11 +29,11 @@ class SnowLayerBlock extends FlowableBlock{
public function getDrops(Item $item, Player $player){
if($item->isShovel() !== false){
return array(
array(SNOWBALL, 0, 1),
);
return [
[SNOWBALL, 0, 1],
];
}
return array();
return [];
}
}

View file

@ -9,8 +9,8 @@ class WoodDoorBlock extends DoorBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array(WOODEN_DOOR, 0, 1),
);
return [
[WOODEN_DOOR, 0, 1],
];
}
}

View file

@ -1,15 +1,16 @@
<?php
//TODO make it extend SlabBlock
class WoodSlabBlock extends TransparentBlock{
public static $blockID;
public function __construct($meta = 0){
parent::__construct(WOOD_SLAB, $meta, "Wooden Slab");
$names = array(
$names = [
0 => "Oak",
1 => "Spruce",
2 => "Birch",
3 => "Jungle",
);
];
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
if(($this->meta & 0x08) === 0x08){
$this->isFullBlock = true;
@ -101,8 +102,8 @@ class WoodSlabBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, $this->meta & 0x07, 1),
);
return [
[$this->id, $this->meta & 0x07, 1],
];
}
}

View file

@ -7,8 +7,8 @@ class BirchWoodStairsBlock extends StairBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -7,8 +7,8 @@ class JungleWoodStairsBlock extends StairBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -7,8 +7,8 @@ class SpruceWoodStairsBlock extends StairBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -21,8 +21,8 @@ class WoodStairsBlock extends StairBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -23,11 +23,11 @@ class CoalOreBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array(COAL, 0, 1),
);
return [
[COAL, 0, 1],
];
}else{
return array();
return [];
}
}

View file

@ -20,11 +20,11 @@ class DiamondOreBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 4){
return array(
array(DIAMOND, 0, 1),
);
return [
[DIAMOND, 0, 1],
];
}else{
return array();
return [];
}
}
}

View file

@ -28,11 +28,11 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 4){
return array(
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
);
return [
[REDSTONE_DUST, 0, mt_rand(4, 5)],
];
}else{
return array();
return [];
}
}

View file

@ -20,11 +20,11 @@ class GoldOreBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 4){
return array(
array(GOLD_ORE, 0, 1),
);
return [
[GOLD_ORE, 0, 1],
];
}else{
return array();
return [];
}
}
}

View file

@ -21,11 +21,11 @@ class IronOreBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
return array(
array(IRON_ORE, 0, 1),
);
return [
[IRON_ORE, 0, 1],
];
}else{
return array();
return [];
}
}
}

View file

@ -21,11 +21,11 @@ class LapisOreBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 3){
return array(
array(DYE, 4, mt_rand(4, 8)),
);
return [
[DYE, 4, mt_rand(4, 8)],
];
}else{
return array();
return [];
}
}

View file

@ -13,11 +13,11 @@ class RedstoneOreBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 4){
return array(
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
);
return [
[REDSTONE_DUST, 0, mt_rand(4, 5)],
];
}else{
return array();
return [];
}
}
}

View file

@ -69,8 +69,8 @@ class CactusBlock extends TransparentBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
return [
[$this->id, 0, 1],
];
}
}

View file

@ -21,7 +21,6 @@ class CyanFlowerBlock extends FlowableBlock{
return false;
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
$downId = $level->level->getBlockID($x, $y - 1, $z);
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
@ -30,8 +29,6 @@ class CyanFlowerBlock extends FlowableBlock{
}
}
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
if(($player->gamemode & 0x01) === 0){

View file

@ -11,12 +11,12 @@ class SaplingBlock extends FlowableBlock{
public function __construct($meta = SaplingBlock::OAK){
parent::__construct(SAPLING, $meta, "Sapling");
$this->isActivable = true;
$names = array(
$names = [
0 => "Oak Sapling",
1 => "Spruce Sapling",
2 => "Birch Sapling",
3 => "Jungle Sapling",
);
];
$this->name = $names[$this->meta & 0x03];
$this->hardness = 0;
}
@ -64,8 +64,8 @@ class SaplingBlock extends FlowableBlock{
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, $this->meta & 0x03, 1),
);
return [
[$this->id, $this->meta & 0x03, 1],
];
}
}

Some files were not shown because too many files have changed in this diff Show more