mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 21:19:44 +00:00
commit
e847151e40
364 changed files with 4746 additions and 3546 deletions
27
.github/workflows/main.yml
vendored
Normal file
27
.github/workflows/main.yml
vendored
Normal 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
3
.gitignore
vendored
|
|
@ -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
36
.php-cs-fixer.php
Normal 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());
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ class AchievementAPI{
|
||||||
* Add an achievement
|
* Add an achievement
|
||||||
* @param string $achievementId
|
* @param string $achievementId
|
||||||
* @param string $achievementName
|
* @param string $achievementName
|
||||||
* @param array $requires
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function addAchievement($achievementId, $achievementName, array $requires = []){
|
public static function addAchievement($achievementId, $achievementName, array $requires = []){
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,6 @@ class BlockAPI{
|
||||||
return $this->cancelAction($target, $player, false);
|
return $this->cancelAction($target, $player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
|
if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
|
||||||
foreach($drops as $drop){
|
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]));
|
$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;
|
return $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
||||||
|
|
||||||
if($type == BLOCK_UPDATE_NORMAL){
|
if($type == BLOCK_UPDATE_NORMAL){
|
||||||
|
|
@ -644,4 +641,31 @@ class BlockAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方块/物品id转换,防止新版本影响旧版本视觉效果
|
||||||
|
*/
|
||||||
|
public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId) : int{
|
||||||
|
if ($protocolId >= ProtocolInfo12::CURRENT_PROTOCOL_12) {
|
||||||
|
return $itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$idMap = [ //default for protocol < 12
|
||||||
|
LIT_PUMPKIN => MELON_BLOCK, //block
|
||||||
|
PUMPKIN_SEEDS => MELON_SEEDS, //item
|
||||||
|
PUMPKIN_PIE => BREAD, //item
|
||||||
|
BEETROOT => BREAD, //item
|
||||||
|
BEETROOT_SEEDS => SEEDS, //item
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($protocolId < ProtocolInfo9::CURRENT_PROTOCOL_9) {
|
||||||
|
$idMap += [
|
||||||
|
NETHERRACK => OBSIDIAN, //block
|
||||||
|
NETHER_BRICK => BRICK, //item
|
||||||
|
NETHER_QUARTZ => BRICK, //item
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $idMap[$itemId] ?? $itemId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,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 = [
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ class EntityAPI{
|
||||||
$this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
|
$this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function commandHandler($cmd, $args, $issuer, $alias){
|
public function commandHandler($cmd, $args, $issuer, $alias){
|
||||||
$mob = [
|
$mob = [
|
||||||
"chicken" => 10,
|
"chicken" => 10,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,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");
|
||||||
|
|
|
||||||
|
|
@ -327,6 +327,17 @@ class PlayerAPI{
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function decodeProtocol($ip){
|
||||||
|
foreach(ServerAPI::request()->clients as $p) {
|
||||||
|
if($p->ip == $ip){
|
||||||
|
return $p->PROTOCOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function add($CID){
|
public function add($CID){
|
||||||
if(isset($this->server->clients[$CID])){
|
if(isset($this->server->clients[$CID])){
|
||||||
$player = $this->server->clients[$CID];
|
$player = $this->server->clients[$CID];
|
||||||
|
|
|
||||||
|
|
@ -312,4 +312,3 @@ class RequiredPluginEntry{ //Use this as object of requirements array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,5 +175,4 @@ class TimeAPI{
|
||||||
return $this->set("sunset");
|
return $this->set("sunset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class Deprecation{
|
class Deprecation{
|
||||||
|
|
||||||
public static $events = [
|
public static $events = [
|
||||||
|
|
|
||||||
296
src/Player.php
296
src/Player.php
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class Player{
|
class Player{
|
||||||
|
|
||||||
public static $smallChunks = false, $experimentalHotbar = false;
|
public static $smallChunks = false, $experimentalHotbar = false;
|
||||||
|
|
@ -84,6 +83,8 @@ class Player{
|
||||||
public $blockUpdateQueue;
|
public $blockUpdateQueue;
|
||||||
public $blockUpdateQueueLength = 0;
|
public $blockUpdateQueueLength = 0;
|
||||||
|
|
||||||
|
public $PROTOCOL = ProtocolInfo::CURRENT_PROTOCOL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent by a client while it is linked to some entity.
|
* Sent by a client while it is linked to some entity.
|
||||||
* @var boolean $isJumping
|
* @var boolean $isJumping
|
||||||
|
|
@ -145,7 +146,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -181,7 +181,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
|
||||||
* @param float|boolean $yaw
|
* @param float|boolean $yaw
|
||||||
* @param float|boolean $pitch
|
* @param float|boolean $pitch
|
||||||
* @param float|boolean $terrain
|
* @param float|boolean $terrain
|
||||||
|
|
@ -346,8 +345,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $id
|
|
||||||
* @param array $data
|
|
||||||
*
|
*
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
|
|
@ -360,7 +357,16 @@ class Player{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(PacketPool::isPacketExist($packet->pid(), $this->PROTOCOL) != true){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
|
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
|
if($packet->pid() == 163 or $packet->pid() == 164 && $this->PROTOCOL < ProtocolInfo8::CURRENT_PROTOCOL_8){
|
||||||
|
return;
|
||||||
|
}
|
||||||
$len = strlen($packet->buffer) + 1;
|
$len = strlen($packet->buffer) + 1;
|
||||||
$MTU = $this->MTU - 24;
|
$MTU = $this->MTU - 24;
|
||||||
if($len > $MTU){
|
if($len > $MTU){
|
||||||
|
|
@ -483,7 +489,6 @@ class Player{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $slot
|
* @param integer $slot
|
||||||
* @param Item $item
|
|
||||||
* @param boolean $send
|
* @param boolean $send
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
@ -693,9 +698,6 @@ class Player{
|
||||||
$this->server->schedule(MAX_CHUNK_RATE, [$this, "getNextChunk"], $world);
|
$this->server->schedule(MAX_CHUNK_RATE, [$this, "getNextChunk"], $world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Vector3 $pos
|
|
||||||
*/
|
|
||||||
public function setSpawn(Vector3 $pos){
|
public function setSpawn(Vector3 $pos){
|
||||||
if(!($pos instanceof Position)){
|
if(!($pos instanceof Position)){
|
||||||
$level = $this->entity->level;
|
$level = $this->entity->level;
|
||||||
|
|
@ -731,9 +733,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $type
|
|
||||||
* @param $damage
|
|
||||||
* @param $count
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -946,8 +945,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $type
|
|
||||||
* @param $damage
|
|
||||||
* @param integer $count
|
* @param integer $count
|
||||||
* @param boolean $send
|
* @param boolean $send
|
||||||
*
|
*
|
||||||
|
|
@ -1260,6 +1257,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);
|
||||||
}
|
}
|
||||||
|
|
@ -1325,6 +1323,7 @@ class Player{
|
||||||
$packet->z = $z;
|
$packet->z = $z;
|
||||||
$packet->block = $id;
|
$packet->block = $id;
|
||||||
$packet->meta = $meta;
|
$packet->meta = $meta;
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
|
|
||||||
$len = 1 + strlen($packet->buffer);
|
$len = 1 + strlen($packet->buffer);
|
||||||
|
|
@ -1357,6 +1356,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 += 1 + strlen($motion->buffer);
|
$len += 1 + strlen($motion->buffer);
|
||||||
++$packets;
|
++$packets;
|
||||||
|
|
@ -1378,6 +1378,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();
|
||||||
|
|
@ -1387,16 +1388,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) + 1;
|
$len += strlen($move->buffer) + 1;
|
||||||
++$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 = $e->eid;
|
$headyaw->eid = $e->eid;
|
||||||
$headyaw->yaw = $e->headYaw;
|
$headyaw->yaw = $e->headYaw;
|
||||||
|
$headyaw->PROTOCOL = $this->PROTOCOL;
|
||||||
$headyaw->encode();
|
$headyaw->encode();
|
||||||
$len += strlen($headyaw->buffer) + 1;
|
$len += strlen($headyaw->buffer) + 1;
|
||||||
++$packets;
|
++$packets;
|
||||||
|
|
@ -1522,6 +1526,7 @@ class Player{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
$pk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
$pk = new RakNetPacket(RakNetInfo::DATA_PACKET_0);
|
||||||
$pk->data[] = $packet;
|
$pk->data[] = $packet;
|
||||||
|
|
@ -1542,7 +1547,6 @@ class Player{
|
||||||
$this->entity->setHealth(min(20, $this->entity->health + 1), "regeneration");
|
$this->entity->setHealth(min(20, $this->entity->health + 1), "regeneration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendPing() {
|
public function sendPing() {
|
||||||
|
|
@ -1555,7 +1559,8 @@ class Player{
|
||||||
return $this->lastPing;
|
return $this->lastPing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleDataPacket(RakNetDataPacket $packet){
|
public function handleDataPacket(RakNetDataPacket $packet)
|
||||||
|
{
|
||||||
if ($this->connected === false) {
|
if ($this->connected === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1564,7 +1569,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:
|
||||||
|
|
@ -1604,6 +1786,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;
|
||||||
|
|
@ -1696,7 +1879,6 @@ class Player{
|
||||||
|
|
||||||
$this->server->api->player->saveOffline($this->data);
|
$this->server->api->player->saveOffline($this->data);
|
||||||
|
|
||||||
|
|
||||||
$pk = new LoginStatusPacket;
|
$pk = new LoginStatusPacket;
|
||||||
$pk->status = 0;
|
$pk->status = 0;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
@ -1712,6 +1894,7 @@ class Player{
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
if (($this->gamemode & 0x01) === 0x01) {
|
if (($this->gamemode & 0x01) === 0x01) {
|
||||||
|
|
||||||
$this->slot = 0;
|
$this->slot = 0;
|
||||||
$this->hotbar = [];
|
$this->hotbar = [];
|
||||||
} elseif ($this->data->exists("hotbar")) {
|
} elseif ($this->data->exists("hotbar")) {
|
||||||
|
|
@ -1768,7 +1951,6 @@ class Player{
|
||||||
$pk->started = !$this->level->isTimeStopped();
|
$pk->started = !$this->level->isTimeStopped();
|
||||||
$this->dataPacket($pk);
|
$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) . ")");
|
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;
|
break;
|
||||||
case ProtocolInfo::READY_PACKET:
|
case ProtocolInfo::READY_PACKET:
|
||||||
|
|
@ -1873,7 +2055,6 @@ class Player{
|
||||||
$packet->slot -= 9;
|
$packet->slot -= 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (($this->gamemode & 0x01) === SURVIVAL) {
|
if (($this->gamemode & 0x01) === SURVIVAL) {
|
||||||
$data["item"] = $this->getSlot($packet->slot);
|
$data["item"] = $this->getSlot($packet->slot);
|
||||||
if (!($data["item"] instanceof Item)) {
|
if (!($data["item"] instanceof Item)) {
|
||||||
|
|
@ -2095,6 +2276,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;
|
||||||
|
|
@ -2267,7 +2515,6 @@ class Player{
|
||||||
$this->craftingItems = [];
|
$this->craftingItems = [];
|
||||||
$this->toCraft = [];
|
$this->toCraft = [];
|
||||||
$this->craftingType = CraftingRecipes::TYPE_INVENTORY;
|
$this->craftingType = CraftingRecipes::TYPE_INVENTORY;
|
||||||
|
|
||||||
$this->checkSpawnPosition();
|
$this->checkSpawnPosition();
|
||||||
$this->teleport($this->spawnPosition, false, false, true, false);
|
$this->teleport($this->spawnPosition, false, false, true, false);
|
||||||
|
|
||||||
|
|
@ -2354,15 +2601,14 @@ class Player{
|
||||||
foreach ($this->inventory as $slot => $item) {
|
foreach ($this->inventory as $slot => $item) {
|
||||||
if ($item->getID() == 0) goto inv_desync_on_drop;
|
if ($item->getID() == 0) goto inv_desync_on_drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addCraftingResult(-1, $prevItem->getID(), $prevItem->getMetadata(), $prevItem->count);
|
$this->addCraftingResult(-1, $prevItem->getID(), $prevItem->getMetadata(), $prevItem->count);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
inv_desync_on_drop:
|
inv_desync_on_drop:
|
||||||
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
||||||
$sendOnDrop = true;
|
$sendOnDrop = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->craftingItems = [];
|
$this->craftingItems = [];
|
||||||
$this->toCraft = [];
|
$this->toCraft = [];
|
||||||
|
|
@ -2490,7 +2736,6 @@ class Player{
|
||||||
$this->addCraftingIngridient($packet->slot, $slot->getID(), $slot->getMetadata(), $slot->count);
|
$this->addCraftingIngridient($packet->slot, $slot->getID(), $slot->getMetadata(), $slot->count);
|
||||||
$this->addCraftingResult($packet->slot, $citem->getID(), $citem->getMetadata(), $citem->count);
|
$this->addCraftingResult($packet->slot, $citem->getID(), $citem->getMetadata(), $citem->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$this->toCraft = [];
|
$this->toCraft = [];
|
||||||
$this->craftingItems = [];
|
$this->craftingItems = [];
|
||||||
|
|
@ -2532,7 +2777,6 @@ class Player{
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->getID() !== AIR and $slot->getID() == $item->getID()) {
|
if ($item->getID() !== AIR and $slot->getID() == $item->getID()) {
|
||||||
if ($slot->count < $item->count) {
|
if ($slot->count < $item->count) {
|
||||||
if ($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false) {
|
if ($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ class PocketMinecraftServer{
|
||||||
|
|
||||||
public static $SAVE_PLAYER_DATA = true;
|
public static $SAVE_PLAYER_DATA = true;
|
||||||
|
|
||||||
|
|
||||||
private function load(){
|
private function load(){
|
||||||
global $dolog;
|
global $dolog;
|
||||||
/*if(defined("DEBUG") and DEBUG >= 0){
|
/*if(defined("DEBUG") and DEBUG >= 0){
|
||||||
|
|
@ -68,6 +67,7 @@ class PocketMinecraftServer{
|
||||||
$this->saveEnabled = true;
|
$this->saveEnabled = true;
|
||||||
$this->tickMeasure = array_fill(0, 40, 0);
|
$this->tickMeasure = array_fill(0, 40, 0);
|
||||||
$this->setType("normal");
|
$this->setType("normal");
|
||||||
|
PacketPool::init();
|
||||||
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, $this->serverip);
|
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, $this->serverip);
|
||||||
$this->stop = false;
|
$this->stop = false;
|
||||||
$this->ticks = 0;
|
$this->ticks = 0;
|
||||||
|
|
@ -348,7 +348,6 @@ class PocketMinecraftServer{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $event
|
* @param string $event
|
||||||
* @param callable $callable
|
|
||||||
* @param integer $priority
|
* @param integer $priority
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
@ -525,7 +524,6 @@ class PocketMinecraftServer{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function packetHandler(Packet $packet){
|
public function packetHandler(Packet $packet){
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
function parseOffset(string $offset) : string|false{
|
function parseOffset(string $offset) : string|false{
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ define("SOUL_SAND", 88);
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -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/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");
|
||||||
|
|
@ -138,8 +137,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/");
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
||||||
public $age;
|
public $age;
|
||||||
public $loveTimeout;
|
public $loveTimeout;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public $closestPlayerThatCanFeedEID = false;
|
public $closestPlayerThatCanFeedEID = false;
|
||||||
public $closestPlayerThatCanFeedDist = INF;
|
public $closestPlayerThatCanFeedDist = INF;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ abstract class Creature extends Living{
|
||||||
public $closestPlayerEID = false;
|
public $closestPlayerEID = false;
|
||||||
public $closestPlayerDist = INF;
|
public $closestPlayerDist = INF;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
$this->inPanic = false; //force for now
|
$this->inPanic = false; //force for now
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
|
|
@ -21,7 +20,6 @@ abstract class Creature extends Living{
|
||||||
return parent::update($now);
|
return parent::update($now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function handlePrePlayerSearcher(){
|
public function handlePrePlayerSearcher(){
|
||||||
parent::handlePrePlayerSearcher();
|
parent::handlePrePlayerSearcher();
|
||||||
if($this->closestPlayerEID !== false){
|
if($this->closestPlayerEID !== false){
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class Entity extends Position
|
||||||
public $fallStart;
|
public $fallStart;
|
||||||
private $state;
|
private $state;
|
||||||
private $tickCounter;
|
private $tickCounter;
|
||||||
private $speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
|
private $speedMeasure = [0, 0, 0, 0, 0, 0, 0];
|
||||||
public $server;
|
public $server;
|
||||||
private $isStatic;
|
private $isStatic;
|
||||||
public $level;
|
public $level;
|
||||||
|
|
@ -131,7 +131,7 @@ class Entity extends Position
|
||||||
$this->status = 0;
|
$this->status = 0;
|
||||||
$this->health = 20;
|
$this->health = 20;
|
||||||
$this->hasGravity = false;
|
$this->hasGravity = false;
|
||||||
$this->dmgcounter = array(0, 0, 0);
|
$this->dmgcounter = [0, 0, 0];
|
||||||
$this->air = $this->maxAir;
|
$this->air = $this->maxAir;
|
||||||
$this->fire = 0;
|
$this->fire = 0;
|
||||||
$this->crouched = false;
|
$this->crouched = false;
|
||||||
|
|
@ -154,14 +154,14 @@ class Entity extends Position
|
||||||
$this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"] : 0;
|
$this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"] : 0;
|
||||||
$this->headYaw = $this->data["headYaw"] ?? $this->yaw;
|
$this->headYaw = $this->data["headYaw"] ?? $this->yaw;
|
||||||
$this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"] : 0;
|
$this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"] : 0;
|
||||||
$this->position = array(
|
$this->position = [
|
||||||
"level" => $this->level,
|
"level" => $this->level,
|
||||||
"x" => &$this->x,
|
"x" => &$this->x,
|
||||||
"y" => &$this->y,
|
"y" => &$this->y,
|
||||||
"z" => &$this->z,
|
"z" => &$this->z,
|
||||||
"yaw" => &$this->yaw,
|
"yaw" => &$this->yaw,
|
||||||
"pitch" => &$this->pitch
|
"pitch" => &$this->pitch
|
||||||
);
|
];
|
||||||
$this->moveTime = 0;
|
$this->moveTime = 0;
|
||||||
$this->lookTime = 0;
|
$this->lookTime = 0;
|
||||||
$this->onGround = false;
|
$this->onGround = false;
|
||||||
|
|
@ -349,22 +349,22 @@ class Entity extends Position
|
||||||
$slot = $this->player->getSlot($i);
|
$slot = $this->player->getSlot($i);
|
||||||
$this->player->setSlot($i, BlockAPI::getItem(AIR, 0, 0));
|
$this->player->setSlot($i, BlockAPI::getItem(AIR, 0, 0));
|
||||||
if($slot->getID() !== AIR and $slot->count > 0){
|
if($slot->getID() !== AIR and $slot->count > 0){
|
||||||
$inv[] = array(
|
$inv[] = [
|
||||||
$slot->getID(),
|
$slot->getID(),
|
||||||
$slot->getMetadata(),
|
$slot->getMetadata(),
|
||||||
$slot->count
|
$slot->count
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for($re = 0; $re < 4; $re++){
|
for($re = 0; $re < 4; $re++){
|
||||||
$slot = $this->player->getArmor($re);
|
$slot = $this->player->getArmor($re);
|
||||||
$this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0));
|
$this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0));
|
||||||
if($slot->getID() !== AIR and $slot->count > 0){
|
if($slot->getID() !== AIR and $slot->count > 0){
|
||||||
$inv[] = array(
|
$inv[] = [
|
||||||
$slot->getID(),
|
$slot->getID(),
|
||||||
$slot->getMetadata(),
|
$slot->getMetadata(),
|
||||||
$slot->count
|
$slot->count
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $inv;
|
return $inv;
|
||||||
|
|
@ -427,14 +427,14 @@ class Entity extends Position
|
||||||
foreach($this->server->api->entity->getRadius($this, 2, false) as $item){
|
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->class === ENTITY_ITEM && !$item->closed && $item->spawntime > 0 && $item->delayBeforePickup <= 0){
|
||||||
if($item->boundingBox->intersectsWith($myBB)){
|
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,
|
"eid" => $this->player->eid,
|
||||||
"player" => $this->player,
|
"player" => $this->player,
|
||||||
"entity" => $item,
|
"entity" => $item,
|
||||||
"block" => $item->itemID,
|
"block" => $item->itemID,
|
||||||
"meta" => $item->meta,
|
"meta" => $item->meta,
|
||||||
"target" => $item->eid
|
"target" => $item->eid
|
||||||
)) !== false){
|
]) !== false){
|
||||||
$item->close();
|
$item->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -589,14 +589,12 @@ class Entity extends Position
|
||||||
$this->speedX = $this->speedY = $this->speedZ = 0;
|
$this->speedX = $this->speedY = $this->speedZ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$savedDX = $dx;
|
$savedDX = $dx;
|
||||||
$savedDY = $dy;
|
$savedDY = $dy;
|
||||||
$savedDZ = $dz;
|
$savedDZ = $dz;
|
||||||
|
|
||||||
$oldBB = clone $this->boundingBox;
|
$oldBB = clone $this->boundingBox;
|
||||||
|
|
||||||
|
|
||||||
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
||||||
foreach($aaBBs as $bb){
|
foreach($aaBBs as $bb){
|
||||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||||
|
|
@ -613,7 +611,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
$this->boundingBox->offset(0, 0, $dz);
|
$this->boundingBox->offset(0, 0, $dz);
|
||||||
|
|
||||||
|
|
||||||
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
|
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
|
||||||
|
|
||||||
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
||||||
|
|
@ -665,13 +662,10 @@ class Entity extends Position
|
||||||
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
|
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
|
||||||
$this->updateFallState($this->speedY);
|
$this->updateFallState($this->speedY);
|
||||||
|
|
||||||
|
|
||||||
if($savedDX != $dx) $this->speedX = 0;
|
if($savedDX != $dx) $this->speedX = 0;
|
||||||
if($savedDY != $dy) $this->speedY = 0;
|
if($savedDY != $dy) $this->speedY = 0;
|
||||||
if($savedDZ != $dz) $this->speedZ = 0;
|
if($savedDZ != $dz) $this->speedZ = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO more stuff -> onEntityWalking
|
//TODO more stuff -> onEntityWalking
|
||||||
|
|
||||||
$this->doBlocksCollision();
|
$this->doBlocksCollision();
|
||||||
|
|
@ -840,7 +834,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->isOnLadder()){
|
if($this->isOnLadder()){
|
||||||
$this->fallDistance = 0;
|
$this->fallDistance = 0;
|
||||||
$this->notOnGroundTicks = 0;
|
$this->notOnGroundTicks = 0;
|
||||||
|
|
@ -880,7 +873,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->counterUpdate();
|
$this->counterUpdate();
|
||||||
|
|
||||||
if($this->isPlayer()){
|
if($this->isPlayer()){
|
||||||
|
|
@ -1179,7 +1171,6 @@ class Entity extends Position
|
||||||
--$this->idleTime;
|
--$this->idleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->inAction){
|
if($this->inAction){
|
||||||
++$this->inActionCounter;
|
++$this->inActionCounter;
|
||||||
}
|
}
|
||||||
|
|
@ -1283,7 +1274,7 @@ class Entity extends Position
|
||||||
|
|
||||||
public function resetSpeed()
|
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()
|
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]);
|
$this->server->api->dhandle("entity.link", ["rider" => $this->eid, "riding" => $e->eid, "type" => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPlayer()
|
public function isPlayer()
|
||||||
|
|
@ -1557,12 +1547,12 @@ class Entity extends Position
|
||||||
$harm = true;
|
$harm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->server->api->dhandle("entity.health.change", array(
|
if($this->server->api->dhandle("entity.health.change", [
|
||||||
"entity" => $this,
|
"entity" => $this,
|
||||||
"eid" => $this->eid,
|
"eid" => $this->eid,
|
||||||
"health" => $health,
|
"health" => $health,
|
||||||
"cause" => $cause
|
"cause" => $cause
|
||||||
)) !== false or $force === true){
|
]) !== false or $force === true){
|
||||||
$this->health = min(127, max(-127, $health));
|
$this->health = min(127, max(-127, $health));
|
||||||
if($harm === true && $allowHarm){
|
if($harm === true && $allowHarm){
|
||||||
$pk = new EntityEventPacket;
|
$pk = new EntityEventPacket;
|
||||||
|
|
@ -1703,7 +1693,6 @@ class Entity extends Position
|
||||||
throw new Exception("Use getHeightOf or getWidthOf method instead of this.");
|
throw new Exception("Use getHeightOf or getWidthOf method instead of this.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link getHeight} or {@link getWidth} instead
|
* @deprecated Use {@link getHeight} or {@link getWidth} instead
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Monster extends Creature{
|
class Monster extends Creature{
|
||||||
|
|
||||||
public $closestPlayerToAttackEID = false;
|
public $closestPlayerToAttackEID = false;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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){
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ class TaskTempt extends TaskBase
|
||||||
$ai->mobController->headYawIsYaw = true;
|
$ai->mobController->headYawIsYaw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTargetValid(EntityAI $ai){
|
public function isTargetValid(EntityAI $ai){
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Creeper extends Monster{
|
class Creeper extends Monster{
|
||||||
const TYPE = MOB_CREEPER;
|
const TYPE = MOB_CREEPER;
|
||||||
const EXPL_TIME = 30;
|
const EXPL_TIME = 30;
|
||||||
|
|
@ -27,8 +28,6 @@ class Creeper extends Monster{
|
||||||
$this->setState($v === null ? !$this->getState() : $v);
|
$this->setState($v === null ? !$this->getState() : $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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 = []){
|
||||||
|
|
|
||||||
|
|
@ -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 = []){
|
||||||
|
|
|
||||||
|
|
@ -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");
|
$this->setHealth($this->data["Health"] ?? 8, "generic");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Zombie extends Monster{
|
class Zombie extends Monster{
|
||||||
const TYPE = MOB_ZOMBIE;
|
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);
|
$this->setSize(0.6, 1.85);
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth($this->data["Health"] ?? 12, "generic");
|
$this->setHealth($this->data["Health"] ?? 12, "generic");
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,6 @@ class Arrow extends Entity{
|
||||||
}
|
}
|
||||||
//Entity::update end
|
//Entity::update end
|
||||||
|
|
||||||
|
|
||||||
if($this->lastPitch == $this->lastYaw && $this->lastYaw == 0){
|
if($this->lastPitch == $this->lastYaw && $this->lastYaw == 0){
|
||||||
$v1 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
|
$v1 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
|
||||||
$this->lastYaw = $this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
|
$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);
|
$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));
|
$entities = $this->level->getEntitiesInAABB($this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ)->expand(1, 1, 1));
|
||||||
$bestDist = 0;
|
$bestDist = 0;
|
||||||
$bestEnt = null;
|
$bestEnt = null;
|
||||||
|
|
@ -197,7 +195,6 @@ class Arrow extends Entity{
|
||||||
$damage += mt_rand(0, $damage / 2 + 1);
|
$damage += mt_rand(0, $damage / 2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($v4->entityHit->harm($damage, $this->eid)){
|
if($v4->entityHit->harm($damage, $this->eid)){
|
||||||
//vanilla seems to increase arrow count if $v4->entity is mob
|
//vanilla seems to increase arrow count if $v4->entity is mob
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
@ -256,8 +253,6 @@ class Arrow extends Entity{
|
||||||
$this->doBlocksCollision();
|
$this->doBlocksCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function spawn($player){
|
public function spawn($player){
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ class FallingSand extends Entity{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
$this->speedX *= 0.7;
|
$this->speedX *= 0.7;
|
||||||
$this->speedZ *= 0.7;
|
$this->speedZ *= 0.7;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class ItemEntity extends Entity{
|
||||||
|
|
||||||
public $meta, $stack, $itemID;
|
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);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setSize(0.25, 0.25);
|
$this->setSize(0.25, 0.25);
|
||||||
|
|
@ -64,7 +64,6 @@ class ItemEntity extends Entity{
|
||||||
$player->dataPacket($pk);
|
$player->dataPacket($pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function tryCombining(Entity $another){
|
public function tryCombining(Entity $another){
|
||||||
|
|
||||||
if($another->eid == $this->eid) return false;
|
if($another->eid == $this->eid) return false;
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,6 @@ class Minecart extends Vehicle{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function applyNaturalSlowdown(){
|
public function applyNaturalSlowdown(){
|
||||||
$mult = $this->linkedEntity != 0 && !$this->isRider ? 0.997 : 0.96;
|
$mult = $this->linkedEntity != 0 && !$this->isRider ? 0.997 : 0.96;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class Painting extends Entity{
|
||||||
public function setDirection($dir){
|
public function setDirection($dir){
|
||||||
$this->direction = $dir;
|
$this->direction = $dir;
|
||||||
$this->lastYaw = $this->yaw = $dir * 90;
|
$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;
|
$width = $size[0] * 16;
|
||||||
$height = $size[1] * 16;
|
$height = $size[1] * 16;
|
||||||
if($dir == 2 || $dir == 0){
|
if($dir == 2 || $dir == 0){
|
||||||
|
|
@ -144,7 +144,7 @@ class Painting extends Entity{
|
||||||
$cubes = $this->level->getCubes($this, $this->boundingBox);
|
$cubes = $this->level->getCubes($this, $this->boundingBox);
|
||||||
if(count($cubes) == 0){
|
if(count($cubes) == 0){
|
||||||
|
|
||||||
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
|
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
|
||||||
$width = $size[0];
|
$width = $size[0];
|
||||||
$width2 = $width * 16 / 32;
|
$width2 = $width * 16 / 32;
|
||||||
$height = $size[1];
|
$height = $size[1];
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -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){
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 = [];
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class Block extends Position{
|
abstract class Block extends Position{
|
||||||
public static $class = array(
|
public static $class = [
|
||||||
AIR => "AirBlock",
|
AIR => "AirBlock",
|
||||||
STONE => "StoneBlock",
|
STONE => "StoneBlock",
|
||||||
GRASS => "GrassBlock",
|
GRASS => "GrassBlock",
|
||||||
|
|
@ -132,7 +132,7 @@ abstract class Block extends Position{
|
||||||
INFO_UPDATE => "InfoUpdateBlock",
|
INFO_UPDATE => "InfoUpdateBlock",
|
||||||
INFO_UPDATE2 => "InfoUpdate2Block",
|
INFO_UPDATE2 => "InfoUpdate2Block",
|
||||||
RESERVED6 => "Reserved6Block",
|
RESERVED6 => "Reserved6Block",
|
||||||
);
|
];
|
||||||
public $id;
|
public $id;
|
||||||
public $meta;
|
public $meta;
|
||||||
public $name;
|
public $name;
|
||||||
|
|
@ -230,7 +230,6 @@ abstract class Block extends Position{
|
||||||
}
|
}
|
||||||
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){}
|
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){}
|
||||||
|
|
||||||
|
|
||||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||||
$this->id = (int) $id;
|
$this->id = (int) $id;
|
||||||
$this->meta = (int) $meta;
|
$this->meta = (int) $meta;
|
||||||
|
|
@ -269,11 +268,11 @@ abstract class Block extends Position{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if(!isset(Block::$class[$this->id])){ //Unknown blocks
|
if(!isset(Block::$class[$this->id])){ //Unknown blocks
|
||||||
return array();
|
return [];
|
||||||
}else{
|
}else{
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta, 1),
|
[$this->id, $this->meta, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class Item{
|
||||||
|
|
||||||
const DEF_DAMAGE = 1;
|
const DEF_DAMAGE = 1;
|
||||||
|
|
||||||
public static $class = array(
|
public static $class = [
|
||||||
|
|
||||||
//armor
|
//armor
|
||||||
LEATHER_CAP => "LeatherCapItem",
|
LEATHER_CAP => "LeatherCapItem",
|
||||||
|
|
@ -128,7 +128,7 @@ class Item{
|
||||||
CLOCK => "ClockItem",
|
CLOCK => "ClockItem",
|
||||||
SHEARS => "ShearsItem",
|
SHEARS => "ShearsItem",
|
||||||
|
|
||||||
);
|
];
|
||||||
public $block;
|
public $block;
|
||||||
public $id;
|
public $id;
|
||||||
public $meta;
|
public $meta;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*value - durability*/
|
/*value - durability*/
|
||||||
class Material{
|
class Material{
|
||||||
const LEATHER = 5; //when enums
|
const LEATHER = 5; //when enums
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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){
|
public static function getSlipperiness($id){
|
||||||
return self::$slipperiness[$id] ?? StaticBlock::DEFAULT_SLIPPERINESS;
|
return self::$slipperiness[$id] ?? StaticBlock::DEFAULT_SLIPPERINESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return [$aabb->offset($x, $y, $z)];
|
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);
|
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){
|
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
|
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
$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 $face
|
||||||
* @param integer $fx
|
* @param integer $fx
|
||||||
* @param integer $fy
|
* @param integer $fy
|
||||||
|
|
@ -142,12 +135,12 @@ class DoorBlock extends TransparentBlock{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$direction = $player->entity->getDirection();
|
$direction = $player->entity->getDirection();
|
||||||
$face = array(
|
$face = [
|
||||||
0 => 3,
|
0 => 3,
|
||||||
1 => 4,
|
1 => 4,
|
||||||
2 => 2,
|
2 => 2,
|
||||||
3 => 5,
|
3 => 5,
|
||||||
);
|
];
|
||||||
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
||||||
$next2 = $this->getSide($face[$direction]);
|
$next2 = $this->getSide($face[$direction]);
|
||||||
$metaUp = 0x08;
|
$metaUp = 0x08;
|
||||||
|
|
@ -164,8 +157,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -186,8 +177,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class GenericBlock extends Block{
|
class GenericBlock extends Block{
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @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 $face
|
||||||
* @param integer $fx
|
* @param integer $fx
|
||||||
* @param integer $fy
|
* @param integer $fy
|
||||||
|
|
@ -28,8 +23,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,8 +31,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,12 +51,12 @@ class GenericBlock extends Block{
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
||||||
$data = array(
|
$data = [
|
||||||
"x" => $x + 0.5,
|
"x" => $x + 0.5,
|
||||||
"y" => $y,
|
"y" => $y,
|
||||||
"z" => $z + 0.5,
|
"z" => $z + 0.5,
|
||||||
"Tile" => $id,
|
"Tile" => $id,
|
||||||
);
|
];
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||||
$server->api->entity->spawnToAll($e);
|
$server->api->entity->spawnToAll($e);
|
||||||
|
|
@ -73,7 +64,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $type
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -85,8 +75,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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(){
|
||||||
|
|
|
||||||
|
|
@ -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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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){
|
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;
|
||||||
|
|
@ -51,8 +51,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -59,21 +59,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)){
|
||||||
|
|
|
||||||
|
|
@ -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{
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,4 @@ class LiquidBlockStatic extends LiquidBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -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{
|
||||||
|
|
|
||||||
|
|
@ -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?
|
||||||
|
|
|
||||||
|
|
@ -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{
|
||||||
|
|
|
||||||
|
|
@ -172,9 +172,9 @@ class BedBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(BED, 0, 1),
|
[BED, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,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;
|
||||||
|
|
@ -79,6 +79,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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,24 +15,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;
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
@ -105,11 +105,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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ class TNTBlock extends SolidBlock{
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
$item->useOn($this);
|
$item->useOn($this);
|
||||||
}
|
}
|
||||||
$data = array(
|
$data = [
|
||||||
"x" => $this->x + 0.5,
|
"x" => $this->x + 0.5,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z + 0.5,
|
"z" => $this->z + 0.5,
|
||||||
"power" => 3,
|
"power" => 3,
|
||||||
"fuse" => 20 * 4, //4 seconds
|
"fuse" => 20 * 4, //4 seconds
|
||||||
);
|
];
|
||||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, 0, 0, true);
|
$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);
|
$e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
|
||||||
ServerAPI::request()->api->entity->spawnToAll($e);
|
ServerAPI::request()->api->entity->spawnToAll($e);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,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){
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class CarpetBlock extends FlowableBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(CARPET, $meta, "Carpet");
|
parent::__construct(CARPET, $meta, "Carpet");
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "White Carpet",
|
0 => "White Carpet",
|
||||||
1 => "Orange Carpet",
|
1 => "Orange Carpet",
|
||||||
2 => "Magenta Carpet",
|
2 => "Magenta Carpet",
|
||||||
|
|
@ -21,7 +21,7 @@ class CarpetBlock extends FlowableBlock{
|
||||||
13 => "Green Carpet",
|
13 => "Green Carpet",
|
||||||
14 => "Red Carpet",
|
14 => "Red Carpet",
|
||||||
15 => "Black Carpet",
|
15 => "Black Carpet",
|
||||||
);
|
];
|
||||||
$this->name = $names[$this->meta];
|
$this->name = $names[$this->meta];
|
||||||
$this->hardness = 0;
|
$this->hardness = 0;
|
||||||
$this->isFullBlock = false;
|
$this->isFullBlock = false;
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,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()];
|
||||||
|
|
@ -40,13 +40,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){
|
||||||
|
|
@ -77,17 +77,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;
|
||||||
}
|
}
|
||||||
|
|
@ -97,15 +95,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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class CobwebBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
elseif ($item->isShears()){
|
elseif ($item->isShears()){
|
||||||
return [
|
return [
|
||||||
array(COBWEB, 0, 1),
|
[COBWEB, 0, 1],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ class FarmlandBlock extends TransparentBlock{
|
||||||
$this->hardness = 3;
|
$this->hardness = 3;
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -33,20 +33,20 @@ class FenceGateBlock extends TransparentBlock{
|
||||||
$this->hardness = 15;
|
$this->hardness = 15;
|
||||||
}
|
}
|
||||||
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){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,11 +24,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("RailBaseBlock.php");
|
require_once("RailBaseBlock.php");
|
||||||
class PoweredRailBlock extends RailBaseBlock{
|
class PoweredRailBlock extends RailBaseBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("RailBaseBlock.php");
|
require_once("RailBaseBlock.php");
|
||||||
class RailBlock extends RailBaseBlock{
|
class RailBlock extends RailBaseBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
|
|
|
||||||
|
|
@ -106,11 +106,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ class SnowLayerBlock extends FlowableBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->isShovel() !== false){
|
if($item->isShovel() !== false){
|
||||||
return array(
|
return [
|
||||||
array(SNOWBALL, 0, 1),
|
[SNOWBALL, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,8 +9,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
//TODO make it extend SlabBlock
|
//TODO make it extend SlabBlock
|
||||||
class WoodSlabBlock extends TransparentBlock{
|
class WoodSlabBlock extends TransparentBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(WOOD_SLAB, $meta, "Wooden Slab");
|
parent::__construct(WOOD_SLAB, $meta, "Wooden Slab");
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "Oak",
|
0 => "Oak",
|
||||||
1 => "Spruce",
|
1 => "Spruce",
|
||||||
2 => "Birch",
|
2 => "Birch",
|
||||||
3 => "Jungle",
|
3 => "Jungle",
|
||||||
);
|
];
|
||||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
|
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||||
if(($this->meta & 0x08) === 0x08){
|
if(($this->meta & 0x08) === 0x08){
|
||||||
$this->isFullBlock = true;
|
$this->isFullBlock = true;
|
||||||
|
|
@ -101,8 +102,8 @@ class WoodSlabBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta & 0x07, 1),
|
[$this->id, $this->meta & 0x07, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,8 +21,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue