mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
commit
845ff19ba1
300 changed files with 3314 additions and 2026 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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,6 @@ class ChatAPI{
|
||||||
/**
|
/**
|
||||||
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
|
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param $whitelist
|
|
||||||
* @param $blacklist
|
|
||||||
*/
|
*/
|
||||||
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
||||||
$message = [
|
$message = [
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ class LevelAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
||||||
if(file_exists($path . "tileEntities.yml")){
|
if(file_exists($path . "tileEntities.yml")){
|
||||||
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
||||||
|
|
|
||||||
|
|
@ -316,4 +316,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 = [
|
||||||
|
|
|
||||||
261
src/Player.php
261
src/Player.php
|
|
@ -503,6 +503,12 @@ class Player{
|
||||||
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY) return;
|
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY) return;
|
||||||
if(!$this->convertToLocalEIDPacket($packet)) return false;
|
if(!$this->convertToLocalEIDPacket($packet)) return false;
|
||||||
|
|
||||||
|
if(PacketPool::isPacketExist($packet->pid(), $this->PROTOCOL) != true){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
|
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
$len = strlen($packet->buffer) + 1;
|
$len = strlen($packet->buffer) + 1;
|
||||||
$MTU = $this->MTU - 24;
|
$MTU = $this->MTU - 24;
|
||||||
|
|
@ -1667,6 +1673,7 @@ class Player{
|
||||||
}
|
}
|
||||||
$this->received[$p->messageIndex] = true;
|
$this->received[$p->messageIndex] = true;
|
||||||
}
|
}
|
||||||
|
$p->PROTOCOL = $this->PROTOCOL;
|
||||||
$p->decode();
|
$p->decode();
|
||||||
$this->handleDataPacket($p);
|
$this->handleDataPacket($p);
|
||||||
}
|
}
|
||||||
|
|
@ -1892,6 +1899,7 @@ class Player{
|
||||||
$motion->speedX = $e->speedX;
|
$motion->speedX = $e->speedX;
|
||||||
$motion->speedY = $e->speedY;
|
$motion->speedY = $e->speedY;
|
||||||
$motion->speedZ = $e->speedZ;
|
$motion->speedZ = $e->speedZ;
|
||||||
|
$motion->PROTOCOL = $this->PROTOCOL;
|
||||||
$motion->encode();
|
$motion->encode();
|
||||||
$len += 10 + strlen($motion->buffer);
|
$len += 10 + strlen($motion->buffer);
|
||||||
++$packets;
|
++$packets;
|
||||||
|
|
@ -1913,6 +1921,7 @@ class Player{
|
||||||
$move->yaw = $e->yaw;
|
$move->yaw = $e->yaw;
|
||||||
$move->pitch = $e->pitch;
|
$move->pitch = $e->pitch;
|
||||||
$move->bodyYaw = $e->headYaw;
|
$move->bodyYaw = $e->headYaw;
|
||||||
|
$move->PROTOCOL = $this->PROTOCOL;
|
||||||
$move->encode();
|
$move->encode();
|
||||||
}else{
|
}else{
|
||||||
$move = new MoveEntityPacket_PosRot();
|
$move = new MoveEntityPacket_PosRot();
|
||||||
|
|
@ -1922,16 +1931,19 @@ class Player{
|
||||||
$move->z = $e->z;
|
$move->z = $e->z;
|
||||||
$move->yaw = $e->yaw;
|
$move->yaw = $e->yaw;
|
||||||
$move->pitch = $e->pitch;
|
$move->pitch = $e->pitch;
|
||||||
|
$move->PROTOCOL = $this->PROTOCOL;
|
||||||
$move->encode();
|
$move->encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
$len += strlen($move->buffer) + 10;
|
$len += strlen($move->buffer) + 10;
|
||||||
++$packets;
|
++$packets;
|
||||||
$moveSent = true;
|
$moveSent = true;
|
||||||
}else if($e->headYaw != $e->lastHeadYaw){
|
|
||||||
|
}elseif($this->PROTOCOL > ProtocolInfo12::CURRENT_PROTOCOL_12 && $e->headYaw != $e->lastHeadYaw){
|
||||||
$headyaw = new RotateHeadPacket();
|
$headyaw = new RotateHeadPacket();
|
||||||
$headyaw->eid = $localeid;
|
$headyaw->eid = $localeid;
|
||||||
$headyaw->yaw = $e->headYaw;
|
$headyaw->yaw = $e->headYaw;
|
||||||
|
$headyaw->PROTOCOL = $this->PROTOCOL;
|
||||||
$headyaw->encode();
|
$headyaw->encode();
|
||||||
$len += strlen($headyaw->buffer) + 10;
|
$len += strlen($headyaw->buffer) + 10;
|
||||||
++$packets;
|
++$packets;
|
||||||
|
|
@ -2131,7 +2143,184 @@ class Player{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($packet->pid()){
|
if ($packet->pid() == ProtocolInfo::LOGIN_PACKET) {
|
||||||
|
if ($this->loggedIn === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->username = $packet->username;
|
||||||
|
$this->iusername = strtolower($this->username);
|
||||||
|
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
||||||
|
$this->PROTOCOL = $packet->PROTOCOL;
|
||||||
|
if (count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)) {
|
||||||
|
$this->close("server is full!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($packet->protocol1 < ProtocolInfo3::CURRENT_PROTOCOL_3 && $packet->protocol1 > ProtocolInfo::CURRENT_PROTOCOL) {
|
||||||
|
if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
|
||||||
|
$pk = new LoginStatusPacket;
|
||||||
|
$pk->status = 1;
|
||||||
|
$this->directDataPacket($pk);
|
||||||
|
} else {
|
||||||
|
$pk = new LoginStatusPacket;
|
||||||
|
$pk->status = 2;
|
||||||
|
$this->directDataPacket($pk);
|
||||||
|
}
|
||||||
|
$this->close("Incorrect protocol #" . $packet->protocol1, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (preg_match('#[^a-zA-Z0-9_]#', $this->username) > 0 || $this->username === "" || $this->iusername === "rcon" || $this->iusername === "console" || $this->iusername === "server" || strlen($this->iusername) > 16) {
|
||||||
|
$this->close("Bad username", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->server->api->handle("player.connect", $this) === false) {
|
||||||
|
$this->close("Unknown reason", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)) {
|
||||||
|
$this->close("Server is white-listed", false);
|
||||||
|
return;
|
||||||
|
} elseif ($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)) {
|
||||||
|
$this->close("You are banned!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->loggedIn = true;
|
||||||
|
|
||||||
|
if (!isset($this->CID) or $this->CID == null) {
|
||||||
|
console("[DEBUG] Player " . $this->username . " does not have a CID", true, true, 2);
|
||||||
|
$this->CID = Utils::readLong(Utils::getRandomBytes(8, false));
|
||||||
|
}
|
||||||
|
$u = $this->server->api->player->get($this->iusername, false);
|
||||||
|
if ($u !== false) {
|
||||||
|
$u = $this->server->clients[$this->CID];
|
||||||
|
$u->close("this player already in game");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->server->api->player->add($this->CID);
|
||||||
|
if ($this->server->api->handle("player.join", $this) === false) {
|
||||||
|
$this->close("join cancelled", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!($this->data instanceof Config)) {
|
||||||
|
$this->close("no config created", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->auth = true;
|
||||||
|
if (!$this->data->exists("inventory") or ($this->gamemode & 0x01) === 0x01) {
|
||||||
|
if (($this->gamemode & 0x01) === 0x01) {
|
||||||
|
$inv = [];
|
||||||
|
if (($this->gamemode & 0x02) === 0x02) {
|
||||||
|
foreach (BlockAPI::$creative as $item) {
|
||||||
|
$inv[] = [0, 0, 1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach (BlockAPI::$creative as $item) {
|
||||||
|
$inv[] = [$item[0], $item[1], 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->data->set("inventory", $inv);
|
||||||
|
}
|
||||||
|
$this->achievements = $this->data->get("achievements");
|
||||||
|
$this->data->set("caseusername", $this->username);
|
||||||
|
$this->inventory = [];
|
||||||
|
foreach ($this->data->get("inventory") as $slot => $item) {
|
||||||
|
if (!is_array($item) or count($item) < 3) {
|
||||||
|
$item = [AIR, 0, 0];
|
||||||
|
}
|
||||||
|
$this->inventory[$slot] = BlockAPI::getItem($item[0], $item[1], $item[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->armor = [];
|
||||||
|
foreach ($this->data->get("armor") as $slot => $item) {
|
||||||
|
$this->armor[$slot] = BlockAPI::getItem($item[0], $item[1], $item[0] === 0 ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data->set("lastIP", $this->ip);
|
||||||
|
$this->data->set("lastID", $this->clientID);
|
||||||
|
|
||||||
|
$this->server->api->player->saveOffline($this->data);
|
||||||
|
|
||||||
|
$pk = new LoginStatusPacket;
|
||||||
|
$pk->status = 0;
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
$pk = new StartGamePacket;
|
||||||
|
$pk->seed = $this->level->getSeed();
|
||||||
|
$pk->x = $this->data->get("position")["x"];
|
||||||
|
$pk->y = $this->data->get("position")["y"];
|
||||||
|
$pk->z = $this->data->get("position")["z"];
|
||||||
|
$pk->generator = 0;
|
||||||
|
$pk->gamemode = $this->gamemode & 0x01;
|
||||||
|
$pk->eid = 0;
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
if (($this->gamemode & 0x01) === 0x01) {
|
||||||
|
$this->slot = 0;
|
||||||
|
$this->hotbar = [];
|
||||||
|
} elseif ($this->data->exists("hotbar")) {
|
||||||
|
$this->hotbar = $this->data->get("hotbar");
|
||||||
|
$this->slot = $this->hotbar[0];
|
||||||
|
} else {
|
||||||
|
$this->slot = 0;
|
||||||
|
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < count($this->hotbar); ++$i) {
|
||||||
|
if ($this->hotbar[$i] > 36) $this->hotbar[$i] = -1; //XXX unsafe?
|
||||||
|
if ($this->hotbar[$i] < -1) $this->hotbar[$i] = -1;
|
||||||
|
}
|
||||||
|
if ($this->data->exists("slot-count")) {
|
||||||
|
$this->slotCount = $this->data->get("slot-count");
|
||||||
|
} else {
|
||||||
|
$this->data->set("slot-count", $this->slotCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entity = $this->server->api->entity->add($this->level, ENTITY_PLAYER, 0, ["player" => $this]);
|
||||||
|
$this->eid = $this->entity->eid;
|
||||||
|
$this->server->query("UPDATE players SET EID = " . $this->eid . " WHERE CID = " . $this->CID . ";");
|
||||||
|
$this->entity->x = $this->data->get("position")["x"];
|
||||||
|
$this->entity->y = $this->data->get("position")["y"];
|
||||||
|
$this->entity->z = $this->data->get("position")["z"];
|
||||||
|
if (($level = $this->server->api->level->get($this->data->get("spawn")["level"])) !== false) {
|
||||||
|
$this->spawnPosition = new Position($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"], $level);
|
||||||
|
|
||||||
|
$pk = new SetSpawnPositionPacket;
|
||||||
|
$pk->x = (int) $this->spawnPosition->x;
|
||||||
|
$pk->y = (int) $this->spawnPosition->y;
|
||||||
|
$pk->z = (int) $this->spawnPosition->z;
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
}
|
||||||
|
$this->entity->check = false;
|
||||||
|
$this->entity->setName($this->username);
|
||||||
|
$this->entity->data["CID"] = $this->CID;
|
||||||
|
$this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.motion", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.animate", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.event", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.metadata", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("entity.link", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("player.equipment.change", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("player.armor", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("player.pickup", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("tile.container.slot", [$this, "eventHandler"]);
|
||||||
|
$this->evid[] = $this->server->event("tile.update", [$this, "eventHandler"]);
|
||||||
|
$this->lastMeasure = microtime(true);
|
||||||
|
$this->server->schedule(50, [$this, "measureLag"], [], true);
|
||||||
|
|
||||||
|
$pk = new SetTimePacket;
|
||||||
|
$pk->time = $this->level->getTime();
|
||||||
|
$pk->started = !$this->level->isTimeStopped();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$internalPid = $packet->getInternalPid();
|
||||||
|
|
||||||
|
switch ($internalPid) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::PONG_PACKET:
|
case ProtocolInfo::PONG_PACKET:
|
||||||
|
|
@ -2171,6 +2360,7 @@ class Player{
|
||||||
$this->username = $packet->username;
|
$this->username = $packet->username;
|
||||||
$this->iusername = strtolower($this->username);
|
$this->iusername = strtolower($this->username);
|
||||||
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
|
||||||
|
$this->PROTOCOL = $packet->PROTOCOL;
|
||||||
if(count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){
|
if(count($this->server->clients) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){
|
||||||
$this->close("server is full!", false);
|
$this->close("server is full!", false);
|
||||||
return;
|
return;
|
||||||
|
|
@ -2675,6 +2865,73 @@ class Player{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ProtocolInfo::PLACE_BLOCK_PACKET:
|
||||||
|
if (!($this->entity instanceof Entity)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$blockVector = new Vector3($packet->x, $packet->y, $packet->z);
|
||||||
|
|
||||||
|
if (($this->spawned === false or $this->blocked === true) and $packet->face >= 0 and $packet->face <= 5) {
|
||||||
|
$target = $this->level->getBlock($blockVector);
|
||||||
|
$block = $target->getSide($packet->face);
|
||||||
|
|
||||||
|
$pk = new UpdateBlockPacket;
|
||||||
|
$pk->x = $target->x;
|
||||||
|
$pk->y = $target->y;
|
||||||
|
$pk->z = $target->z;
|
||||||
|
$pk->block = $target->getID();
|
||||||
|
$pk->meta = $target->getMetadata();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
$pk = new UpdateBlockPacket;
|
||||||
|
$pk->x = $block->x;
|
||||||
|
$pk->y = $block->y;
|
||||||
|
$pk->z = $block->z;
|
||||||
|
$pk->block = $block->getID();
|
||||||
|
$pk->meta = $block->getMetadata();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$this->craftingItems = [];
|
||||||
|
$this->toCraft = [];
|
||||||
|
$packet->eid = $this->eid;
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
if ($packet->face >= 0 and $packet->face <= 5) {
|
||||||
|
if ($this->entity->inAction === true) {
|
||||||
|
$this->entity->inAction = false;
|
||||||
|
$this->entity->inActionCounter = 0;
|
||||||
|
$this->entity->updateMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->server->api->block->playerBlockAction($this, $blockVector, $packet->face, $packet->x, $packet->y, $packet->z);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$target = $this->level->getBlock($blockVector);
|
||||||
|
$block = $target->getSide($packet->face);
|
||||||
|
|
||||||
|
$pk = new UpdateBlockPacket;
|
||||||
|
$pk->x = $target->x;
|
||||||
|
$pk->y = $target->y;
|
||||||
|
$pk->z = $target->z;
|
||||||
|
$pk->block = $target->getID();
|
||||||
|
$pk->meta = $target->getMetadata();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
$pk = new UpdateBlockPacket;
|
||||||
|
$pk->x = $block->x;
|
||||||
|
$pk->y = $block->y;
|
||||||
|
$pk->z = $block->z;
|
||||||
|
$pk->block = $block->getID();
|
||||||
|
$pk->meta = $block->getMetadata();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ProtocolInfo::PLAYER_ACTION_PACKET:
|
case ProtocolInfo::PLAYER_ACTION_PACKET:
|
||||||
if($this->spawned === false or $this->blocked === true){
|
if($this->spawned === false or $this->blocked === true){
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TileNavigator
|
class TileNavigator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -21,9 +22,9 @@ class TileNavigator
|
||||||
public function reconstructPath($path, $current){
|
public function reconstructPath($path, $current){
|
||||||
console("path built");
|
console("path built");
|
||||||
$totalPath = [$current];
|
$totalPath = [$current];
|
||||||
while (isset($path[(string)$current]))
|
while (isset($path[(string) $current]))
|
||||||
{
|
{
|
||||||
$current = $path[(string)$current];
|
$current = $path[(string) $current];
|
||||||
$totalPath[] = $current;
|
$totalPath[] = $current;
|
||||||
}
|
}
|
||||||
//foreach(array_unique($path) as $k => $p) console($k.":".$p);
|
//foreach(array_unique($path) as $k => $p) console($k.":".$p);
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -71,12 +71,12 @@ class TileNavigator
|
||||||
$path = [];
|
$path = [];
|
||||||
$gScore = [];
|
$gScore = [];
|
||||||
$gScore[(string) $from] = 0;
|
$gScore[(string) $from] = 0;
|
||||||
$has = [(string)$from, true];
|
$has = [(string) $from, true];
|
||||||
if($this->isLocBlocked($pmfLevel, $to)){
|
if($this->isLocBlocked($pmfLevel, $to)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$visited = [];
|
$visited = [];
|
||||||
$maxDist*=$maxDist; //no square root
|
$maxDist *= $maxDist; //no square root
|
||||||
$closestToTarget = null;
|
$closestToTarget = null;
|
||||||
$closestToTargetDist = INF;
|
$closestToTargetDist = INF;
|
||||||
|
|
||||||
|
|
@ -108,10 +108,10 @@ class TileNavigator
|
||||||
if($this->isLocBlocked($pmfLevel, $new - 2)){
|
if($this->isLocBlocked($pmfLevel, $new - 2)){
|
||||||
$new -= 1;
|
$new -= 1;
|
||||||
$newY -= 1;
|
$newY -= 1;
|
||||||
}else if($this->isLocBlocked($pmfLevel, $new - 3)){
|
}elseif($this->isLocBlocked($pmfLevel, $new - 3)){
|
||||||
$new -= 2;
|
$new -= 2;
|
||||||
$newY -= 2;
|
$newY -= 2;
|
||||||
}else if($this->isLocBlocked($pmfLevel, $new - 4)){
|
}elseif($this->isLocBlocked($pmfLevel, $new - 4)){
|
||||||
$new -= 3;
|
$new -= 3;
|
||||||
$newY -= 3;
|
$newY -= 3;
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -119,17 +119,17 @@ class TileNavigator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dist = ($fromX - $newX)*($fromX - $newX) + ($fromY - $newY)*($fromY - $newY) + ($fromZ - $newZ)*($fromZ - $newZ);
|
$dist = ($fromX - $newX) * ($fromX - $newX) + ($fromY - $newY) * ($fromY - $newY) + ($fromZ - $newZ) * ($fromZ - $newZ);
|
||||||
if($dist < -$maxDist || $dist > $maxDist){
|
if($dist < -$maxDist || $dist > $maxDist){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$points[] = $new;
|
$points[] = $new;
|
||||||
}else if(!$this->isLocBlocked($pmfLevel, $current+1) && !$this->isLocBlocked($pmfLevel, $new+1)){
|
}elseif(!$this->isLocBlocked($pmfLevel, $current + 1) && !$this->isLocBlocked($pmfLevel, $new + 1)){
|
||||||
$new += 1;
|
$new += 1;
|
||||||
$newY += 1;
|
$newY += 1;
|
||||||
|
|
||||||
$dist = ($fromX - $newX)*($fromX - $newX) + ($fromY - $newY)*($fromY - $newY) + ($fromZ - $newZ)*($fromZ - $newZ);
|
$dist = ($fromX - $newX) * ($fromX - $newX) + ($fromY - $newY) * ($fromY - $newY) + ($fromZ - $newZ) * ($fromZ - $newZ);
|
||||||
if($dist < -$maxDist || $dist > $maxDist){
|
if($dist < -$maxDist || $dist > $maxDist){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -148,14 +148,13 @@ class TileNavigator
|
||||||
$diffX = ($toX - ($neighbor >> 16 & 0xff));
|
$diffX = ($toX - ($neighbor >> 16 & 0xff));
|
||||||
$diffY = ($toY - ($neighbor & 0xff));
|
$diffY = ($toY - ($neighbor & 0xff));
|
||||||
$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));
|
||||||
|
|
||||||
$distbetweenCost = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
$distbetweenCost = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
||||||
$tentativeG = $gScore[$current] + $distbetweenCost;
|
$tentativeG = $gScore[$current] + $distbetweenCost;
|
||||||
if (!isset($has[$neighbor]))
|
if (!isset($has[$neighbor]))
|
||||||
{
|
{
|
||||||
|
|
@ -191,6 +190,5 @@ class TileNavigator
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ define("SOUL_SAND", 88); //doesnt exist
|
||||||
define("GLOWSTONE", 89);
|
define("GLOWSTONE", 89);
|
||||||
define("GLOWSTONE_BLOCK", 89);
|
define("GLOWSTONE_BLOCK", 89);
|
||||||
|
|
||||||
|
|
||||||
define("LIT_PUMPKIN", 91);
|
define("LIT_PUMPKIN", 91);
|
||||||
define("JACK_O_LANTERN", 91);
|
define("JACK_O_LANTERN", 91);
|
||||||
define("CAKE_BLOCK", 92);
|
define("CAKE_BLOCK", 92);
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,6 @@ require_once(FILE_PATH . "/src/pmf/PMF.php");
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
|
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
|
||||||
|
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
|
require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/entity/Rideable.php");
|
require_once(FILE_PATH . "/src/entity/Rideable.php");
|
||||||
|
|
@ -133,8 +132,6 @@ require_once(FILE_PATH . "/src/world/generator/vanilla/feature/Feature.php");
|
||||||
|
|
||||||
require_all(FILE_PATH . "src/");
|
require_all(FILE_PATH . "src/");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$inc = get_included_files();
|
$inc = get_included_files();
|
||||||
$inc[] = array_shift($inc);
|
$inc[] = array_shift($inc);
|
||||||
$srcdir = realpath(FILE_PATH . "src/");
|
$srcdir = realpath(FILE_PATH . "src/");
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -87,10 +86,10 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
|
|
||||||
public function collideHandler(){
|
public function collideHandler(){
|
||||||
$bb = $this->boundingBox->expand(0.2, 0, 0.2);
|
$bb = $this->boundingBox->expand(0.2, 0, 0.2);
|
||||||
$minChunkX = ((int)($bb->minX)) >> 4;
|
$minChunkX = ((int) ($bb->minX)) >> 4;
|
||||||
$minChunkZ = ((int)($bb->minZ)) >> 4;
|
$minChunkZ = ((int) ($bb->minZ)) >> 4;
|
||||||
$maxChunkX = ((int)($bb->minX)) >> 4;
|
$maxChunkX = ((int) ($bb->minX)) >> 4;
|
||||||
$maxChunkZ = ((int)($bb->minZ)) >> 4;
|
$maxChunkZ = ((int) ($bb->minZ)) >> 4;
|
||||||
|
|
||||||
//TODO also index by chunkY?
|
//TODO also index by chunkY?
|
||||||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||||
|
|
@ -140,14 +139,13 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
if(self::$pathfind){
|
if(self::$pathfind){
|
||||||
$this->path = $this->pathFinder->navigate(
|
$this->path = $this->pathFinder->navigate(
|
||||||
$this->level,
|
$this->level,
|
||||||
(int)$this->x, (int)$this->y, (int)$this->z,
|
(int) $this->x, (int) $this->y, (int) $this->z,
|
||||||
//(int)$pl->entity->x, (int)$pl->entity->y, (int)$pl->entity->z,
|
//(int)$pl->entity->x, (int)$pl->entity->y, (int)$pl->entity->z,
|
||||||
(int)$this->x + mt_rand(-16, 16), (int)$this->y, (int)$this->z + mt_rand(-16, 16),
|
(int) $this->x + mt_rand(-16, 16), (int) $this->y, (int) $this->z + mt_rand(-16, 16),
|
||||||
16
|
16
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*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;
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +251,7 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
if($blockAt > 0) $friction = StaticBlock::getSlipperiness($blockAt) * 0.91;
|
if($blockAt > 0) $friction = StaticBlock::getSlipperiness($blockAt) * 0.91;
|
||||||
}
|
}
|
||||||
|
|
||||||
$var8 = 0.16277 / ($friction*$friction*$friction);
|
$var8 = 0.16277 / ($friction * $friction * $friction);
|
||||||
|
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
$var5 = $this->getAIMoveSpeed(); //in vanilla it returns either this.seed or calls getBaseSpeed(depending on useNewAi)
|
$var5 = $this->getAIMoveSpeed(); //in vanilla it returns either this.seed or calls getBaseSpeed(depending on useNewAi)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Monster extends Creature{
|
class Monster extends Creature{
|
||||||
|
|
||||||
public $closestPlayerToAttackEID = false;
|
public $closestPlayerToAttackEID = false;
|
||||||
|
|
@ -35,7 +36,7 @@ class Monster extends Creature{
|
||||||
$this->closestPlayerToAttackEID = false;
|
$this->closestPlayerToAttackEID = false;
|
||||||
$this->closestPlayerToAttackDist = INF;
|
$this->closestPlayerToAttackDist = INF;
|
||||||
}else{
|
}else{
|
||||||
$dist = ($this->x - $player->x)*($this->x - $player->x) + ($this->y - $player->y)*($this->y - $player->y) + ($this->z - $player->z)*($this->z - $player->z);
|
$dist = ($this->x - $player->x) * ($this->x - $player->x) + ($this->y - $player->y) * ($this->y - $player->y) + ($this->z - $player->z) * ($this->z - $player->z);
|
||||||
$this->closestPlayerToAttackDist = $dist;
|
$this->closestPlayerToAttackDist = $dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -98,7 +99,7 @@ abstract class Projectile extends Entity{
|
||||||
if(!$this->isImmuneToFire){
|
if(!$this->isImmuneToFire){
|
||||||
$this->harm(4, "fire");
|
$this->harm(4, "fire");
|
||||||
$oldOnFire = $this->fire;
|
$oldOnFire = $this->fire;
|
||||||
if($oldOnFire < 20*30) $this->fire = 20*30; //30 seconds
|
if($oldOnFire < 20 * 30) $this->fire = 20 * 30; //30 seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,7 +167,7 @@ abstract class Projectile extends Entity{
|
||||||
$this->x += $this->speedX;
|
$this->x += $this->speedX;
|
||||||
$this->y += $this->speedY;
|
$this->y += $this->speedY;
|
||||||
$this->z += $this->speedZ;
|
$this->z += $this->speedZ;
|
||||||
$v21 = sqrt($this->speedX*$this->speedX + $this->speedZ*$this->speedZ);
|
$v21 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
|
||||||
$this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
|
$this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
|
||||||
$this->pitch = atan2($this->speedY, $v21) * 180 / M_PI;
|
$this->pitch = atan2($this->speedY, $v21) * 180 / M_PI;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class MobController
|
||||||
$diffZ = $this->moveToZ - $this->entity->z;
|
$diffZ = $this->moveToZ - $this->entity->z;
|
||||||
$diffY = $this->moveToY - $v1;
|
$diffY = $this->moveToY - $v1;
|
||||||
|
|
||||||
$v8 = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ;
|
$v8 = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
||||||
|
|
||||||
if($v8 >= 0.00000025){
|
if($v8 >= 0.00000025){
|
||||||
$v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
$v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
||||||
|
|
@ -123,7 +123,7 @@ class MobController
|
||||||
public function updateHeadYaw(){
|
public function updateHeadYaw(){
|
||||||
$diffX = $this->entity->x - $this->entity->lastX;
|
$diffX = $this->entity->x - $this->entity->lastX;
|
||||||
$diffZ = $this->entity->z - $this->entity->lastZ;
|
$diffZ = $this->entity->z - $this->entity->lastZ;
|
||||||
if(($diffX*$diffX + $diffZ*$diffZ) > 0.00000025){
|
if(($diffX * $diffX + $diffZ * $diffZ) > 0.00000025){
|
||||||
$this->entity->renderYawOffset = $this->entity->yaw;
|
$this->entity->renderYawOffset = $this->entity->yaw;
|
||||||
$this->entity->headYaw = self::limitAngle2($this->entity->renderYawOffset, $this->entity->headYaw, 75);
|
$this->entity->headYaw = self::limitAngle2($this->entity->renderYawOffset, $this->entity->headYaw, 75);
|
||||||
$this->headYaw = $this->entity->headYaw;
|
$this->headYaw = $this->entity->headYaw;
|
||||||
|
|
@ -153,10 +153,10 @@ class MobController
|
||||||
$diffX = $this->lookX - $this->entity->x;
|
$diffX = $this->lookX - $this->entity->x;
|
||||||
$diffY = $this->lookY - ($this->entity->y + $this->entity->getEyeHeight());
|
$diffY = $this->lookY - ($this->entity->y + $this->entity->getEyeHeight());
|
||||||
$diffZ = $this->lookZ - $this->entity->z;
|
$diffZ = $this->lookZ - $this->entity->z;
|
||||||
$distance = sqrt($diffX*$diffX + $diffZ*$diffZ);
|
$distance = sqrt($diffX * $diffX + $diffZ * $diffZ);
|
||||||
|
|
||||||
$v9 = (atan2($diffZ, $diffX)*180 / M_PI) - 90;
|
$v9 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
||||||
$v10 = -(atan2($diffY, $distance)*180 / M_PI);
|
$v10 = -(atan2($diffY, $distance) * 180 / M_PI);
|
||||||
|
|
||||||
$this->entity->pitch = self::limitAngle($this->entity->pitch, $v10, $this->deltaLookPitch);
|
$this->entity->pitch = self::limitAngle($this->entity->pitch, $v10, $this->deltaLookPitch);
|
||||||
$this->entity->headYaw = self::limitAngle($this->entity->headYaw, $v9, $this->deltaLookYaw);
|
$this->entity->headYaw = self::limitAngle($this->entity->headYaw, $v9, $this->deltaLookYaw);
|
||||||
|
|
@ -200,7 +200,7 @@ class MobController
|
||||||
}
|
}
|
||||||
|
|
||||||
public function faceEntity($x, $y, $z){
|
public function faceEntity($x, $y, $z){
|
||||||
$len = sqrt($x*$x + $z*$z + $y*$y);
|
$len = sqrt($x * $x + $z * $z + $y * $y);
|
||||||
//$d = $len == 0 ?//$v->subtract($this->entity)->normalize();
|
//$d = $len == 0 ?//$v->subtract($this->entity)->normalize();
|
||||||
if($len == 0){
|
if($len == 0){
|
||||||
$dx = 0;
|
$dx = 0;
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class TaskAttackPlayer extends TaskBase
|
||||||
|
|
||||||
public function __construct($speed, $range){
|
public function __construct($speed, $range){
|
||||||
$this->speedMultiplier = $speed;
|
$this->speedMultiplier = $speed;
|
||||||
$this->rangeSquared = $range*$range;
|
$this->rangeSquared = $range * $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onStart(EntityAI $ai)
|
public function onStart(EntityAI $ai)
|
||||||
|
|
@ -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)){
|
||||||
|
|
@ -38,7 +37,7 @@ class TaskAttackPlayer extends TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
$dist = ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff);
|
$dist = ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff);
|
||||||
if($dist <= $v1){
|
if($dist <= $v1){
|
||||||
if($this->attackCounter <= 0){
|
if($this->attackCounter <= 0){
|
||||||
$this->attackCounter = $e->attackEntity($t, sqrt($dist)) ? 20 : 0;
|
$this->attackCounter = $e->attackEntity($t, sqrt($dist)) ? 20 : 0;
|
||||||
|
|
@ -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){
|
||||||
|
|
@ -55,7 +53,7 @@ class TaskAttackPlayer extends TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared;
|
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +65,7 @@ class TaskAttackPlayer extends TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared){
|
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class TaskLookAround extends TaskBase
|
||||||
|
|
||||||
public function canBeExecuted(EntityAI $ai)
|
public function canBeExecuted(EntityAI $ai)
|
||||||
{
|
{
|
||||||
return !$ai->entity->inPanic && !$ai->entity->isMoving() && lcg_value() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskAttackPlayer") && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
|
return !$ai->entity->inPanic && !$ai->entity->isMoving() && lcg_value() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskAttackPlayer") && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate(EntityAI $ai)
|
public function onUpdate(EntityAI $ai)
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ class TaskLookAtPlayer extends TaskBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeExecuted(EntityAI $ai){
|
public function canBeExecuted(EntityAI $ai){
|
||||||
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->isStarted("TaskPanic") && !$ai->entity->hasPath();
|
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->isStarted("TaskPanic") && !$ai->entity->hasPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findTarget(Creature $e, $r){
|
protected function findTarget(Creature $e, $r){
|
||||||
return $e->closestPlayerDist > $r*$r ? null : $e->level->entityList[$e->closestPlayerEID];
|
return $e->closestPlayerDist > $r * $r ? null : $e->level->entityList[$e->closestPlayerEID];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onStart(EntityAI $ai){
|
public function onStart(EntityAI $ai){
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ class TaskMate extends TaskBase
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed());
|
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||||
$ai->mobController->setMovingTarget($movTo->x, $movTo->y, $movTo->z, $this->speedMultiplier);
|
$ai->mobController->setMovingTarget($movTo->x, $movTo->y, $movTo->z, $this->speedMultiplier);
|
||||||
|
|
||||||
|
|
@ -56,7 +55,7 @@ class TaskMate extends TaskBase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findMate(EntityAI $ai){
|
public function findMate(EntityAI $ai){
|
||||||
$distance = 8.0*8.0;
|
$distance = 8.0 * 8.0;
|
||||||
$minDist = $distance; //TODO check bb intersection?
|
$minDist = $distance; //TODO check bb intersection?
|
||||||
$matedEID = null;
|
$matedEID = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,7 @@ class TaskRandomWalk extends TaskBase
|
||||||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt") || $ai->isStarted("TaskAttackPlayer") || $ai->isStarted("TaskRangedAttack")) {
|
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt") || $ai->isStarted("TaskAttackPlayer") || $ai->isStarted("TaskRangedAttack")) {
|
||||||
return false;
|
return false;
|
||||||
} // i really need mutexBits
|
} // i really need mutexBits
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class TaskRangedAttack extends \TaskBase
|
||||||
public $rangeSquared = 0;
|
public $rangeSquared = 0;
|
||||||
public function __construct($speed, $range){
|
public function __construct($speed, $range){
|
||||||
$this->speedMultiplier = $speed;
|
$this->speedMultiplier = $speed;
|
||||||
$this->rangeSquared = $range*$range;
|
$this->rangeSquared = $range * $range;
|
||||||
$this->server = ServerAPI::request();
|
$this->server = ServerAPI::request();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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){
|
||||||
|
|
@ -97,7 +95,7 @@ class TaskRangedAttack extends \TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared;
|
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +107,7 @@ class TaskRangedAttack extends \TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared){
|
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class TaskTempt extends TaskBase
|
||||||
public $targetDistance;
|
public $targetDistance;
|
||||||
public function __construct($speed){
|
public function __construct($speed){
|
||||||
$this->speedMultiplier = $speed;
|
$this->speedMultiplier = $speed;
|
||||||
$this->targetDistance = 10*10;
|
$this->targetDistance = 10 * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onStart(EntityAI $ai)
|
public function onStart(EntityAI $ai)
|
||||||
|
|
@ -31,7 +31,7 @@ class TaskTempt extends TaskBase
|
||||||
$xdiff = ($target->x - $ai->entity->x);
|
$xdiff = ($target->x - $ai->entity->x);
|
||||||
$ydiff = ($target->y - $ai->entity->y);
|
$ydiff = ($target->y - $ai->entity->y);
|
||||||
$zdiff = ($target->z - $ai->entity->z);
|
$zdiff = ($target->z - $ai->entity->z);
|
||||||
$dist = $xdiff*$xdiff + $ydiff*$ydiff + $zdiff*$zdiff;
|
$dist = $xdiff * $xdiff + $ydiff * $ydiff + $zdiff * $zdiff;
|
||||||
$ai->mobController->setLookPosition($target->x, $target->y + $target->getEyeHeight(), $target->z, 30, $ai->entity->getVerticalFaceSpeed());
|
$ai->mobController->setLookPosition($target->x, $target->y + $target->getEyeHeight(), $target->z, 30, $ai->entity->getVerticalFaceSpeed());
|
||||||
if($dist >= 6.25){
|
if($dist >= 6.25){
|
||||||
$ai->mobController->setMovingTarget($target->x, $target->y, $target->z, $this->speedMultiplier);
|
$ai->mobController->setMovingTarget($target->x, $target->y, $target->z, $this->speedMultiplier);
|
||||||
|
|
@ -39,7 +39,6 @@ class TaskTempt extends TaskBase
|
||||||
$ai->mobController->headYawIsYaw = true;
|
$ai->mobController->headYawIsYaw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTargetValid(EntityAI $ai){
|
public function isTargetValid(EntityAI $ai){
|
||||||
|
|
@ -49,7 +48,7 @@ class TaskTempt extends TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->targetDistance;
|
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->targetDistance;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +65,7 @@ class TaskTempt extends TaskBase
|
||||||
$xDiff = ($t->x - $e->x);
|
$xDiff = ($t->x - $e->x);
|
||||||
$yDiff = ($t->y - $e->y);
|
$yDiff = ($t->y - $e->y);
|
||||||
$zDiff = ($t->z - $e->z);
|
$zDiff = ($t->z - $e->z);
|
||||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->targetDistance){
|
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->targetDistance){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 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 = []){
|
||||||
|
|
@ -24,15 +25,15 @@ class Skeleton extends Monster{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//bad fix for burning in water
|
//bad fix for burning in water
|
||||||
[$block, $meta] = $this->level->level->getBlock((int)$this->x, (int)$this->y, (int)$this->z);
|
[$block, $meta] = $this->level->level->getBlock((int) $this->x, (int) $this->y, (int) $this->z);
|
||||||
if($block == WATER || $block == STILL_WATER){
|
if($block == WATER || $block == STILL_WATER){
|
||||||
$v16 = ((int)$this->y + 1) - LiquidBlock::getPercentAir($meta);
|
$v16 = ((int) $this->y + 1) - LiquidBlock::getPercentAir($meta);
|
||||||
if($this->boundingBox->intersectsWith(new AxisAlignedBB((int)$this->x, (int)$this->y, (int)$this->z, (int)$this->x + 1, $v16, (int)$this->z + 1))){
|
if($this->boundingBox->intersectsWith(new AxisAlignedBB((int) $this->x, (int) $this->y, (int) $this->z, (int) $this->x + 1, $v16, (int) $this->z + 1))){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for($y = (int)$this->y; $y < 129; $y++){
|
for($y = (int) $this->y; $y < 129; $y++){
|
||||||
$block = $this->level->level->getBlockID($this->x, $y, $this->z);
|
$block = $this->level->level->getBlockID($this->x, $y, $this->z);
|
||||||
if(StaticBlock::getIsSolid($block)){
|
if(StaticBlock::getIsSolid($block)){
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Spider extends Monster{
|
class Spider extends Monster{
|
||||||
const TYPE = MOB_SPIDER;
|
const TYPE = MOB_SPIDER;
|
||||||
|
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
$this->setSize(1.4, 0.9);
|
$this->setSize(1.4, 0.9);
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false);
|
$this->setHealth($this->data["Health"] ?? 8, "generic", allowHarm: false);
|
||||||
|
|
@ -23,10 +24,10 @@ class Spider extends Monster{
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
$diffX = $entity->x - $this->x;
|
$diffX = $entity->x - $this->x;
|
||||||
$diffZ = $entity->z - $this->z;
|
$diffZ = $entity->z - $this->z;
|
||||||
$dist = sqrt($diffX*$diffX + $diffZ*$diffZ);
|
$dist = sqrt($diffX * $diffX + $diffZ * $diffZ);
|
||||||
|
|
||||||
$this->speedX = $diffX / $dist*0.5*0.8 + $this->speedX*0.2;
|
$this->speedX = $diffX / $dist * 0.5 * 0.8 + $this->speedX * 0.2;
|
||||||
$this->speedZ = $diffZ / $dist*0.5*0.8 + $this->speedZ*0.2;
|
$this->speedZ = $diffZ / $dist * 0.5 * 0.8 + $this->speedZ * 0.2;
|
||||||
$this->speedY = 0.4;
|
$this->speedY = 0.4;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class LiquidBlock extends TransparentBlock{
|
||||||
return match(static::$blockID){
|
return match(static::$blockID){
|
||||||
WATER, STILL_WATER => $id == WATER || $id == STILL_WATER ? $meta : -1,
|
WATER, STILL_WATER => $id == WATER || $id == STILL_WATER ? $meta : -1,
|
||||||
LAVA, STILL_LAVA => $id == LAVA || $id == STILL_LAVA ? $meta : -1,
|
LAVA, STILL_LAVA => $id == LAVA || $id == STILL_LAVA ? $meta : -1,
|
||||||
default=> -1
|
default => -1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ class LiquidBlock extends TransparentBlock{
|
||||||
$flowVector->z += ($v10 - $z) * $v12;
|
$flowVector->z += ($v10 - $z) * $v12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if($v11 >= 0){
|
}elseif($v11 >= 0){
|
||||||
$v12 = $v11 - $v6;
|
$v12 = $v11 - $v6;
|
||||||
$flowVector->x += ($v8 - $x) * $v12;
|
$flowVector->x += ($v8 - $x) * $v12;
|
||||||
$flowVector->y += ($y - $y) * $v12;
|
$flowVector->y += ($y - $y) * $v12;
|
||||||
|
|
@ -168,10 +168,10 @@ class LiquidBlock extends TransparentBlock{
|
||||||
|
|
||||||
if(
|
if(
|
||||||
$zNeg == WATER || $zNeg == STILL_WATER
|
$zNeg == WATER || $zNeg == STILL_WATER
|
||||||
|| $zPos == WATER || $zPos == STILL_WATER
|
|| $zPos == WATER || $zPos == STILL_WATER
|
||||||
|| $xNeg == WATER || $xNeg == STILL_WATER
|
|| $xNeg == WATER || $xNeg == STILL_WATER
|
||||||
|| $xPos == WATER || $xPos == STILL_WATER
|
|| $xPos == WATER || $xPos == STILL_WATER
|
||||||
|| $yPos == WATER || $yPos == STILL_WATER
|
|| $yPos == WATER || $yPos == STILL_WATER
|
||||||
) {
|
) {
|
||||||
if($meta){
|
if($meta){
|
||||||
//if($meta > 4) -> fizz & ret
|
//if($meta > 4) -> fizz & ret
|
||||||
|
|
@ -184,12 +184,11 @@ 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(){
|
||||||
return (($this->meta >= 8 ? 0 : $this->meta)+1) / 9;
|
return (($this->meta >= 8 ? 0 : $this->meta) + 1) / 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,11 +52,11 @@ class StairBlock extends TransparentBlock{
|
||||||
$cid = self::$complexStateID;
|
$cid = self::$complexStateID;
|
||||||
StaticBlock::setBlockBounds($id,
|
StaticBlock::setBlockBounds($id,
|
||||||
0.5 * ($cid % 2),
|
0.5 * ($cid % 2),
|
||||||
0.5 * ((int)($cid / 2) % 2),
|
0.5 * ((int) ($cid / 2) % 2),
|
||||||
0.5 * ((int)($cid / 4) % 2),
|
0.5 * ((int) ($cid / 4) % 2),
|
||||||
0.5 + 0.5 * ($cid % 2),
|
0.5 + 0.5 * ($cid % 2),
|
||||||
0.5 + 0.5 * ((int)($cid / 2) % 2),
|
0.5 + 0.5 * ((int) ($cid / 2) % 2),
|
||||||
0.5 + 0.5 * ((int)($cid / 4) % 2)
|
0.5 + 0.5 * ((int) ($cid / 4) % 2)
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
StaticBlock::setBlockBounds($level->level->getBlockID($x, $y, $z), 0, 0, 0, 1, 1, 1);
|
StaticBlock::setBlockBounds($level->level->getBlockID($x, $y, $z), 0, 0, 0, 1, 1, 1);
|
||||||
|
|
@ -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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ class LadderBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ class SignPostBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(SIGN, 0, 1),
|
[SIGN, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
||||||
2 => $level->level->getBlockID($x + 1, $y, $z),
|
2 => $level->level->getBlockID($x + 1, $y, $z),
|
||||||
3 => $level->level->getBlockID($x, $y, $z - 1),
|
3 => $level->level->getBlockID($x, $y, $z - 1),
|
||||||
4 => $level->level->getBlockID($x, $y, $z + 1),
|
4 => $level->level->getBlockID($x, $y, $z + 1),
|
||||||
default => $level->level->getBlockID($x, $y - 1, $z)
|
default => $level->level->getBlockID($x, $y - 1, $z)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(StaticBlock::getIsTransparent($attach) && !($side === 0 && $attach === FENCE)){ //Replace with common break method
|
if(StaticBlock::getIsTransparent($attach) && !($side === 0 && $attach === FENCE)){ //Replace with common break method
|
||||||
|
|
@ -36,13 +36,13 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($target->isTransparent === false and $face !== 0){
|
if($target->isTransparent === false and $face !== 0){
|
||||||
$faces = array(
|
$faces = [
|
||||||
1 => 5,
|
1 => 5,
|
||||||
2 => 4,
|
2 => 4,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
4 => 2,
|
4 => 2,
|
||||||
5 => 1,
|
5 => 1,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$face];
|
$this->meta = $faces[$face];
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -54,8 +54,8 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -61,21 +61,21 @@ class TrapdoorBlock extends TransparentBlock{
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
|
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
|
||||||
$faces = array(
|
$faces = [
|
||||||
2 => 0,
|
2 => 0,
|
||||||
3 => 1,
|
3 => 1,
|
||||||
4 => 2,
|
4 => 2,
|
||||||
5 => 3,
|
5 => 3,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$face] & 0x03;
|
$this->meta = $faces[$face] & 0x03;
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
$attach = match($level->level->getBlockDamage($x, $y, $z)){
|
$attach = match($level->level->getBlockDamage($x, $y, $z)){
|
||||||
|
|
|
||||||
|
|
@ -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{
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
public function getMaxLightValue(){
|
public function getMaxLightValue(){
|
||||||
return 15;
|
return 15;
|
||||||
|
|
@ -82,6 +82,5 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
||||||
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||||
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,24 +19,24 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
$this->meta = 1;
|
$this->meta = 1;
|
||||||
$this->level->setBlock($this,$this);
|
$this->level->setBlock($this,$this);
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
$server->schedule(40, array($this, "glow"), 1);
|
$server->schedule(40, [$this, "glow"], 1);
|
||||||
$server->schedule(60, array($this, "glow"), 2);
|
$server->schedule(60, [$this, "glow"], 2);
|
||||||
$server->schedule(80, array($this, "glow"), 3);
|
$server->schedule(80, [$this, "glow"], 3);
|
||||||
$server->schedule(140, array($this, "glow"), 4);
|
$server->schedule(140, [$this, "glow"], 4);
|
||||||
$server->schedule(200, array($this, "spawnItems"), [0,15,2,true]); //200
|
$server->schedule(200, [$this, "spawnItems"], [0,15,2,true]); //200
|
||||||
$server->schedule(260, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
$server->schedule(260, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||||
$server->schedule(300, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
$server->schedule(300, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||||
$server->schedule(340, array($this, "spawnItems"), [11,20,"checkPigmen",false]);
|
$server->schedule(340, [$this, "spawnItems"], [11,20,"checkPigmen",false]);
|
||||||
$server->schedule(400, array($this, "spawnItems"), [0,10,"checkPigmen",false]);
|
$server->schedule(400, [$this, "spawnItems"], [0,10,"checkPigmen",false]);
|
||||||
$server->schedule(500, array($this, "spawnItems"), [17,32, "checkPigmen",false]); //500
|
$server->schedule(500, [$this, "spawnItems"], [17,32, "checkPigmen",false]); //500
|
||||||
$server->schedule(580, array($this, "spawnItems"), [17,32, "checkPigmen",false]);
|
$server->schedule(580, [$this, "spawnItems"], [17,32, "checkPigmen",false]);
|
||||||
$server->schedule(620, array($this, "spawnItems"), [1,32, "checkPigmen",false]);
|
$server->schedule(620, [$this, "spawnItems"], [1,32, "checkPigmen",false]);
|
||||||
$server->schedule(660, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
$server->schedule(660, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||||
$server->schedule(700, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
$server->schedule(700, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||||
$server->schedule(860, array($this, "glow"), 5);
|
$server->schedule(860, [$this, "glow"], 5);
|
||||||
$server->schedule(880, array($this, "glow"), 6);
|
$server->schedule(880, [$this, "glow"], 6);
|
||||||
$server->schedule(900, array($this, "glow"), 7);
|
$server->schedule(900, [$this, "glow"], 7);
|
||||||
$server->schedule(920, array($this, "destroy"));
|
$server->schedule(920, [$this, "destroy"]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
@ -45,12 +45,12 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
|
|
||||||
public function destroy(){
|
public function destroy(){
|
||||||
$this->level->setBlock(new Vector3($this->x, $this->y, $this->z),new NetherReactorBlock(2));
|
$this->level->setBlock(new Vector3($this->x, $this->y, $this->z),new NetherReactorBlock(2));
|
||||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
|
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 0, 17, 16, 2, 34, 1, 0, 17, 1);
|
||||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
|
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 1, 16, 1, 2, 34, 1, 0, 17, 16);
|
||||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
|
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 3, 14, 10, 8, 34, 1, 3, 14, 1);
|
||||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
|
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 4, 13, 1, 8, 34, 1, 3, 14, 10);
|
||||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
|
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 5, 12, 6, 14, 34, 1, 5, 12, 1);
|
||||||
$this->decay($this->x-8, $this->y-3, $this->z-8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
|
$this->decay($this->x - 8, $this->y - 3, $this->z - 8, 6, 11, 1, 14, 34, 1, 5, 12, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
|
|
@ -63,8 +63,8 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
for($a = $aOne; $a < $aTwo; $a += $aThree) {
|
for($a = $aOne; $a < $aTwo; $a += $aThree) {
|
||||||
for($b = $bOne; $b < $bTwo; $b += $bThree) {
|
for($b = $bOne; $b < $bTwo; $b += $bThree) {
|
||||||
for($c = $cOne; $c < $cTwo; $c += $cThree) {
|
for($c = $cOne; $c < $cTwo; $c += $cThree) {
|
||||||
if ($this->level->level->getBlockID($x+$a, $y+$b, $z+$c) === NETHERRACK && lcg_value() > 0.75){
|
if ($this->level->level->getBlockID($x + $a, $y + $b, $z + $c) === NETHERRACK && lcg_value() > 0.75){
|
||||||
$this->level->fastSetBlockUpdate($x+$a, $y+$b, $z+$c, 0, 0);
|
$this->level->fastSetBlockUpdate($x + $a, $y + $b, $z + $c, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,28 +92,28 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
$forceAmount = $data[3];
|
$forceAmount = $data[3];
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
if(!$forceAmount){
|
if(!$forceAmount){
|
||||||
$spawnNumber = $minAmount + floor(lcg_value()*($maxAmount-$minAmount+1));
|
$spawnNumber = $minAmount + floor(lcg_value() * ($maxAmount - $minAmount + 1));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$spawnNumber = $maxAmount;
|
$spawnNumber = $maxAmount;
|
||||||
}
|
}
|
||||||
for($i = 0; $i < $spawnNumber; $i++) {
|
for($i = 0; $i < $spawnNumber; $i++) {
|
||||||
$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));
|
||||||
if(Utils::chance(5)) $randomID = $this->rarePossibleLoot[array_rand($this->rarePossibleLoot)];
|
if(Utils::chance(5)) $randomID = $this->rarePossibleLoot[array_rand($this->rarePossibleLoot)];
|
||||||
else $randomID = $this->possibleLoot[array_rand($this->possibleLoot)];
|
else $randomID = $this->possibleLoot[array_rand($this->possibleLoot)];
|
||||||
$server->api->entity->drop(new Position($x+($shiftX*$randomRange)+0.5, $y, $z+($shiftZ*$randomRange)+0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
|
$server->api->entity->drop(new Position($x + ($shiftX * $randomRange) + 0.5, $y, $z + ($shiftZ * $randomRange) + 0.5, $this->level), BlockAPI::getItem($randomID, 0, 1));
|
||||||
}
|
}
|
||||||
for($i = 0; $i < $pigmen; $i++) {
|
for($i = 0; $i < $pigmen; $i++) {
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
@ -124,63 +124,63 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
$z = $this->z;
|
$z = $this->z;
|
||||||
switch($part){
|
switch($part){
|
||||||
case 1:
|
case 1:
|
||||||
$this->level->setBlock(new Vector3($x, $y-1, $z),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y - 1, $z),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y-1, $z+1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y-1, $z-1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$this->level->setBlock(new Vector3($x+1, $y, $z+1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y, $z + 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y, $z-1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y, $z - 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y, $z+1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y, $z + 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y, $z-1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y, $z - 1),new GlowingObsidianBlock);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$this->level->setBlock(new Vector3($x, $y+1, $z),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y + 1, $z),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y+1, $z+1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y + 1, $z + 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y+1, $z-1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y + 1, $z - 1),new GlowingObsidianBlock);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z + 1),new GlowingObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new GlowingObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z - 1),new GlowingObsidianBlock);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
$this->level->setBlock(new Vector3($x, $y+1, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y + 1, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y+1, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y + 1, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y+1, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y + 1, $z - 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y+1, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y + 1, $z - 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y+1, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y + 1, $z - 1),new ObsidianBlock);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$this->level->setBlock(new Vector3($x, $y, $z), new NetherReactorBlock(2));
|
$this->level->setBlock(new Vector3($x, $y, $z), new NetherReactorBlock(2));
|
||||||
$this->level->setBlock(new Vector3($x+1, $y, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y, $z - 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y, $z - 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y, $z - 1),new ObsidianBlock);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
$this->level->setBlock(new Vector3($x, $y-1, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y - 1, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y-1, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y - 1, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x, $y-1, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x, $y - 1, $z - 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x+1, $y-1, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x + 1, $y - 1, $z - 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z+1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z + 1),new ObsidianBlock);
|
||||||
$this->level->setBlock(new Vector3($x-1, $y-1, $z-1),new ObsidianBlock);
|
$this->level->setBlock(new Vector3($x - 1, $y - 1, $z - 1),new ObsidianBlock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -234,6 +234,6 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
private $core = [
|
private $core = [
|
||||||
-1 => ["GCG", "CCC", "GCG"],
|
-1 => ["GCG", "CCC", "GCG"],
|
||||||
0 => ["C C", " R ", "C C",],
|
0 => ["C C", " R ", "C C",],
|
||||||
1 =>[" C ", "CCC", " C "]
|
1 => [" C ", "CCC", " C "]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class CakeBlock extends TransparentBlock{
|
||||||
|
|
||||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||||
$data = $level->level->getBlockDamage($x, $y, $z);
|
$data = $level->level->getBlockDamage($x, $y, $z);
|
||||||
return [new AxisAlignedBB($x + (2*$data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
|
return [new AxisAlignedBB($x + (2 * $data + 1) * 0.0625, $y, $z + 0.0625, $x + 0.9375, $y + 0.5, $z + 0.9375)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updateShape(Level $level, $x, $y, $z){
|
public static function updateShape(Level $level, $x, $y, $z){
|
||||||
|
|
@ -39,7 +39,7 @@ class CakeBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ class ChestBlock extends TransparentBlock{
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 4,
|
0 => 4,
|
||||||
1 => 2,
|
1 => 2,
|
||||||
2 => 5,
|
2 => 5,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
);
|
];
|
||||||
|
|
||||||
$chest = false;
|
$chest = false;
|
||||||
$this->meta = $faces[$player->entity->getDirection()];
|
$this->meta = $faces[$player->entity->getDirection()];
|
||||||
|
|
@ -42,13 +42,13 @@ class ChestBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||||
"Items" => array(),
|
"Items" => [],
|
||||||
"id" => TILE_CHEST,
|
"id" => TILE_CHEST,
|
||||||
"x" => $this->x,
|
"x" => $this->x,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z
|
"z" => $this->z
|
||||||
));
|
]);
|
||||||
$server->api->tile->spawnToAll($tile);
|
$server->api->tile->spawnToAll($tile);
|
||||||
|
|
||||||
if($chest instanceof Tile){
|
if($chest instanceof Tile){
|
||||||
|
|
@ -79,17 +79,15 @@ class ChestBlock extends TransparentBlock{
|
||||||
if($t !== false){
|
if($t !== false){
|
||||||
$chest = $t;
|
$chest = $t;
|
||||||
}else{
|
}else{
|
||||||
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||||
"Items" => array(),
|
"Items" => [],
|
||||||
"id" => TILE_CHEST,
|
"id" => TILE_CHEST,
|
||||||
"x" => $this->x,
|
"x" => $this->x,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z
|
"z" => $this->z
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(($player->gamemode & 0x01) === 0x01){
|
if(($player->gamemode & 0x01) === 0x01){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -99,15 +97,15 @@ class ChestBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
$drops = array(
|
$drops = [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
$t = ServerAPI::request()->api->tile->get($this);
|
$t = ServerAPI::request()->api->tile->get($this);
|
||||||
if($t !== false and $t->class === TILE_CHEST){
|
if($t !== false and $t->class === TILE_CHEST){
|
||||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||||
$slot = $t->getSlot($s);
|
$slot = $t->getSlot($s);
|
||||||
if($slot->getID() > AIR and $slot->count > 0){
|
if($slot->getID() > AIR and $slot->count > 0){
|
||||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class CobwebBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
elseif ($item->isShears()){
|
elseif ($item->isShears()){
|
||||||
return [
|
return [
|
||||||
array(COBWEB, 0, 1),
|
[COBWEB, 0, 1],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ class FarmlandBlock extends TransparentBlock{
|
||||||
$this->material = Material::$dirt;
|
$this->material = Material::$dirt;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(DIRT, 0, 1),
|
[DIRT, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public function hasCrops(){
|
public function hasCrops(){
|
||||||
//TODO vanilla 0.8.1 detection method
|
//TODO vanilla 0.8.1 detection method
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,20 @@ class FenceGateBlock extends TransparentBlock{
|
||||||
$this->material = Material::$wood;
|
$this->material = Material::$wood;
|
||||||
}
|
}
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 3,
|
0 => 3,
|
||||||
1 => 0,
|
1 => 0,
|
||||||
2 => 1,
|
2 => 1,
|
||||||
3 => 2,
|
3 => 2,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ class FenceGateBlock extends TransparentBlock{
|
||||||
$meta ^= 4;
|
$meta ^= 4;
|
||||||
}else{
|
}else{
|
||||||
$direction = ($player->entity->yaw * 4 / 360) + 0.5;
|
$direction = ($player->entity->yaw * 4 / 360) + 0.5;
|
||||||
$blockDirection = (int)$direction;
|
$blockDirection = (int) $direction;
|
||||||
if($direction < $blockDirection) --$blockDirection;
|
if($direction < $blockDirection) --$blockDirection;
|
||||||
$blockDirection &= 3;
|
$blockDirection &= 3;
|
||||||
if(($meta & 3) == (($blockDirection + 2) & 3)){
|
if(($meta & 3) == (($blockDirection + 2) & 3)){
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class GlassPaneBlock extends TransparentBlock{
|
||||||
|
|
||||||
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
||||||
if($var11 && !$var12) $minX = 0;
|
if($var11 && !$var12) $minX = 0;
|
||||||
else if(!$var11 && $var12) $maxX = 1;
|
elseif(!$var11 && $var12) $maxX = 1;
|
||||||
}else{
|
}else{
|
||||||
$minX = 0;
|
$minX = 0;
|
||||||
$maxX = 1;
|
$maxX = 1;
|
||||||
|
|
@ -33,7 +33,7 @@ class GlassPaneBlock extends TransparentBlock{
|
||||||
|
|
||||||
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
||||||
if($var9 && !$var10) $minZ = 0;
|
if($var9 && !$var10) $minZ = 0;
|
||||||
else if(!$var9 && $var10) $maxZ = 1;
|
elseif(!$var9 && $var10) $maxZ = 1;
|
||||||
}else{
|
}else{
|
||||||
$minZ = 0;
|
$minZ = 0;
|
||||||
$maxZ = 1;
|
$maxZ = 1;
|
||||||
|
|
@ -69,8 +69,8 @@ class GlassPaneBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(GLASS_PANE, 0, 0),
|
[GLASS_PANE, 0, 0],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +26,7 @@ class IronBarsBlock extends TransparentBlock{
|
||||||
|
|
||||||
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
if((!$var11 || !$var12) && ($var11 || $var12 || $var9 || $var10)){
|
||||||
if($var11 && !$var12) $minX = 0;
|
if($var11 && !$var12) $minX = 0;
|
||||||
else if(!$var11 && $var12) $maxX = 1;
|
elseif(!$var11 && $var12) $maxX = 1;
|
||||||
}else{
|
}else{
|
||||||
$minX = 0;
|
$minX = 0;
|
||||||
$maxX = 1;
|
$maxX = 1;
|
||||||
|
|
@ -34,7 +34,7 @@ class IronBarsBlock extends TransparentBlock{
|
||||||
|
|
||||||
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
if((!$var9 || !$var10) && ($var11 || $var12 || $var9 || $var10)){
|
||||||
if($var9 && !$var10) $minZ = 0;
|
if($var9 && !$var10) $minZ = 0;
|
||||||
else if(!$var9 && $var10) $maxZ = 1;
|
elseif(!$var9 && $var10) $maxZ = 1;
|
||||||
}else{
|
}else{
|
||||||
$minZ = 0;
|
$minZ = 0;
|
||||||
$maxZ = 1;
|
$maxZ = 1;
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class IronDoorBlock extends DoorBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(IRON_DOOR, 0, 1),
|
[IRON_DOOR, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,11 +108,11 @@ class SlabBlock extends TransparentBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta & 0x07, 1),
|
[$this->id, $this->meta & 0x07, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class StoneWallBlock extends TransparentBlock{
|
||||||
$minX = 0.3125;
|
$minX = 0.3125;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(!$zPos && $zNeg){
|
}elseif(!$zPos && $zNeg){
|
||||||
if($xPos){
|
if($xPos){
|
||||||
$maxY = 0.8125;
|
$maxY = 0.8125;
|
||||||
$maxZ = 0.6875;
|
$maxZ = 0.6875;
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ class WoodDoorBlock extends DoorBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(WOODEN_DOOR, 0, 1),
|
[WOODEN_DOOR, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ class BirchWoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,8 +10,8 @@ class JungleWoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,8 +10,8 @@ class SpruceWoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,8 +25,8 @@ class WoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class CoalOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(COAL, 0, 1),
|
[COAL, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ class DiamondOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(DIAMOND, 0, 1),
|
[DIAMOND, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ class GoldOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(GOLD_ORE, 0, 1),
|
[GOLD_ORE, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ class IronOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
|
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
|
||||||
return array(
|
return [
|
||||||
array(IRON_ORE, 0, 1),
|
[IRON_ORE, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ class LapisOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 3){
|
if($item->getPickaxeLevel() >= 3){
|
||||||
return array(
|
return [
|
||||||
array(DYE, 4, mt_rand(4, 8)),
|
[DYE, 4, mt_rand(4, 8)],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@ class RedstoneOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,8 +70,8 @@ class CactusBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,17 +23,14 @@ class CyanFlowerBlock extends FlowableBlock{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
$downId = $level->level->getBlockID($x, $y - 1, $z);
|
$downId = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
|
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
|
||||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(CYAN_FLOWER));
|
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CYAN_FLOWER));
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||||
$random = new Random();
|
$random = new Random();
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@ class SaplingBlock extends FlowableBlock{
|
||||||
public function __construct($meta = SaplingBlock::OAK){
|
public function __construct($meta = SaplingBlock::OAK){
|
||||||
parent::__construct(SAPLING, $meta, "Sapling");
|
parent::__construct(SAPLING, $meta, "Sapling");
|
||||||
$this->isActivable = true;
|
$this->isActivable = true;
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "Oak Sapling",
|
0 => "Oak Sapling",
|
||||||
1 => "Spruce Sapling",
|
1 => "Spruce Sapling",
|
||||||
2 => "Birch Sapling",
|
2 => "Birch Sapling",
|
||||||
3 => "Jungle Sapling",
|
3 => "Jungle Sapling",
|
||||||
);
|
];
|
||||||
$this->name = $names[$this->meta & 0x03];
|
$this->name = $names[$this->meta & 0x03];
|
||||||
$this->hardness = 0;
|
$this->hardness = 0;
|
||||||
$this->breakTime = 0;
|
$this->breakTime = 0;
|
||||||
|
|
@ -46,7 +46,7 @@ class SaplingBlock extends FlowableBlock{
|
||||||
$downID = $level->level->getBlockID($x, $y - 1, $z);
|
$downID = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
|
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem($id, $meta));
|
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem($id, $meta));
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,8 +63,8 @@ class SaplingBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta & 0x03, 1),
|
[$this->id, $this->meta & 0x03, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ class TallGrassBlock extends FlowableBlock{
|
||||||
public function __construct($meta = 1){
|
public function __construct($meta = 1){
|
||||||
parent::__construct(TALL_GRASS, $meta, "Tall Grass");
|
parent::__construct(TALL_GRASS, $meta, "Tall Grass");
|
||||||
$this->isReplaceable = true;
|
$this->isReplaceable = true;
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "Dead Shrub",
|
0 => "Dead Shrub",
|
||||||
1 => "Tall Grass",
|
1 => "Tall Grass",
|
||||||
2 => "Fern",
|
2 => "Fern",
|
||||||
);
|
];
|
||||||
$this->name = $names[$this->meta & 0x03];
|
$this->name = $names[$this->meta & 0x03];
|
||||||
$this->hardness = 0;
|
$this->hardness = 0;
|
||||||
$this->breakTime = 0;
|
$this->breakTime = 0;
|
||||||
|
|
@ -19,7 +19,7 @@ class TallGrassBlock extends FlowableBlock{
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
$downID = $level->level->getBlockID($x, $y - 1, $z);
|
$downID = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
|
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
|
||||||
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(WHEAT_SEEDS));
|
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(WHEAT_SEEDS));
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,9 +29,9 @@ class TallGrassBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
$drops = array();
|
$drops = [];
|
||||||
if($item->isShears()) $drops[] = array($this->id, $this->meta & 0x03, 1);
|
if($item->isShears()) $drops[] = [$this->id, $this->meta & 0x03, 1];
|
||||||
elseif(Utils::chance(15)) $drops[] = array(WHEAT_SEEDS, 0, 1);
|
elseif(Utils::chance(15)) $drops[] = [WHEAT_SEEDS, 0, 1];
|
||||||
return $drops;
|
return $drops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class BricksBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(BRICKS_BLOCK, 0, 1),
|
[BRICKS_BLOCK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 4,
|
0 => 4,
|
||||||
1 => 2,
|
1 => 2,
|
||||||
2 => 5,
|
2 => 5,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$player->entity->getDirection()];
|
$this->meta = $faces[$player->entity->getDirection()];
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -39,13 +39,13 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
||||||
if($t !== false){
|
if($t !== false){
|
||||||
$furnace = $t;
|
$furnace = $t;
|
||||||
}else{
|
}else{
|
||||||
$furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, array(
|
$furnace = $server->api->tile->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, [
|
||||||
"Items" => array(),
|
"Items" => [],
|
||||||
"id" => TILE_FURNACE,
|
"id" => TILE_FURNACE,
|
||||||
"x" => $this->x,
|
"x" => $this->x,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z
|
"z" => $this->z
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($player->gamemode & 0x01) === 0x01){
|
if(($player->gamemode & 0x01) === 0x01){
|
||||||
|
|
@ -71,16 +71,16 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
$drops = array();
|
$drops = [];
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
$drops[] = array(FURNACE, 0, 1);
|
$drops[] = [FURNACE, 0, 1];
|
||||||
}
|
}
|
||||||
$t = ServerAPI::request()->api->tile->get($this);
|
$t = ServerAPI::request()->api->tile->get($this);
|
||||||
if($t !== false and $t->class === TILE_FURNACE){
|
if($t !== false and $t->class === TILE_FURNACE){
|
||||||
for($s = 0; $s < FURNACE_SLOTS; ++$s){
|
for($s = 0; $s < FURNACE_SLOTS; ++$s){
|
||||||
$slot = $t->getSlot($s);
|
$slot = $t->getSlot($s);
|
||||||
if($slot->getID() > AIR and $slot->count > 0){
|
if($slot->getID() > AIR and $slot->count > 0){
|
||||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ class ClayBlock extends SolidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(CLAY, 0, 4),
|
[CLAY, 0, 4],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,11 +26,11 @@ class CoalBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(COAL_BLOCK, 0, 1),
|
[COAL_BLOCK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class CobblestoneBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(COBBLESTONE, 0, 1),
|
[COBBLESTONE, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ class DiamondBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(DIAMOND_BLOCK, 0, 1),
|
[DIAMOND_BLOCK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,33 +31,33 @@ class DirtBlock extends SolidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getGrassInRadius(Level $level, $x, $y, $z){ //umwut (although kinda faster than for loop =D)
|
public static function getGrassInRadius(Level $level, $x, $y, $z){ //umwut (although kinda faster than for loop =D)
|
||||||
if($level->level->getBlockID($x+1, $y, $z+1) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x+1, $y, $z) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x+1, $y, $z-1) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y, $z - 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y, $z+1) == 2) return true;
|
if($level->level->getBlockID($x, $y, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y, $z-1) == 2) return true;
|
if($level->level->getBlockID($x, $y, $z - 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y, $z+1) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y, $z) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y, $z-1) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y, $z - 1) == 2) return true;
|
||||||
|
|
||||||
if($level->level->getBlockID($x+1, $y-1, $z+1) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y - 1, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x+1, $y-1, $z) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y - 1, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x+1, $y-1, $z-1) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y - 1, $z - 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y-1, $z+1) == 2) return true;
|
if($level->level->getBlockID($x, $y - 1, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y-1, $z) == 2) return true;
|
if($level->level->getBlockID($x, $y - 1, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y-1, $z-1) == 2) return true;
|
if($level->level->getBlockID($x, $y - 1, $z - 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y-1, $z+1) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y - 1, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y-1, $z) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y - 1, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y-1, $z-1) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y - 1, $z - 1) == 2) return true;
|
||||||
|
|
||||||
if($level->level->getBlockID($x+1, $y+1, $z+1) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y + 1, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x+1, $y+1, $z) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y + 1, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x+1, $y+1, $z-1) == 2) return true;
|
if($level->level->getBlockID($x + 1, $y + 1, $z - 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y+1, $z+1) == 2) return true;
|
if($level->level->getBlockID($x, $y + 1, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x, $y+1, $z-1) == 2) return true;
|
if($level->level->getBlockID($x, $y + 1, $z - 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y+1, $z+1) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y + 1, $z + 1) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y+1, $z) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y + 1, $z) == 2) return true;
|
||||||
if($level->level->getBlockID($x-1, $y+1, $z-1) == 2) return true;
|
if($level->level->getBlockID($x - 1, $y + 1, $z - 1) == 2) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class DoubleSlabBlock extends SolidBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(DOUBLE_SLAB, $meta, "Double Slab");
|
parent::__construct(DOUBLE_SLAB, $meta, "Double Slab");
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "Stone",
|
0 => "Stone",
|
||||||
1 => "Sandstone",
|
1 => "Sandstone",
|
||||||
2 => "Wooden",
|
2 => "Wooden",
|
||||||
|
|
@ -13,7 +13,7 @@ class DoubleSlabBlock extends SolidBlock{
|
||||||
5 => "Stone Brick",
|
5 => "Stone Brick",
|
||||||
6 => "Quartz",
|
6 => "Quartz",
|
||||||
7 => "Smooth Stone",
|
7 => "Smooth Stone",
|
||||||
);
|
];
|
||||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||||
$this->hardness = 30;
|
$this->hardness = 30;
|
||||||
$this->breakTime = 2;
|
$this->breakTime = 2;
|
||||||
|
|
@ -37,11 +37,11 @@ class DoubleSlabBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(SLAB, $this->meta & 0x07, 2),
|
[SLAB, $this->meta & 0x07, 2],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ class DoubleWoodSlabBlock extends SolidBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab");
|
parent::__construct(DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab");
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "Oak",
|
0 => "Oak",
|
||||||
1 => "Spruce",
|
1 => "Spruce",
|
||||||
2 => "Birch",
|
2 => "Birch",
|
||||||
3 => "Jungle",
|
3 => "Jungle",
|
||||||
);
|
];
|
||||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
|
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||||
$this->hardness = 30;
|
$this->hardness = 30;
|
||||||
$this->breakTime = 2;
|
$this->breakTime = 2;
|
||||||
|
|
@ -34,9 +34,9 @@ class DoubleWoodSlabBlock extends SolidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(WOOD_SLAB, $this->meta & 0x07, 2),
|
[WOOD_SLAB, $this->meta & 0x07, 2],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
require_once("BurningFurnaceBlock.php");
|
require_once("BurningFurnaceBlock.php");
|
||||||
/***REM_END***/
|
/***REM_END***/
|
||||||
|
|
||||||
|
|
||||||
class FurnaceBlock extends BurningFurnaceBlock{
|
class FurnaceBlock extends BurningFurnaceBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class GlassBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(GLOWSTONE_DUST, 0, mt_rand(2, 4)),
|
[GLOWSTONE_DUST, 0, mt_rand(2, 4)],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ class GoldBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(GOLD_BLOCK, 0, 1),
|
[GOLD_BLOCK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ class HayBaleBlock extends SolidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 0,
|
0 => 0,
|
||||||
1 => 0,
|
1 => 0,
|
||||||
2 => 0b1000,
|
2 => 0b1000,
|
||||||
3 => 0b1000,
|
3 => 0b1000,
|
||||||
4 => 0b0100,
|
4 => 0b0100,
|
||||||
5 => 0b0100,
|
5 => 0b0100,
|
||||||
);
|
];
|
||||||
|
|
||||||
$this->meta = ($this->meta & 0x03) | $faces[$face];
|
$this->meta = ($this->meta & 0x03) | $faces[$face];
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
|
|
@ -26,9 +26,9 @@ class HayBaleBlock extends SolidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -24,11 +24,11 @@ class IronBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 3){
|
if($item->getPickaxeLevel() >= 3){
|
||||||
return array(
|
return [
|
||||||
array(IRON_BLOCK, 0, 1),
|
[IRON_BLOCK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ class LapisBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 3){
|
if($item->getPickaxeLevel() >= 3){
|
||||||
return array(
|
return [
|
||||||
array(LAPIS_BLOCK, 0, 1),
|
[LAPIS_BLOCK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
|
||||||
3 => 0,
|
3 => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(LIT_PUMPKIN, $meta, "Jack o'Lantern");
|
parent::__construct(LIT_PUMPKIN, $meta, "Jack o'Lantern");
|
||||||
$this->hardness = 5;
|
$this->hardness = 5;
|
||||||
|
|
@ -39,5 +38,4 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
@ -10,9 +10,9 @@ class MelonBlock extends TransparentBlock{
|
||||||
$this->lightBlock = 255;
|
$this->lightBlock = 255;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(MELON_SLICE, 0, mt_rand(3, 7)),
|
[MELON_SLICE, 0, mt_rand(3, 7)],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class MossStoneBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(MOSS_STONE, 0, 1),
|
[MOSS_STONE, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class NetherBricksBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(NETHER_BRICKS, 0, 1),
|
[NETHER_BRICKS, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@ class NetherrackBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(NETHERRACK, 0, 1),
|
[NETHERRACK, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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