Merge pull request #9 from yefengeeeeeeeeeee/main

Merger Conflict
This commit is contained in:
yefengeeeeeeeeeee 2026-04-04 15:07:47 +08:00 • committed by GitHub
commit 845ff19ba1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
300 changed files with 3314 additions and 2026 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 *.txt
*.properties *.properties
# php-cs-fixer
/.php_cs.cache
/.php-cs-fixer.cache
############ ############
## Windows ## 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

@ -4,7 +4,7 @@
NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content
Supported MCPE versions: 0.8.0, 0.8.1 (maybe 0.8.2) Supported MCPE versions: 0.3.0 ~ 0.8.1 (maybe 0.8.2)
(Special thx to GullCraft Network and DartMiner43) (Special thx to GullCraft Network and DartMiner43)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -503,6 +503,12 @@ class Player{
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY) return; if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY) return;
if(!$this->convertToLocalEIDPacket($packet)) return false; if(!$this->convertToLocalEIDPacket($packet)) return false;
if(PacketPool::isPacketExist($packet->pid(), $this->PROTOCOL) != true){
return;
}
$packet->PROTOCOL = $this->PROTOCOL;
$packet->encode(); $packet->encode();
$len = strlen($packet->buffer) + 1; $len = strlen($packet->buffer) + 1;
$MTU = $this->MTU - 24; $MTU = $this->MTU - 24;
@ -1667,6 +1673,7 @@ class Player{
} }
$this->received[$p->messageIndex] = true; $this->received[$p->messageIndex] = true;
} }
$p->PROTOCOL = $this->PROTOCOL;
$p->decode(); $p->decode();
$this->handleDataPacket($p); $this->handleDataPacket($p);
} }
@ -1892,6 +1899,7 @@ class Player{
$motion->speedX = $e->speedX; $motion->speedX = $e->speedX;
$motion->speedY = $e->speedY; $motion->speedY = $e->speedY;
$motion->speedZ = $e->speedZ; $motion->speedZ = $e->speedZ;
$motion->PROTOCOL = $this->PROTOCOL;
$motion->encode(); $motion->encode();
$len += 10 + strlen($motion->buffer); $len += 10 + strlen($motion->buffer);
++$packets; ++$packets;
@ -1913,6 +1921,7 @@ class Player{
$move->yaw = $e->yaw; $move->yaw = $e->yaw;
$move->pitch = $e->pitch; $move->pitch = $e->pitch;
$move->bodyYaw = $e->headYaw; $move->bodyYaw = $e->headYaw;
$move->PROTOCOL = $this->PROTOCOL;
$move->encode(); $move->encode();
}else{ }else{
$move = new MoveEntityPacket_PosRot(); $move = new MoveEntityPacket_PosRot();
@ -1922,16 +1931,19 @@ class Player{
$move->z = $e->z; $move->z = $e->z;
$move->yaw = $e->yaw; $move->yaw = $e->yaw;
$move->pitch = $e->pitch; $move->pitch = $e->pitch;
$move->PROTOCOL = $this->PROTOCOL;
$move->encode(); $move->encode();
} }
$len += strlen($move->buffer) + 10; $len += strlen($move->buffer) + 10;
++$packets; ++$packets;
$moveSent = true; $moveSent = true;
}else if($e->headYaw != $e->lastHeadYaw){
}elseif($this->PROTOCOL > ProtocolInfo12::CURRENT_PROTOCOL_12 && $e->headYaw != $e->lastHeadYaw){
$headyaw = new RotateHeadPacket(); $headyaw = new RotateHeadPacket();
$headyaw->eid = $localeid; $headyaw->eid = $localeid;
$headyaw->yaw = $e->headYaw; $headyaw->yaw = $e->headYaw;
$headyaw->PROTOCOL = $this->PROTOCOL;
$headyaw->encode(); $headyaw->encode();
$len += strlen($headyaw->buffer) + 10; $len += strlen($headyaw->buffer) + 10;
++$packets; ++$packets;
@ -2131,7 +2143,184 @@ class Player{
return; return;
} }
switch($packet->pid()){ if ($packet->pid() == ProtocolInfo::LOGIN_PACKET) {
if ($this->loggedIn === true) {
return;
}
$this->username = $packet->username;
$this->iusername = strtolower($this->username);
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
$this->PROTOCOL = $packet->PROTOCOL;
if (count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)) {
$this->close("server is full!", false);
return;
}
if ($packet->protocol1 < ProtocolInfo3::CURRENT_PROTOCOL_3 && $packet->protocol1 > ProtocolInfo::CURRENT_PROTOCOL) {
if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
$pk = new LoginStatusPacket;
$pk->status = 1;
$this->directDataPacket($pk);
} else {
$pk = new LoginStatusPacket;
$pk->status = 2;
$this->directDataPacket($pk);
}
$this->close("Incorrect protocol #" . $packet->protocol1, false);
return;
}
if (preg_match('#[^a-zA-Z0-9_]#', $this->username) > 0 || $this->username === "" || $this->iusername === "rcon" || $this->iusername === "console" || $this->iusername === "server" || strlen($this->iusername) > 16) {
$this->close("Bad username", false);
return;
}
if ($this->server->api->handle("player.connect", $this) === false) {
$this->close("Unknown reason", false);
return;
}
if ($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)) {
$this->close("Server is white-listed", false);
return;
} elseif ($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)) {
$this->close("You are banned!", false);
return;
}
$this->loggedIn = true;
if (!isset($this->CID) or $this->CID == null) {
console("[DEBUG] Player " . $this->username . " does not have a CID", true, true, 2);
$this->CID = Utils::readLong(Utils::getRandomBytes(8, false));
}
$u = $this->server->api->player->get($this->iusername, false);
if ($u !== false) {
$u = $this->server->clients[$this->CID];
$u->close("this player already in game");
}
$this->server->api->player->add($this->CID);
if ($this->server->api->handle("player.join", $this) === false) {
$this->close("join cancelled", false);
return;
}
if (!($this->data instanceof Config)) {
$this->close("no config created", false);
return;
}
$this->auth = true;
if (!$this->data->exists("inventory") or ($this->gamemode & 0x01) === 0x01) {
if (($this->gamemode & 0x01) === 0x01) {
$inv = [];
if (($this->gamemode & 0x02) === 0x02) {
foreach (BlockAPI::$creative as $item) {
$inv[] = [0, 0, 1];
}
} else {
foreach (BlockAPI::$creative as $item) {
$inv[] = [$item[0], $item[1], 1];
}
}
}
$this->data->set("inventory", $inv);
}
$this->achievements = $this->data->get("achievements");
$this->data->set("caseusername", $this->username);
$this->inventory = [];
foreach ($this->data->get("inventory") as $slot => $item) {
if (!is_array($item) or count($item) < 3) {
$item = [AIR, 0, 0];
}
$this->inventory[$slot] = BlockAPI::getItem($item[0], $item[1], $item[2]);
}
$this->armor = [];
foreach ($this->data->get("armor") as $slot => $item) {
$this->armor[$slot] = BlockAPI::getItem($item[0], $item[1], $item[0] === 0 ? 0 : 1);
}
$this->data->set("lastIP", $this->ip);
$this->data->set("lastID", $this->clientID);
$this->server->api->player->saveOffline($this->data);
$pk = new LoginStatusPacket;
$pk->status = 0;
$this->dataPacket($pk);
$pk = new StartGamePacket;
$pk->seed = $this->level->getSeed();
$pk->x = $this->data->get("position")["x"];
$pk->y = $this->data->get("position")["y"];
$pk->z = $this->data->get("position")["z"];
$pk->generator = 0;
$pk->gamemode = $this->gamemode & 0x01;
$pk->eid = 0;
$this->dataPacket($pk);
if (($this->gamemode & 0x01) === 0x01) {
$this->slot = 0;
$this->hotbar = [];
} elseif ($this->data->exists("hotbar")) {
$this->hotbar = $this->data->get("hotbar");
$this->slot = $this->hotbar[0];
} else {
$this->slot = 0;
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
}
for ($i = 0; $i < count($this->hotbar); ++$i) {
if ($this->hotbar[$i] > 36) $this->hotbar[$i] = -1; //XXX unsafe?
if ($this->hotbar[$i] < -1) $this->hotbar[$i] = -1;
}
if ($this->data->exists("slot-count")) {
$this->slotCount = $this->data->get("slot-count");
} else {
$this->data->set("slot-count", $this->slotCount);
}
$this->entity = $this->server->api->entity->add($this->level, ENTITY_PLAYER, 0, ["player" => $this]);
$this->eid = $this->entity->eid;
$this->server->query("UPDATE players SET EID = " . $this->eid . " WHERE CID = " . $this->CID . ";");
$this->entity->x = $this->data->get("position")["x"];
$this->entity->y = $this->data->get("position")["y"];
$this->entity->z = $this->data->get("position")["z"];
if (($level = $this->server->api->level->get($this->data->get("spawn")["level"])) !== false) {
$this->spawnPosition = new Position($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"], $level);
$pk = new SetSpawnPositionPacket;
$pk->x = (int) $this->spawnPosition->x;
$pk->y = (int) $this->spawnPosition->y;
$pk->z = (int) $this->spawnPosition->z;
$this->dataPacket($pk);
}
$this->entity->check = false;
$this->entity->setName($this->username);
$this->entity->data["CID"] = $this->CID;
$this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("entity.motion", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("entity.animate", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("entity.event", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("entity.metadata", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("entity.link", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("player.equipment.change", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("player.armor", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("player.pickup", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("tile.container.slot", [$this, "eventHandler"]);
$this->evid[] = $this->server->event("tile.update", [$this, "eventHandler"]);
$this->lastMeasure = microtime(true);
$this->server->schedule(50, [$this, "measureLag"], [], true);
$pk = new SetTimePacket;
$pk->time = $this->level->getTime();
$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) . ")");
return;
}
$internalPid = $packet->getInternalPid();
switch ($internalPid) {
case 0x01: case 0x01:
break; break;
case ProtocolInfo::PONG_PACKET: case ProtocolInfo::PONG_PACKET:
@ -2171,6 +2360,7 @@ class Player{
$this->username = $packet->username; $this->username = $packet->username;
$this->iusername = strtolower($this->username); $this->iusername = strtolower($this->username);
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData]; $this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
$this->PROTOCOL = $packet->PROTOCOL;
if(count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){ if(count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){
$this->close("server is full!", false); $this->close("server is full!", false);
return; return;
@ -2675,6 +2865,73 @@ class Player{
} }
} }
break; break;
case ProtocolInfo::PLACE_BLOCK_PACKET:
if (!($this->entity instanceof Entity)) {
break;
}
$blockVector = new Vector3($packet->x, $packet->y, $packet->z);
if (($this->spawned === false or $this->blocked === true) and $packet->face >= 0 and $packet->face <= 5) {
$target = $this->level->getBlock($blockVector);
$block = $target->getSide($packet->face);
$pk = new UpdateBlockPacket;
$pk->x = $target->x;
$pk->y = $target->y;
$pk->z = $target->z;
$pk->block = $target->getID();
$pk->meta = $target->getMetadata();
$this->dataPacket($pk);
$pk = new UpdateBlockPacket;
$pk->x = $block->x;
$pk->y = $block->y;
$pk->z = $block->z;
$pk->block = $block->getID();
$pk->meta = $block->getMetadata();
$this->dataPacket($pk);
break;
}
$this->craftingItems = [];
$this->toCraft = [];
$packet->eid = $this->eid;
$data = [];
if ($packet->face >= 0 and $packet->face <= 5) {
if ($this->entity->inAction === true) {
$this->entity->inAction = false;
$this->entity->inActionCounter = 0;
$this->entity->updateMetadata();
}
if ($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)) {
} else {
$this->server->api->block->playerBlockAction($this, $blockVector, $packet->face, $packet->x, $packet->y, $packet->z);
break;
}
$target = $this->level->getBlock($blockVector);
$block = $target->getSide($packet->face);
$pk = new UpdateBlockPacket;
$pk->x = $target->x;
$pk->y = $target->y;
$pk->z = $target->z;
$pk->block = $target->getID();
$pk->meta = $target->getMetadata();
$this->dataPacket($pk);
$pk = new UpdateBlockPacket;
$pk->x = $block->x;
$pk->y = $block->y;
$pk->z = $block->z;
$pk->block = $block->getID();
$pk->meta = $block->getMetadata();
$this->dataPacket($pk);
break;
}
break;
case ProtocolInfo::PLAYER_ACTION_PACKET: case ProtocolInfo::PLAYER_ACTION_PACKET:
if($this->spawned === false or $this->blocked === true){ if($this->spawned === false or $this->blocked === true){
break; break;

View file

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

View file

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

View file

@ -98,7 +98,6 @@ require_once(FILE_PATH . "/src/pmf/PMF.php");
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.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/ai/tasks/TaskBase.php");
require_once(FILE_PATH . "/src/entity/Rideable.php"); require_once(FILE_PATH . "/src/entity/Rideable.php");
@ -133,8 +132,6 @@ require_once(FILE_PATH . "/src/world/generator/vanilla/feature/Feature.php");
require_all(FILE_PATH . "src/"); require_all(FILE_PATH . "src/");
$inc = get_included_files(); $inc = get_included_files();
$inc[] = array_shift($inc); $inc[] = array_shift($inc);
$srcdir = realpath(FILE_PATH . "src/"); $srcdir = realpath(FILE_PATH . "src/");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,7 +17,6 @@ class TaskAttackPlayer extends TaskBase
$this->selfCounter = 1; $this->selfCounter = 1;
} }
public function onUpdate(EntityAI $ai) public function onUpdate(EntityAI $ai)
{ {
if(!$this->isTargetValid($ai)){ if(!$this->isTargetValid($ai)){
@ -47,7 +46,6 @@ class TaskAttackPlayer extends TaskBase
} }
public function isTargetValid(EntityAI $ai){ public function isTargetValid(EntityAI $ai){
$e = $ai->entity; $e = $ai->entity;
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){ 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. * Executed when entity starts task. It is recommended to set counter here.
* @param EntityAI $ai
*/ */
abstract function onStart(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. * 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); abstract function onUpdate(EntityAI $ai);
/** /**
* On task end. * On task end.
* @param EntityAI $ai
*/ */
abstract function onEnd(EntityAI $ai); abstract function onEnd(EntityAI $ai);
/** /**
* Can start the task * Can start the task
* @param EntityAI $ai
*/ */
abstract function canBeExecuted(EntityAI $ai); abstract function canBeExecuted(EntityAI $ai);

View file

@ -29,7 +29,6 @@ class TaskMate extends TaskBase
return; return;
} }
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed()); $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); $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; 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; 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; $this->seenTicks = 0;
} }
$dist = $ai->entity->distanceSquared($ai->entity->target); $dist = $ai->entity->distanceSquared($ai->entity->target);
if($dist > 100 || $this->seenTicks < 20){ if($dist > 100 || $this->seenTicks < 20){
@ -89,7 +88,6 @@ class TaskRangedAttack extends \TaskBase
} }
} }
public function isTargetValid(EntityAI $ai){ public function isTargetValid(EntityAI $ai){
$e = $ai->entity; $e = $ai->entity;
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){ if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
@ -123,7 +121,6 @@ class TaskRangedAttack extends \TaskBase
return false; return false;
} }
public function canBeExecuted(EntityAI $ai) public function canBeExecuted(EntityAI $ai)
{ {
return $this->tryTargeting($ai); return $this->tryTargeting($ai);

View file

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

View file

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

View file

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

View file

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

View file

@ -1,8 +1,9 @@
<?php <?php
class Spider extends Monster{ class Spider extends Monster{
const TYPE = MOB_SPIDER; 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); $this->setSize(1.4, 0.9);
parent::__construct($level, $eid, $class, $type, $data); parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false); $this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false);

View file

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

View file

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

View file

@ -1,6 +1,5 @@
<?php <?php
/** /**
* Plugins that create events must use this class as the base * 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; private $packet;
public function __construct(Packet $packet){ public function __construct(Packet $packet){
$this->packet = $packet; $this->packet = $packet;
} }

View file

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

View file

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

View file

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

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 $face
* @param int $fx * @param int $fx
* @param int $fy * @param int $fy

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

@ -9,9 +9,9 @@ class FarmlandBlock extends TransparentBlock{
$this->material = Material::$dirt; $this->material = Material::$dirt;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return [
array(DIRT, 0, 1), [DIRT, 0, 1],
); ];
} }
public function hasCrops(){ public function hasCrops(){
//TODO vanilla 0.8.1 detection method //TODO vanilla 0.8.1 detection method

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,11 +5,11 @@ class TallGrassBlock extends FlowableBlock{
public function __construct($meta = 1){ public function __construct($meta = 1){
parent::__construct(TALL_GRASS, $meta, "Tall Grass"); parent::__construct(TALL_GRASS, $meta, "Tall Grass");
$this->isReplaceable = true; $this->isReplaceable = true;
$names = array( $names = [
0 => "Dead Shrub", 0 => "Dead Shrub",
1 => "Tall Grass", 1 => "Tall Grass",
2 => "Fern", 2 => "Fern",
); ];
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 0; $this->hardness = 0;
$this->breakTime = 0; $this->breakTime = 0;
@ -29,9 +29,9 @@ class TallGrassBlock extends FlowableBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
$drops = array(); $drops = [];
if($item->isShears()) $drops[] = array($this->id, $this->meta & 0x03, 1); if($item->isShears()) $drops[] = [$this->id, $this->meta & 0x03, 1];
elseif(Utils::chance(15)) $drops[] = array(WHEAT_SEEDS, 0, 1); elseif(Utils::chance(15)) $drops[] = [WHEAT_SEEDS, 0, 1];
return $drops; return $drops;
} }

View file

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

View file

@ -13,12 +13,12 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array( $faces = [
0 => 4, 0 => 4,
1 => 2, 1 => 2,
2 => 5, 2 => 5,
3 => 3, 3 => 3,
); ];
$this->meta = $faces[$player->entity->getDirection()]; $this->meta = $faces[$player->entity->getDirection()];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
@ -39,13 +39,13 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
if($t !== false){ if($t !== false){
$furnace = $t; $furnace = $t;
}else{ }else{
$furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, array( $furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, [
"Items" => array(), "Items" => [],
"id" => TILE_FURNACE, "id" => TILE_FURNACE,
"x" => $this->x, "x" => $this->x,
"y" => $this->y, "y" => $this->y,
"z" => $this->z "z" => $this->z
)); ]);
} }
if(($player->gamemode & 0x01) === 0x01){ if(($player->gamemode & 0x01) === 0x01){
@ -71,16 +71,16 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
$drops = array(); $drops = [];
if($item->getPickaxeLevel() >= 1){ if($item->getPickaxeLevel() >= 1){
$drops[] = array(FURNACE, 0, 1); $drops[] = [FURNACE, 0, 1];
} }
$t = ServerAPI::request()->api->tile->get($this); $t = ServerAPI::request()->api->tile->get($this);
if($t !== false and $t->class === TILE_FURNACE){ if($t !== false and $t->class === TILE_FURNACE){
for($s = 0; $s < FURNACE_SLOTS; ++$s){ for($s = 0; $s < FURNACE_SLOTS; ++$s){
$slot = $t->getSlot($s); $slot = $t->getSlot($s);
if($slot->getID() > AIR and $slot->count > 0){ 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

@ -11,8 +11,8 @@ class ClayBlock extends SolidBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return [
array(CLAY, 0, 4), [CLAY, 0, 4],
); ];
} }
} }

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ class DoubleSlabBlock extends SolidBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(DOUBLE_SLAB, $meta, "Double Slab"); parent::__construct(DOUBLE_SLAB, $meta, "Double Slab");
$names = array( $names = [
0 => "Stone", 0 => "Stone",
1 => "Sandstone", 1 => "Sandstone",
2 => "Wooden", 2 => "Wooden",
@ -13,7 +13,7 @@ class DoubleSlabBlock extends SolidBlock{
5 => "Stone Brick", 5 => "Stone Brick",
6 => "Quartz", 6 => "Quartz",
7 => "Smooth Stone", 7 => "Smooth Stone",
); ];
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab"; $this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
$this->hardness = 30; $this->hardness = 30;
$this->breakTime = 2; $this->breakTime = 2;
@ -37,11 +37,11 @@ class DoubleSlabBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){ if($item->getPickaxeLevel() >= 1){
return array( return [
array(SLAB, $this->meta & 0x07, 2), [SLAB, $this->meta & 0x07, 2],
); ];
}else{ }else{
return array(); return [];
} }
} }

View file

@ -4,12 +4,12 @@ class DoubleWoodSlabBlock extends SolidBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab"); parent::__construct(DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab");
$names = array( $names = [
0 => "Oak", 0 => "Oak",
1 => "Spruce", 1 => "Spruce",
2 => "Birch", 2 => "Birch",
3 => "Jungle", 3 => "Jungle",
); ];
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; $this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
$this->hardness = 30; $this->hardness = 30;
$this->breakTime = 2; $this->breakTime = 2;
@ -34,9 +34,9 @@ class DoubleWoodSlabBlock extends SolidBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return [
array(WOOD_SLAB, $this->meta & 0x07, 2), [WOOD_SLAB, $this->meta & 0x07, 2],
); ];
} }
} }

View file

@ -4,7 +4,6 @@
require_once("BurningFurnaceBlock.php"); require_once("BurningFurnaceBlock.php");
/***REM_END***/ /***REM_END***/
class FurnaceBlock extends BurningFurnaceBlock{ class FurnaceBlock extends BurningFurnaceBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){

View file

@ -10,7 +10,7 @@ class GlassBlock extends TransparentBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array(); return [];
} }
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){

View file

@ -16,9 +16,9 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return [
array(GLOWSTONE_DUST, 0, mt_rand(2, 4)), [GLOWSTONE_DUST, 0, mt_rand(2, 4)],
); ];
} }
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){

View file

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

View file

@ -11,14 +11,14 @@ class HayBaleBlock extends SolidBlock{
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array( $faces = [
0 => 0, 0 => 0,
1 => 0, 1 => 0,
2 => 0b1000, 2 => 0b1000,
3 => 0b1000, 3 => 0b1000,
4 => 0b0100, 4 => 0b0100,
5 => 0b0100, 5 => 0b0100,
); ];
$this->meta = ($this->meta & 0x03) | $faces[$face]; $this->meta = ($this->meta & 0x03) | $faces[$face];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
@ -26,9 +26,9 @@ class HayBaleBlock extends SolidBlock{
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return [
array($this->id, 0, 1), [$this->id, 0, 1],
); ];
} }
} }

View file

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

View file

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

View file

@ -9,7 +9,6 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
3 => 0, 3 => 0,
]; ];
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(LIT_PUMPKIN, $meta, "Jack o'Lantern"); parent::__construct(LIT_PUMPKIN, $meta, "Jack o'Lantern");
$this->hardness = 5; $this->hardness = 5;
@ -39,5 +38,4 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
]; ];
} }
} }

View file

@ -10,9 +10,9 @@ class MelonBlock extends TransparentBlock{
$this->lightBlock = 255; $this->lightBlock = 255;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return [
array(MELON_SLICE, 0, mt_rand(3, 7)), [MELON_SLICE, 0, mt_rand(3, 7)],
); ];
} }
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){

View file

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

View file

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

View file

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

View file

@ -4,12 +4,12 @@ class PlanksBlock extends SolidBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(PLANKS, $meta, "Wooden Planks"); parent::__construct(PLANKS, $meta, "Wooden Planks");
$names = array( $names = [
WoodBlock::OAK => "Oak Wooden Planks", WoodBlock::OAK => "Oak Wooden Planks",
WoodBlock::SPRUCE => "Spruce Wooden Planks", WoodBlock::SPRUCE => "Spruce Wooden Planks",
WoodBlock::BIRCH => "Birch Wooden Planks", WoodBlock::BIRCH => "Birch Wooden Planks",
WoodBlock::JUNGLE => "Jungle Wooden Planks", WoodBlock::JUNGLE => "Jungle Wooden Planks",
); ];
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 15; $this->hardness = 15;
$this->breakTime = 2; $this->breakTime = 2;

View file

@ -4,12 +4,12 @@ class QuartzBlock extends SolidBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(QUARTZ_BLOCK, $meta, "Quartz Block"); parent::__construct(QUARTZ_BLOCK, $meta, "Quartz Block");
$names = array( $names = [
0 => "Quartz Block", 0 => "Quartz Block",
1 => "Chiseled Quartz Block", 1 => "Chiseled Quartz Block",
2 => "Quartz Pillar", 2 => "Quartz Pillar",
3 => "Quartz Pillar", 3 => "Quartz Pillar",
); ];
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->breakTime = 0.8; $this->breakTime = 0.8;
$this->hardness = 4; $this->hardness = 4;
@ -33,11 +33,11 @@ class QuartzBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){ if($item->getPickaxeLevel() >= 1){
return array( return [
array(QUARTZ_BLOCK, $this->meta & 0x03, 1), [QUARTZ_BLOCK, $this->meta & 0x03, 1],
); ];
}else{ }else{
return array(); return [];
} }
} }
} }

View file

@ -4,11 +4,11 @@ class SandstoneBlock extends SolidBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(SANDSTONE, $meta, "Sandstone"); parent::__construct(SANDSTONE, $meta, "Sandstone");
$names = array( $names = [
0 => "Sandstone", 0 => "Sandstone",
1 => "Chiseled Sandstone", 1 => "Chiseled Sandstone",
2 => "Smooth Sandstone", 2 => "Smooth Sandstone",
); ];
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 4; $this->hardness = 4;
$this->breakTime = 0.8; $this->breakTime = 0.8;
@ -32,11 +32,11 @@ class SandstoneBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){ if($item->getPickaxeLevel() >= 1){
return array( return [
array(SANDSTONE, $this->meta & 0x03, 1), [SANDSTONE, $this->meta & 0x03, 1],
); ];
}else{ }else{
return array(); return [];
} }
} }

View file

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

View file

@ -4,12 +4,12 @@ class StoneBricksBlock extends SolidBlock{
public static $blockID; public static $blockID;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(STONE_BRICKS, $meta, "Stone Bricks"); parent::__construct(STONE_BRICKS, $meta, "Stone Bricks");
$names = array( $names = [
0 => "Stone Bricks", 0 => "Stone Bricks",
1 => "Mossy Stone Bricks", 1 => "Mossy Stone Bricks",
2 => "Cracked Stone Bricks", 2 => "Cracked Stone Bricks",
3 => "Chiseled Stone Bricks", 3 => "Chiseled Stone Bricks",
); ];
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 30; $this->hardness = 30;
$this->breakTime = 1.5; $this->breakTime = 1.5;
@ -33,11 +33,11 @@ class StoneBricksBlock extends SolidBlock{
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){ if($item->getPickaxeLevel() >= 1){
return array( return [
array(STONE_BRICKS, $this->meta & 0x03, 1), [STONE_BRICKS, $this->meta & 0x03, 1],
); ];
}else{ }else{
return array(); return [];
} }
} }

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