mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
code style fix
This commit is contained in:
parent
fc5c5625cb
commit
5e8e9330e2
361 changed files with 4766 additions and 4650 deletions
|
|
@ -92,7 +92,6 @@ class AchievementAPI{
|
||||||
* Add an achievement
|
* Add an achievement
|
||||||
* @param string $achievementId
|
* @param string $achievementId
|
||||||
* @param string $achievementName
|
* @param string $achievementName
|
||||||
* @param array $requires
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function addAchievement($achievementId, $achievementName, array $requires = []){
|
public static function addAchievement($achievementId, $achievementName, array $requires = []){
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,6 @@ class BlockAPI{
|
||||||
return $this->cancelAction($target, $player, false);
|
return $this->cancelAction($target, $player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
|
if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
|
||||||
foreach($drops as $drop){
|
foreach($drops as $drop){
|
||||||
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
|
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
|
||||||
|
|
@ -541,8 +540,6 @@ class BlockAPI{
|
||||||
return $level;
|
return $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
||||||
|
|
||||||
if($type == BLOCK_UPDATE_NORMAL){
|
if($type == BLOCK_UPDATE_NORMAL){
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,6 @@ class ChatAPI{
|
||||||
/**
|
/**
|
||||||
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
|
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param $whitelist
|
|
||||||
* @param $blacklist
|
|
||||||
*/
|
*/
|
||||||
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
||||||
$message = [
|
$message = [
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ class EntityAPI{
|
||||||
$this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
|
$this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function commandHandler($cmd, $args, $issuer, $alias){
|
public function commandHandler($cmd, $args, $issuer, $alias){
|
||||||
$mob = [
|
$mob = [
|
||||||
"chicken" => 10,
|
"chicken" => 10,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ class LevelAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
||||||
if(file_exists($path . "tileEntities.yml")){
|
if(file_exists($path . "tileEntities.yml")){
|
||||||
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
||||||
|
|
|
||||||
|
|
@ -312,4 +312,3 @@ class RequiredPluginEntry{ //Use this as object of requirements array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,5 +175,4 @@ class TimeAPI{
|
||||||
return $this->set("sunset");
|
return $this->set("sunset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class Deprecation{
|
class Deprecation{
|
||||||
|
|
||||||
public static $events = [
|
public static $events = [
|
||||||
|
|
|
||||||
116
src/Player.php
116
src/Player.php
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
|
|
||||||
public static $smallChunks = false, $experimentalHotbar = false;
|
public static $smallChunks = false;
|
||||||
|
|
||||||
|
public static $experimentalHotbar = false;
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
public $data;
|
public $data;
|
||||||
/** @var Entity */
|
/** @var Entity */
|
||||||
|
|
@ -83,7 +84,8 @@ class Player{
|
||||||
* @var boolean $isJumping
|
* @var boolean $isJumping
|
||||||
* @var boolean $isSneaking
|
* @var boolean $isSneaking
|
||||||
*/
|
*/
|
||||||
public $isJumping, $isSneaking;
|
public $isJumping;
|
||||||
|
public $isSneaking;
|
||||||
|
|
||||||
private $lastPing = -1;
|
private $lastPing = -1;
|
||||||
|
|
||||||
|
|
@ -139,7 +141,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -160,8 +161,9 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
$spawnPoint = BedBlock::findStandUpPosition($this->level, $pos->x, $pos->y, $pos->z);
|
$spawnPoint = BedBlock::findStandUpPosition($this->level, $pos->x, $pos->y, $pos->z);
|
||||||
if($spawnPoint == null) $spawnPoint = $pos->add(0.5, 1, 0.5);
|
if($spawnPoint == null) {
|
||||||
else{
|
$spawnPoint = $pos->add(0.5, 1, 0.5);
|
||||||
|
} else {
|
||||||
$spawnPoint->x += 0.5;
|
$spawnPoint->x += 0.5;
|
||||||
$spawnPoint->z += 0.5;
|
$spawnPoint->z += 0.5;
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +177,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
|
||||||
* @param float|boolean $yaw
|
* @param float|boolean $yaw
|
||||||
* @param float|boolean $pitch
|
* @param float|boolean $pitch
|
||||||
* @param float|boolean $terrain
|
* @param float|boolean $terrain
|
||||||
|
|
@ -313,7 +314,9 @@ class Player{
|
||||||
$this->entity->calculateVelocity();
|
$this->entity->calculateVelocity();
|
||||||
if($terrain === true) {
|
if($terrain === true) {
|
||||||
$this->orderChunks();
|
$this->orderChunks();
|
||||||
if($this->spawned) $this->getNextChunk($this->level);
|
if($this->spawned) {
|
||||||
|
$this->getNextChunk($this->level);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->entity->check = true;
|
$this->entity->check = true;
|
||||||
if($force === true) {
|
if($force === true) {
|
||||||
|
|
@ -340,8 +343,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $id
|
|
||||||
* @param array $data
|
|
||||||
*
|
*
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
|
|
@ -380,7 +381,9 @@ class Player{
|
||||||
$sendtime = microtime(true);
|
$sendtime = microtime(true);
|
||||||
|
|
||||||
$size = $this->MTU - 34;
|
$size = $this->MTU - 34;
|
||||||
if($size <= 0) return false;
|
if($size <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$buffer = str_split($packet->buffer, $size);
|
$buffer = str_split($packet->buffer, $size);
|
||||||
$bigCnt = $this->bigCnt;
|
$bigCnt = $this->bigCnt;
|
||||||
$this->bigCnt = ($this->bigCnt + 1) % 0x10000;
|
$this->bigCnt = ($this->bigCnt + 1) % 0x10000;
|
||||||
|
|
@ -441,7 +444,6 @@ class Player{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $slot
|
* @param integer $slot
|
||||||
* @param Item $item
|
|
||||||
* @param boolean $send
|
* @param boolean $send
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
@ -650,9 +652,6 @@ class Player{
|
||||||
$this->server->schedule(MAX_CHUNK_RATE, [$this, "getNextChunk"], $world);
|
$this->server->schedule(MAX_CHUNK_RATE, [$this, "getNextChunk"], $world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Vector3 $pos
|
|
||||||
*/
|
|
||||||
public function setSpawn(Vector3 $pos) {
|
public function setSpawn(Vector3 $pos) {
|
||||||
if(!($pos instanceof Position)) {
|
if(!($pos instanceof Position)) {
|
||||||
$level = $this->entity->level;
|
$level = $this->entity->level;
|
||||||
|
|
@ -687,9 +686,6 @@ class Player{
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param $type
|
|
||||||
* @param $damage
|
|
||||||
* @param $count
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -902,8 +898,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $type
|
|
||||||
* @param $damage
|
|
||||||
* @param integer $count
|
* @param integer $count
|
||||||
* @param boolean $send
|
* @param boolean $send
|
||||||
*
|
*
|
||||||
|
|
@ -919,10 +913,14 @@ class Player{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$item->count += $add;
|
$item->count += $add;
|
||||||
if($send) $this->sendInventorySlot($s);
|
if($send) {
|
||||||
|
$this->sendInventorySlot($s);
|
||||||
|
}
|
||||||
|
|
||||||
$count -= $add;
|
$count -= $add;
|
||||||
if($count <= 0) return true;
|
if($count <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$toadd = BlockAPI::getItem($type, $damage, $count);
|
$toadd = BlockAPI::getItem($type, $damage, $count);
|
||||||
|
|
@ -930,12 +928,18 @@ class Player{
|
||||||
if($item->getID() === AIR) {
|
if($item->getID() === AIR) {
|
||||||
$add = min($toadd->getMaxStackSize(), $count);
|
$add = min($toadd->getMaxStackSize(), $count);
|
||||||
$this->inventory[$s] = BlockAPI::getItem($type, $damage, $add);
|
$this->inventory[$s] = BlockAPI::getItem($type, $damage, $add);
|
||||||
if($send) $this->sendInventorySlot($s);
|
if($send) {
|
||||||
|
$this->sendInventorySlot($s);
|
||||||
|
}
|
||||||
$count -= $add;
|
$count -= $add;
|
||||||
if($count <= 0) return true;
|
if($count <= 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($count <= 0) return true;
|
}
|
||||||
|
if($count <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -996,7 +1000,9 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkSpawnPosition() {
|
public function checkSpawnPosition() {
|
||||||
if($this->server->api->dhandle("player.checkspawnpos", ["player" => $this]) === false) return;
|
if($this->server->api->dhandle("player.checkspawnpos", ["player" => $this]) === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$level = $this->spawnPosition->level;
|
$level = $this->spawnPosition->level;
|
||||||
if(!isset($this->server->api->level->levels[$level->getName()])) {
|
if(!isset($this->server->api->level->levels[$level->getName()])) {
|
||||||
ConsoleAPI::warn("Level to respawn {$this->iusername} was unloaded, changing spawnpoint to default.");
|
ConsoleAPI::warn("Level to respawn {$this->iusername} was unloaded, changing spawnpoint to default.");
|
||||||
|
|
@ -1246,12 +1252,13 @@ class Player{
|
||||||
$cnt = $this->send($data);
|
$cnt = $this->send($data);
|
||||||
if(isset($this->chunkCount[$count])) {
|
if(isset($this->chunkCount[$count])) {
|
||||||
unset($this->chunkCount[$count]);
|
unset($this->chunkCount[$count]);
|
||||||
if(!is_null($cnt) and !is_null($cnt[0]))
|
if(!is_null($cnt) and !is_null($cnt[0])) {
|
||||||
$this->chunkCount[$cnt[0]] = true;
|
$this->chunkCount[$cnt[0]] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function sendEntityMovementUpdateQueue() {
|
public function sendEntityMovementUpdateQueue() {
|
||||||
if($this->entityMovementQueueLength > 0 && $this->entityMovementQueue instanceof RakNetPacket) {
|
if($this->entityMovementQueueLength > 0 && $this->entityMovementQueue instanceof RakNetPacket) {
|
||||||
$this->entityMovementQueue->seqNumber = $this->counter[0]++;
|
$this->entityMovementQueue->seqNumber = $this->counter[0]++;
|
||||||
|
|
@ -1358,7 +1365,9 @@ class Player{
|
||||||
++$packets;
|
++$packets;
|
||||||
$headSent = true;
|
$headSent = true;
|
||||||
}
|
}
|
||||||
if($packets <= 0) return;
|
if($packets <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//console("Update {$e}: $packets, mot: $motionSent, mov: $moveSent, hed: $headSent");
|
//console("Update {$e}: $packets, mot: $motionSent, mov: $moveSent, hed: $headSent");
|
||||||
$MTU = $this->MTU - 24;
|
$MTU = $this->MTU - 24;
|
||||||
if(($this->entityMovementQueueLength + $len) >= $MTU) {
|
if(($this->entityMovementQueueLength + $len) >= $MTU) {
|
||||||
|
|
@ -1491,7 +1500,9 @@ class Player{
|
||||||
return [$pk->seqNumber];
|
return [$pk->seqNumber];
|
||||||
}
|
}
|
||||||
public function entityTick() {
|
public function entityTick() {
|
||||||
if($this->isSleeping) ++$this->sleepingTime;
|
if($this->isSleeping) {
|
||||||
|
++$this->sleepingTime;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->server->difficulty == 0 && $this->entity->counter % (20 * 15) == 0) {
|
if($this->server->difficulty == 0 && $this->entity->counter % (20 * 15) == 0) {
|
||||||
if($this->entity->health < 20 && $this->entity->health > 0) {
|
if($this->entity->health < 20 && $this->entity->health > 0) {
|
||||||
|
|
@ -1652,7 +1663,6 @@ class Player{
|
||||||
|
|
||||||
$this->server->api->player->saveOffline($this->data);
|
$this->server->api->player->saveOffline($this->data);
|
||||||
|
|
||||||
|
|
||||||
$pk = new LoginStatusPacket;
|
$pk = new LoginStatusPacket;
|
||||||
$pk->status = 0;
|
$pk->status = 0;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
@ -1678,8 +1688,12 @@ class Player{
|
||||||
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
$this->hotbar = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
}
|
}
|
||||||
for($i = 0; $i < count($this->hotbar); ++$i) {
|
for($i = 0; $i < count($this->hotbar); ++$i) {
|
||||||
if($this->hotbar[$i] > 36) $this->hotbar[$i] = -1; //XXX unsafe?
|
if($this->hotbar[$i] > 36) {
|
||||||
if($this->hotbar[$i] < -1) $this->hotbar[$i] = -1;
|
$this->hotbar[$i] = -1;
|
||||||
|
} //XXX unsafe?
|
||||||
|
if($this->hotbar[$i] < -1) {
|
||||||
|
$this->hotbar[$i] = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($this->data->exists("slot-count")) {
|
if($this->data->exists("slot-count")) {
|
||||||
$this->slotCount = $this->data->get("slot-count");
|
$this->slotCount = $this->data->get("slot-count");
|
||||||
|
|
@ -1724,7 +1738,6 @@ class Player{
|
||||||
$pk->started = !$this->level->isTimeStopped();
|
$pk->started = !$this->level->isTimeStopped();
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
|
|
||||||
console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
|
console("[INFO] " . FORMAT_AQUA . $this->username . FORMAT_RESET . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->eid . " at (" . $this->entity->level->getName() . ", " . round($this->entity->x, 2) . ", " . round($this->entity->y, 2) . ", " . round($this->entity->z, 2) . ")");
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::READY_PACKET:
|
case ProtocolInfo::READY_PACKET:
|
||||||
|
|
@ -1785,7 +1798,9 @@ class Player{
|
||||||
if($this->spawned === false) {
|
if($this->spawned === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($this->isSleeping) break;
|
if($this->isSleeping) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(($this->entity instanceof Entity) and $packet->messageIndex > $this->lastMovement) {
|
if(($this->entity instanceof Entity) and $packet->messageIndex > $this->lastMovement) {
|
||||||
$this->lastMovement = $packet->messageIndex;
|
$this->lastMovement = $packet->messageIndex;
|
||||||
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
|
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||||
|
|
@ -1829,7 +1844,6 @@ class Player{
|
||||||
$packet->slot -= 9;
|
$packet->slot -= 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(($this->gamemode & 0x01) === SURVIVAL) {
|
if(($this->gamemode & 0x01) === SURVIVAL) {
|
||||||
$data["item"] = $this->getSlot($packet->slot);
|
$data["item"] = $this->getSlot($packet->slot);
|
||||||
if(!($data["item"] instanceof Item)) {
|
if(!($data["item"] instanceof Item)) {
|
||||||
|
|
@ -1854,13 +1868,17 @@ class Player{
|
||||||
$data["slot"] = $packet->slot;
|
$data["slot"] = $packet->slot;
|
||||||
|
|
||||||
if($this->server->handle("player.equipment.change", $data) !== false) {
|
if($this->server->handle("player.equipment.change", $data) !== false) {
|
||||||
if(!Player::$experimentalHotbar) $this->slot = $packet->slot;
|
if(!Player::$experimentalHotbar) {
|
||||||
|
$this->slot = $packet->slot;
|
||||||
|
}
|
||||||
if(($this->gamemode & 0x01) === SURVIVAL) {
|
if(($this->gamemode & 0x01) === SURVIVAL) {
|
||||||
$has = false;
|
$has = false;
|
||||||
$slotPos = 0;
|
$slotPos = 0;
|
||||||
$packetSlotPos = 0;
|
$packetSlotPos = 0;
|
||||||
for($i = 0; $i < $this->slotCount; ++$i) {
|
for($i = 0; $i < $this->slotCount; ++$i) {
|
||||||
if($this->slot == $this->hotbar[$i]) $slotPos = $i;
|
if($this->slot == $this->hotbar[$i]) {
|
||||||
|
$slotPos = $i;
|
||||||
|
}
|
||||||
if($packet->slot == $this->hotbar[$i]) {
|
if($packet->slot == $this->hotbar[$i]) {
|
||||||
$packetSlotPos = $i;
|
$packetSlotPos = $i;
|
||||||
$has = true;
|
$has = true;
|
||||||
|
|
@ -1882,7 +1900,9 @@ class Player{
|
||||||
array_unshift($this->hotbar, $this->slot);
|
array_unshift($this->hotbar, $this->slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Player::$experimentalHotbar) $this->sendInventory();
|
if(Player::$experimentalHotbar) {
|
||||||
|
$this->sendInventory();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->slot = $packet->slot;
|
$this->slot = $packet->slot;
|
||||||
}
|
}
|
||||||
|
|
@ -2017,8 +2037,11 @@ class Player{
|
||||||
|
|
||||||
if(($this->gamemode & 0x01) == 0x0) {
|
if(($this->gamemode & 0x01) == 0x0) {
|
||||||
if($slotItem !== false) {
|
if($slotItem !== false) {
|
||||||
if($slotItem->count == 1) $this->inventory[$this->slot] = BlockAPI::getItem(AIR, 0, 0);
|
if($slotItem->count == 1) {
|
||||||
else $slotItem->count -= 1;
|
$this->inventory[$this->slot] = BlockAPI::getItem(AIR, 0, 0);
|
||||||
|
} else {
|
||||||
|
$slotItem->count -= 1;
|
||||||
|
}
|
||||||
//$this->sendInventory();
|
//$this->sendInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2054,7 +2077,9 @@ class Player{
|
||||||
$power = $initalPower / 20;
|
$power = $initalPower / 20;
|
||||||
$power = ($power * $power + $power * 2) / 3;
|
$power = ($power * $power + $power * 2) / 3;
|
||||||
if($power >= 0.1) {
|
if($power >= 0.1) {
|
||||||
if($power > 1) $power = 1;
|
if($power > 1) {
|
||||||
|
$power = 1;
|
||||||
|
}
|
||||||
$this->server->dhandle("player.shoot", [
|
$this->server->dhandle("player.shoot", [
|
||||||
"player" => $this,
|
"player" => $this,
|
||||||
"power" => &$power,
|
"power" => &$power,
|
||||||
|
|
@ -2287,7 +2312,9 @@ class Player{
|
||||||
if($prevItem->getID() != $packet->item->getID() || $prevItem->getMetadata() != $packet->item->getMetadata()) {
|
if($prevItem->getID() != $packet->item->getID() || $prevItem->getMetadata() != $packet->item->getMetadata()) {
|
||||||
if(count($this->inventory) >= 36) {
|
if(count($this->inventory) >= 36) {
|
||||||
foreach($this->inventory as $slot => $item) {
|
foreach($this->inventory as $slot => $item) {
|
||||||
if($item->getID() == 0) goto inv_desync_on_drop;
|
if($item->getID() == 0) {
|
||||||
|
goto inv_desync_on_drop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->toCraft[] = $prevItem; //vanilla drops only result?
|
$this->toCraft[] = $prevItem; //vanilla drops only result?
|
||||||
|
|
@ -2672,9 +2699,6 @@ class Player{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $craft
|
|
||||||
* @param array $recipe
|
|
||||||
* @param $type
|
|
||||||
*
|
*
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
|
|
@ -2854,7 +2878,7 @@ class Player{
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function __toString(){
|
public function __toString() {
|
||||||
if($this->username != "") {
|
if($this->username != "") {
|
||||||
return $this->username;
|
return $this->username;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,68 @@
|
||||||
|
|
||||||
class PocketMinecraftServer {
|
class PocketMinecraftServer {
|
||||||
|
|
||||||
public $tCnt, $ticks;
|
public $tCnt;
|
||||||
public $extraprops, $serverID, $interface, $database, $version, $invisible, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $port, $saveEnabled;
|
public $ticks;
|
||||||
|
public $extraprops;
|
||||||
|
public $serverID;
|
||||||
|
public $interface;
|
||||||
|
public $database;
|
||||||
|
public $version;
|
||||||
|
public $invisible;
|
||||||
|
public $tickMeasure;
|
||||||
|
public $preparedSQL;
|
||||||
|
public $seed;
|
||||||
|
public $gamemode;
|
||||||
|
public $name;
|
||||||
|
public $maxClients;
|
||||||
|
public $clients;
|
||||||
|
public $eidCnt;
|
||||||
|
public $custom;
|
||||||
|
public $description;
|
||||||
|
public $motd;
|
||||||
|
public $port;
|
||||||
|
public $saveEnabled;
|
||||||
/**
|
/**
|
||||||
* @var ServerAPI
|
* @var ServerAPI
|
||||||
*/
|
*/
|
||||||
public $api;
|
public $api;
|
||||||
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0;
|
private $serverip;
|
||||||
|
private $evCnt;
|
||||||
|
private $handCnt;
|
||||||
|
private $events;
|
||||||
|
private $eventsID;
|
||||||
|
private $handlers;
|
||||||
|
private $serverType;
|
||||||
|
private $lastTick;
|
||||||
|
private $memoryStats;
|
||||||
|
private $async = [];
|
||||||
|
private $asyncID = 0;
|
||||||
|
|
||||||
public $doTick, $levelData, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $difficulty, $stop, $asyncThread;
|
public $doTick;
|
||||||
public static $FORCE_20_TPS = false, $KEEP_CHUNKS_LOADED = true, $PACKET_READING_LIMIT = 100;
|
|
||||||
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
|
public $levelData;
|
||||||
|
|
||||||
|
public $tiles;
|
||||||
|
|
||||||
|
public $entities;
|
||||||
|
|
||||||
|
public $schedule;
|
||||||
|
|
||||||
|
public $scheduleCnt;
|
||||||
|
|
||||||
|
public $whitelist;
|
||||||
|
|
||||||
|
public $spawn;
|
||||||
|
|
||||||
|
public $difficulty;
|
||||||
|
|
||||||
|
public $stop;
|
||||||
|
|
||||||
|
public $asyncThread;
|
||||||
|
public static $FORCE_20_TPS = false;
|
||||||
|
public static $KEEP_CHUNKS_LOADED = true;
|
||||||
|
public static $PACKET_READING_LIMIT = 100;
|
||||||
|
public function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0") {
|
||||||
$this->port = (int) $port;
|
$this->port = (int) $port;
|
||||||
$this->doTick = true;
|
$this->doTick = true;
|
||||||
$this->gamemode = (int) $gamemode;
|
$this->gamemode = (int) $gamemode;
|
||||||
|
|
@ -26,7 +77,6 @@ class PocketMinecraftServer{
|
||||||
|
|
||||||
public static $SAVE_PLAYER_DATA = true;
|
public static $SAVE_PLAYER_DATA = true;
|
||||||
|
|
||||||
|
|
||||||
private function load() {
|
private function load() {
|
||||||
global $dolog;
|
global $dolog;
|
||||||
/*if(defined("DEBUG") and DEBUG >= 0){
|
/*if(defined("DEBUG") and DEBUG >= 0){
|
||||||
|
|
@ -347,7 +397,6 @@ class PocketMinecraftServer{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $event
|
* @param string $event
|
||||||
* @param callable $callable
|
|
||||||
* @param integer $priority
|
* @param integer $priority
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
@ -475,8 +524,7 @@ class PocketMinecraftServer{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function process()
|
public function process() {
|
||||||
{
|
|
||||||
$lastLoop = 0;
|
$lastLoop = 0;
|
||||||
if(self::$FORCE_20_TPS) {
|
if(self::$FORCE_20_TPS) {
|
||||||
while($this->stop === false) {
|
while($this->stop === false) {
|
||||||
|
|
@ -524,7 +572,6 @@ class PocketMinecraftServer{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function packetHandler(Packet $packet) {
|
public function packetHandler(Packet $packet) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TileNavigator
|
class TileNavigator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -57,7 +58,6 @@ class TileNavigator
|
||||||
return $b;
|
return $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function navigate(Level $level, $fromX, $fromY, $fromZ, $toX, $toY, $toZ, $maxDist)
|
public function navigate(Level $level, $fromX, $fromY, $fromZ, $toX, $toY, $toZ, $maxDist)
|
||||||
{
|
{
|
||||||
$from = $fromX << 16 | $fromZ << 8 | $fromY;
|
$from = $fromX << 16 | $fromZ << 8 | $fromY;
|
||||||
|
|
@ -150,7 +150,6 @@ class TileNavigator
|
||||||
$diffZ = ($toZ - ($neighbor >> 8 & 0xff));
|
$diffZ = ($toZ - ($neighbor >> 8 & 0xff));
|
||||||
$targetDist = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
$targetDist = $diffX * $diffX + $diffY * $diffY + $diffZ * $diffZ;
|
||||||
|
|
||||||
|
|
||||||
$diffX = ($currentX - ($neighbor >> 16 & 0xff));
|
$diffX = ($currentX - ($neighbor >> 16 & 0xff));
|
||||||
$diffY = ($currentY - ($neighbor & 0xff));
|
$diffY = ($currentY - ($neighbor & 0xff));
|
||||||
$diffZ = ($currentZ - ($neighbor >> 8 & 0xff));
|
$diffZ = ($currentZ - ($neighbor >> 8 & 0xff));
|
||||||
|
|
@ -191,6 +190,5 @@ class TileNavigator
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
function parseOffset(string $offset) : string|false{
|
function parseOffset(string $offset) : string|false{
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ define("SOUL_SAND", 88);
|
||||||
define("GLOWSTONE", 89);
|
define("GLOWSTONE", 89);
|
||||||
define("GLOWSTONE_BLOCK", 89);
|
define("GLOWSTONE_BLOCK", 89);
|
||||||
|
|
||||||
|
|
||||||
define("LIT_PUMPKIN", 91);
|
define("LIT_PUMPKIN", 91);
|
||||||
define("JACK_O_LANTERN", 91);
|
define("JACK_O_LANTERN", 91);
|
||||||
define("CAKE_BLOCK", 92);
|
define("CAKE_BLOCK", 92);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,6 @@ require_once(FILE_PATH . "/src/pmf/PMF.php");
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
|
require_once(FILE_PATH . "/src/astarnavigator/TileNavigator.php");
|
||||||
|
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
|
require_once(FILE_PATH . "/src/entity/ai/tasks/TaskBase.php");
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/entity/Rideable.php");
|
require_once(FILE_PATH . "/src/entity/Rideable.php");
|
||||||
|
|
@ -138,8 +137,6 @@ require_once(FILE_PATH . "/src/world/generator/vanilla/feature/Feature.php");
|
||||||
|
|
||||||
require_all(FILE_PATH . "src/");
|
require_all(FILE_PATH . "src/");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$inc = get_included_files();
|
$inc = get_included_files();
|
||||||
$inc[] = array_shift($inc);
|
$inc[] = array_shift($inc);
|
||||||
$srcdir = realpath(FILE_PATH . "src/");
|
$srcdir = realpath(FILE_PATH . "src/");
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
||||||
public $age;
|
public $age;
|
||||||
public $loveTimeout;
|
public $loveTimeout;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public $closestPlayerThatCanFeedEID = false;
|
public $closestPlayerThatCanFeedEID = false;
|
||||||
public $closestPlayerThatCanFeedDist = INF;
|
public $closestPlayerThatCanFeedDist = INF;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ abstract class Creature extends Living{
|
||||||
public $closestPlayerEID = false;
|
public $closestPlayerEID = false;
|
||||||
public $closestPlayerDist = INF;
|
public $closestPlayerDist = INF;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
$this->inPanic = false; //force for now
|
$this->inPanic = false; //force for now
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
|
|
@ -21,7 +20,6 @@ abstract class Creature extends Living{
|
||||||
return parent::update($now);
|
return parent::update($now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function handlePrePlayerSearcher(){
|
public function handlePrePlayerSearcher(){
|
||||||
parent::handlePrePlayerSearcher();
|
parent::handlePrePlayerSearcher();
|
||||||
if($this->closestPlayerEID !== false){
|
if($this->closestPlayerEID !== false){
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class Entity extends Position
|
||||||
public $fallStart;
|
public $fallStart;
|
||||||
private $state;
|
private $state;
|
||||||
private $tickCounter;
|
private $tickCounter;
|
||||||
private $speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
|
private $speedMeasure = [0, 0, 0, 0, 0, 0, 0];
|
||||||
public $server;
|
public $server;
|
||||||
private $isStatic;
|
private $isStatic;
|
||||||
public $level;
|
public $level;
|
||||||
|
|
@ -131,7 +131,7 @@ class Entity extends Position
|
||||||
$this->status = 0;
|
$this->status = 0;
|
||||||
$this->health = 20;
|
$this->health = 20;
|
||||||
$this->hasGravity = false;
|
$this->hasGravity = false;
|
||||||
$this->dmgcounter = array(0, 0, 0);
|
$this->dmgcounter = [0, 0, 0];
|
||||||
$this->air = $this->maxAir;
|
$this->air = $this->maxAir;
|
||||||
$this->fire = 0;
|
$this->fire = 0;
|
||||||
$this->crouched = false;
|
$this->crouched = false;
|
||||||
|
|
@ -154,14 +154,14 @@ class Entity extends Position
|
||||||
$this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"] : 0;
|
$this->yaw = isset($this->data["yaw"]) ? (float) $this->data["yaw"] : 0;
|
||||||
$this->headYaw = $this->data["headYaw"] ?? $this->yaw;
|
$this->headYaw = $this->data["headYaw"] ?? $this->yaw;
|
||||||
$this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"] : 0;
|
$this->pitch = isset($this->data["pitch"]) ? (float) $this->data["pitch"] : 0;
|
||||||
$this->position = array(
|
$this->position = [
|
||||||
"level" => $this->level,
|
"level" => $this->level,
|
||||||
"x" => &$this->x,
|
"x" => &$this->x,
|
||||||
"y" => &$this->y,
|
"y" => &$this->y,
|
||||||
"z" => &$this->z,
|
"z" => &$this->z,
|
||||||
"yaw" => &$this->yaw,
|
"yaw" => &$this->yaw,
|
||||||
"pitch" => &$this->pitch
|
"pitch" => &$this->pitch
|
||||||
);
|
];
|
||||||
$this->moveTime = 0;
|
$this->moveTime = 0;
|
||||||
$this->lookTime = 0;
|
$this->lookTime = 0;
|
||||||
$this->onGround = false;
|
$this->onGround = false;
|
||||||
|
|
@ -349,22 +349,22 @@ class Entity extends Position
|
||||||
$slot = $this->player->getSlot($i);
|
$slot = $this->player->getSlot($i);
|
||||||
$this->player->setSlot($i, BlockAPI::getItem(AIR, 0, 0));
|
$this->player->setSlot($i, BlockAPI::getItem(AIR, 0, 0));
|
||||||
if($slot->getID() !== AIR and $slot->count > 0){
|
if($slot->getID() !== AIR and $slot->count > 0){
|
||||||
$inv[] = array(
|
$inv[] = [
|
||||||
$slot->getID(),
|
$slot->getID(),
|
||||||
$slot->getMetadata(),
|
$slot->getMetadata(),
|
||||||
$slot->count
|
$slot->count
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for($re = 0; $re < 4; $re++){
|
for($re = 0; $re < 4; $re++){
|
||||||
$slot = $this->player->getArmor($re);
|
$slot = $this->player->getArmor($re);
|
||||||
$this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0));
|
$this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0));
|
||||||
if($slot->getID() !== AIR and $slot->count > 0){
|
if($slot->getID() !== AIR and $slot->count > 0){
|
||||||
$inv[] = array(
|
$inv[] = [
|
||||||
$slot->getID(),
|
$slot->getID(),
|
||||||
$slot->getMetadata(),
|
$slot->getMetadata(),
|
||||||
$slot->count
|
$slot->count
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $inv;
|
return $inv;
|
||||||
|
|
@ -427,14 +427,14 @@ class Entity extends Position
|
||||||
foreach($this->server->api->entity->getRadius($this, 2, false) as $item){
|
foreach($this->server->api->entity->getRadius($this, 2, false) as $item){
|
||||||
if($item->class === ENTITY_ITEM && !$item->closed && $item->spawntime > 0 && $item->delayBeforePickup <= 0){
|
if($item->class === ENTITY_ITEM && !$item->closed && $item->spawntime > 0 && $item->delayBeforePickup <= 0){
|
||||||
if($item->boundingBox->intersectsWith($myBB)){
|
if($item->boundingBox->intersectsWith($myBB)){
|
||||||
if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->itemID, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", array(
|
if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->itemID, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", [
|
||||||
"eid" => $this->player->eid,
|
"eid" => $this->player->eid,
|
||||||
"player" => $this->player,
|
"player" => $this->player,
|
||||||
"entity" => $item,
|
"entity" => $item,
|
||||||
"block" => $item->itemID,
|
"block" => $item->itemID,
|
||||||
"meta" => $item->meta,
|
"meta" => $item->meta,
|
||||||
"target" => $item->eid
|
"target" => $item->eid
|
||||||
)) !== false){
|
]) !== false){
|
||||||
$item->close();
|
$item->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -589,14 +589,12 @@ class Entity extends Position
|
||||||
$this->speedX = $this->speedY = $this->speedZ = 0;
|
$this->speedX = $this->speedY = $this->speedZ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$savedDX = $dx;
|
$savedDX = $dx;
|
||||||
$savedDY = $dy;
|
$savedDY = $dy;
|
||||||
$savedDZ = $dz;
|
$savedDZ = $dz;
|
||||||
|
|
||||||
$oldBB = clone $this->boundingBox;
|
$oldBB = clone $this->boundingBox;
|
||||||
|
|
||||||
|
|
||||||
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
||||||
foreach($aaBBs as $bb){
|
foreach($aaBBs as $bb){
|
||||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||||
|
|
@ -613,7 +611,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
$this->boundingBox->offset(0, 0, $dz);
|
$this->boundingBox->offset(0, 0, $dz);
|
||||||
|
|
||||||
|
|
||||||
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
|
$fallingFlag = $this->onGround || $savedDY != $dy && $savedDY < 0;
|
||||||
|
|
||||||
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
if($this->stepHeight > 0 && $fallingFlag && ($savedDX != $dx || $savedDZ != $dz)){
|
||||||
|
|
@ -665,13 +662,10 @@ class Entity extends Position
|
||||||
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
|
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
|
||||||
$this->updateFallState($this->speedY);
|
$this->updateFallState($this->speedY);
|
||||||
|
|
||||||
|
|
||||||
if($savedDX != $dx) $this->speedX = 0;
|
if($savedDX != $dx) $this->speedX = 0;
|
||||||
if($savedDY != $dy) $this->speedY = 0;
|
if($savedDY != $dy) $this->speedY = 0;
|
||||||
if($savedDZ != $dz) $this->speedZ = 0;
|
if($savedDZ != $dz) $this->speedZ = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO more stuff -> onEntityWalking
|
//TODO more stuff -> onEntityWalking
|
||||||
|
|
||||||
$this->doBlocksCollision();
|
$this->doBlocksCollision();
|
||||||
|
|
@ -840,7 +834,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->isOnLadder()){
|
if($this->isOnLadder()){
|
||||||
$this->fallDistance = 0;
|
$this->fallDistance = 0;
|
||||||
$this->notOnGroundTicks = 0;
|
$this->notOnGroundTicks = 0;
|
||||||
|
|
@ -880,7 +873,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->counterUpdate();
|
$this->counterUpdate();
|
||||||
|
|
||||||
if($this->isPlayer()){
|
if($this->isPlayer()){
|
||||||
|
|
@ -1179,7 +1171,6 @@ class Entity extends Position
|
||||||
--$this->idleTime;
|
--$this->idleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->inAction){
|
if($this->inAction){
|
||||||
++$this->inActionCounter;
|
++$this->inActionCounter;
|
||||||
}
|
}
|
||||||
|
|
@ -1283,7 +1274,7 @@ class Entity extends Position
|
||||||
|
|
||||||
public function resetSpeed()
|
public function resetSpeed()
|
||||||
{
|
{
|
||||||
$this->speedMeasure = array(0, 0, 0, 0, 0, 0, 0);
|
$this->speedMeasure = [0, 0, 0, 0, 0, 0, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpeed()
|
public function getSpeed()
|
||||||
|
|
@ -1490,7 +1481,6 @@ class Entity extends Position
|
||||||
$this->server->api->dhandle("entity.link", ["rider" => $this->eid, "riding" => $e->eid, "type" => 0]);
|
$this->server->api->dhandle("entity.link", ["rider" => $this->eid, "riding" => $e->eid, "type" => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPlayer()
|
public function isPlayer()
|
||||||
|
|
@ -1557,12 +1547,12 @@ class Entity extends Position
|
||||||
$harm = true;
|
$harm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->server->api->dhandle("entity.health.change", array(
|
if($this->server->api->dhandle("entity.health.change", [
|
||||||
"entity" => $this,
|
"entity" => $this,
|
||||||
"eid" => $this->eid,
|
"eid" => $this->eid,
|
||||||
"health" => $health,
|
"health" => $health,
|
||||||
"cause" => $cause
|
"cause" => $cause
|
||||||
)) !== false or $force === true){
|
]) !== false or $force === true){
|
||||||
$this->health = min(127, max(-127, $health));
|
$this->health = min(127, max(-127, $health));
|
||||||
if($harm === true && $allowHarm){
|
if($harm === true && $allowHarm){
|
||||||
$pk = new EntityEventPacket;
|
$pk = new EntityEventPacket;
|
||||||
|
|
@ -1703,7 +1693,6 @@ class Entity extends Position
|
||||||
throw new Exception("Use getHeightOf or getWidthOf method instead of this.");
|
throw new Exception("Use getHeightOf or getWidthOf method instead of this.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link getHeight} or {@link getWidth} instead
|
* @deprecated Use {@link getHeight} or {@link getWidth} instead
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
|
|
||||||
public static $pathfinderTest = false;
|
public static $pathfinderTest = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Entity $target
|
* @var Entity $target
|
||||||
* @var EntityAI $ai
|
* @var EntityAI $ai
|
||||||
|
|
@ -21,7 +20,7 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
|
|
||||||
public $renderYawOffset = 0.0; //used by head rotation, TODO better name
|
public $renderYawOffset = 0.0; //used by head rotation, TODO better name
|
||||||
public $jumping, $jumpTicks;
|
public $jumping, $jumpTicks;
|
||||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
$this->target = false;
|
$this->target = false;
|
||||||
$this->ai = new EntityAI($this);
|
$this->ai = new EntityAI($this);
|
||||||
$this->pathFinder = new TileNavigator($this);
|
$this->pathFinder = new TileNavigator($this);
|
||||||
|
|
@ -147,7 +146,6 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*if($this->path){
|
/*if($this->path){
|
||||||
console("Found path of length ".count($this->path));
|
console("Found path of length ".count($this->path));
|
||||||
|
|
||||||
|
|
@ -172,7 +170,6 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
$this->pathFollower->followPath();
|
$this->pathFollower->followPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//not exactly here
|
//not exactly here
|
||||||
if($this->jumping){
|
if($this->jumping){
|
||||||
if(!$this->inWater && !$this->inLava){
|
if(!$this->inWater && !$this->inLava){
|
||||||
|
|
@ -187,7 +184,6 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
$this->jumpTicks = 0;
|
$this->jumpTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->ai->mobController->movementTick();
|
$this->ai->mobController->movementTick();
|
||||||
$this->ai->mobController->rotateTick();
|
$this->ai->mobController->rotateTick();
|
||||||
$this->ai->mobController->jumpTick();
|
$this->ai->mobController->jumpTick();
|
||||||
|
|
@ -220,7 +216,6 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
if($this->jumpTicks > 0) --$this->jumpTicks;
|
if($this->jumpTicks > 0) --$this->jumpTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function moveEntityWithHeading($strafe, $forward){
|
public function moveEntityWithHeading($strafe, $forward){
|
||||||
if($this->inWater){ //also check is player, and can it fly or not
|
if($this->inWater){ //also check is player, and can it fly or not
|
||||||
$prevPosY = $this->y;
|
$prevPosY = $this->y;
|
||||||
|
|
@ -231,7 +226,6 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
$this->speedZ *= 0.8;
|
$this->speedZ *= 0.8;
|
||||||
$this->speedY -= 0.02;
|
$this->speedY -= 0.02;
|
||||||
|
|
||||||
|
|
||||||
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
||||||
$this->speedY = 0.3;
|
$this->speedY = 0.3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Monster extends Creature{
|
class Monster extends Creature{
|
||||||
|
|
||||||
public $closestPlayerToAttackEID = false;
|
public $closestPlayerToAttackEID = false;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class Projectile extends Entity{
|
abstract class Projectile extends Entity{
|
||||||
const CLASS_TYPE = ENTITY_OBJECT;
|
const CLASS_TYPE = ENTITY_OBJECT;
|
||||||
public $shooterEID;
|
public $shooterEID;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ class EntityAI
|
||||||
$this->mobController = new MobController($entity);
|
$this->mobController = new MobController($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function canSee(Entity $entity){
|
public function canSee(Entity $entity){
|
||||||
//TODO caches
|
//TODO caches
|
||||||
return $this->entity->canSee($entity);
|
return $this->entity->canSee($entity);
|
||||||
|
|
@ -32,7 +31,6 @@ class EntityAI
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a task for entity
|
* Add a task for entity
|
||||||
* @param TaskBase $task
|
|
||||||
*/
|
*/
|
||||||
public function addTask(TaskBase $task){
|
public function addTask(TaskBase $task){
|
||||||
$this->tasks[$task->__toString()] = $task;
|
$this->tasks[$task->__toString()] = $task;
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,6 @@ class MobController
|
||||||
$dz = $z / $len;
|
$dz = $z / $len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
|
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
|
||||||
$thetaOffset = $dz < 0 ? 90 : 270;
|
$thetaOffset = $dz < 0 ? 90 : 270;
|
||||||
$calcYaw = ($thetaOffset + $tan);
|
$calcYaw = ($thetaOffset + $tan);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ class PathFollower{
|
||||||
$this->entity->currentNode = null;
|
$this->entity->currentNode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->entity->currentIndex >= count($this->entity->path)){
|
if($this->entity->currentIndex >= count($this->entity->path)){
|
||||||
console("path finished.");
|
console("path finished.");
|
||||||
$this->entity->currentNode = null;
|
$this->entity->currentNode = null;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ class TaskAttackPlayer extends TaskBase
|
||||||
$this->selfCounter = 1;
|
$this->selfCounter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onUpdate(EntityAI $ai)
|
public function onUpdate(EntityAI $ai)
|
||||||
{
|
{
|
||||||
if(!$this->isTargetValid($ai)){
|
if(!$this->isTargetValid($ai)){
|
||||||
|
|
@ -47,7 +46,6 @@ class TaskAttackPlayer extends TaskBase
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isTargetValid(EntityAI $ai){
|
public function isTargetValid(EntityAI $ai){
|
||||||
$e = $ai->entity;
|
$e = $ai->entity;
|
||||||
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,21 @@ abstract class TaskBase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executed when entity starts task. It is recommended to set counter here.
|
* Executed when entity starts task. It is recommended to set counter here.
|
||||||
* @param EntityAI $ai
|
|
||||||
*/
|
*/
|
||||||
abstract function onStart(EntityAI $ai);
|
abstract function onStart(EntityAI $ai);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every tick until counter will be not equal to 0. It is recommended to update value of counter here.
|
* Every tick until counter will be not equal to 0. It is recommended to update value of counter here.
|
||||||
* @param EntityAI $ai
|
|
||||||
*/
|
*/
|
||||||
abstract function onUpdate(EntityAI $ai);
|
abstract function onUpdate(EntityAI $ai);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On task end.
|
* On task end.
|
||||||
* @param EntityAI $ai
|
|
||||||
*/
|
*/
|
||||||
abstract function onEnd(EntityAI $ai);
|
abstract function onEnd(EntityAI $ai);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can start the task
|
* Can start the task
|
||||||
* @param EntityAI $ai
|
|
||||||
*/
|
*/
|
||||||
abstract function canBeExecuted(EntityAI $ai);
|
abstract function canBeExecuted(EntityAI $ai);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ class TaskMate extends TaskBase
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed());
|
$ai->mobController->setLookPosition($movTo->x, $movTo->y + $movTo->getEyeHeight(), $movTo->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||||
$ai->mobController->setMovingTarget($movTo->x, $movTo->y, $movTo->z, $this->speedMultiplier);
|
$ai->mobController->setMovingTarget($movTo->x, $movTo->y, $movTo->z, $this->speedMultiplier);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,5 @@ class TaskPanic extends TaskBase
|
||||||
return $ai->entity instanceof Animal && $ai->entity->inPanic && $ai->entity->knockbackTime <= 0;
|
return $ai->entity instanceof Animal && $ai->entity->inPanic && $ai->entity->knockbackTime <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,5 +43,4 @@ class TaskRandomWalk extends TaskBase
|
||||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskFollowParent") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskFollowParent") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ class TaskRangedAttack extends \TaskBase
|
||||||
$this->seenTicks = 0;
|
$this->seenTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$dist = $ai->entity->distanceSquared($ai->entity->target);
|
$dist = $ai->entity->distanceSquared($ai->entity->target);
|
||||||
|
|
||||||
if($dist > 100 || $this->seenTicks < 20){
|
if($dist > 100 || $this->seenTicks < 20){
|
||||||
|
|
@ -89,7 +88,6 @@ class TaskRangedAttack extends \TaskBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isTargetValid(EntityAI $ai){
|
public function isTargetValid(EntityAI $ai){
|
||||||
$e = $ai->entity;
|
$e = $ai->entity;
|
||||||
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
||||||
|
|
@ -123,7 +121,6 @@ class TaskRangedAttack extends \TaskBase
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function canBeExecuted(EntityAI $ai)
|
public function canBeExecuted(EntityAI $ai)
|
||||||
{
|
{
|
||||||
return $this->tryTargeting($ai);
|
return $this->tryTargeting($ai);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ class TaskTempt extends TaskBase
|
||||||
$ai->mobController->headYawIsYaw = true;
|
$ai->mobController->headYawIsYaw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isTargetValid(EntityAI $ai){
|
public function isTargetValid(EntityAI $ai){
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Pig extends Animal implements Rideable{
|
class Pig extends Animal implements Rideable{
|
||||||
const TYPE = MOB_PIG;
|
const TYPE = MOB_PIG;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Creeper extends Monster{
|
class Creeper extends Monster{
|
||||||
const TYPE = MOB_CREEPER;
|
const TYPE = MOB_CREEPER;
|
||||||
const EXPL_TIME = 30;
|
const EXPL_TIME = 30;
|
||||||
|
|
@ -27,8 +28,6 @@ class Creeper extends Monster{
|
||||||
$this->setState($v === null ? !$this->getState() : $v);
|
$this->setState($v === null ? !$this->getState() : $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PigZombie extends Monster{ //TODO extends zombie
|
class PigZombie extends Monster{ //TODO extends zombie
|
||||||
const TYPE = MOB_PIGMAN;
|
const TYPE = MOB_PIGMAN;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Skeleton extends Monster{
|
class Skeleton extends Monster{
|
||||||
const TYPE = MOB_SKELETON;
|
const TYPE = MOB_SKELETON;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Spider extends Monster{
|
class Spider extends Monster{
|
||||||
const TYPE = MOB_SPIDER;
|
const TYPE = MOB_SPIDER;
|
||||||
|
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
$this->setSize(1.4, 0.9);
|
$this->setSize(1.4, 0.9);
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth($this->data["Health"] ?? 8, "generic");
|
$this->setHealth($this->data["Health"] ?? 8, "generic");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Zombie extends Monster{
|
class Zombie extends Monster{
|
||||||
const TYPE = MOB_ZOMBIE;
|
const TYPE = MOB_ZOMBIE;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||||
$this->setSize(0.6, 1.85);
|
$this->setSize(0.6, 1.85);
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setHealth($this->data["Health"] ?? 12, "generic");
|
$this->setHealth($this->data["Health"] ?? 12, "generic");
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,6 @@ class Arrow extends Entity{
|
||||||
}
|
}
|
||||||
//Entity::update end
|
//Entity::update end
|
||||||
|
|
||||||
|
|
||||||
if($this->lastPitch == $this->lastYaw && $this->lastYaw == 0){
|
if($this->lastPitch == $this->lastYaw && $this->lastYaw == 0){
|
||||||
$v1 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
|
$v1 = sqrt($this->speedX * $this->speedX + $this->speedZ * $this->speedZ);
|
||||||
$this->lastYaw = $this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
|
$this->lastYaw = $this->yaw = atan2($this->speedX, $this->speedZ) * 180 / M_PI;
|
||||||
|
|
@ -163,7 +162,6 @@ class Arrow extends Entity{
|
||||||
$end = new Vector3($this->x + $this->speedX, $this->y + $this->speedY, $this->z + $this->speedZ);
|
$end = new Vector3($this->x + $this->speedX, $this->y + $this->speedY, $this->z + $this->speedZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$entities = $this->level->getEntitiesInAABB($this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ)->expand(1, 1, 1));
|
$entities = $this->level->getEntitiesInAABB($this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ)->expand(1, 1, 1));
|
||||||
$bestDist = 0;
|
$bestDist = 0;
|
||||||
$bestEnt = null;
|
$bestEnt = null;
|
||||||
|
|
@ -197,7 +195,6 @@ class Arrow extends Entity{
|
||||||
$damage += mt_rand(0, $damage / 2 + 1);
|
$damage += mt_rand(0, $damage / 2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($v4->entityHit->harm($damage, $this->eid)){
|
if($v4->entityHit->harm($damage, $this->eid)){
|
||||||
//vanilla seems to increase arrow count if $v4->entity is mob
|
//vanilla seems to increase arrow count if $v4->entity is mob
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
@ -256,8 +253,6 @@ class Arrow extends Entity{
|
||||||
$this->doBlocksCollision();
|
$this->doBlocksCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function spawn($player){
|
public function spawn($player){
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class ItemEntity extends Entity{
|
||||||
|
|
||||||
public $meta, $stack, $itemID;
|
public $meta, $stack, $itemID;
|
||||||
|
|
||||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
public function __construct(Level $level, $eid, $class, $type = 0, $data = [])
|
||||||
{
|
{
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
parent::__construct($level, $eid, $class, $type, $data);
|
||||||
$this->setSize(0.25, 0.25);
|
$this->setSize(0.25, 0.25);
|
||||||
|
|
@ -64,7 +64,6 @@ class ItemEntity extends Entity{
|
||||||
$player->dataPacket($pk);
|
$player->dataPacket($pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function tryCombining(Entity $another){
|
public function tryCombining(Entity $another){
|
||||||
|
|
||||||
if($another->eid == $this->eid) return false;
|
if($another->eid == $this->eid) return false;
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,6 @@ class Minecart extends Vehicle{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function applyNaturalSlowdown(){
|
public function applyNaturalSlowdown(){
|
||||||
$mult = $this->linkedEntity != 0 && !$this->isRider ? 0.997 : 0.96;
|
$mult = $this->linkedEntity != 0 && !$this->isRider ? 0.997 : 0.96;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class Painting extends Entity{
|
||||||
public function setDirection($dir){
|
public function setDirection($dir){
|
||||||
$this->direction = $dir;
|
$this->direction = $dir;
|
||||||
$this->lastYaw = $this->yaw = $dir * 90;
|
$this->lastYaw = $this->yaw = $dir * 90;
|
||||||
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
|
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
|
||||||
$width = $size[0] * 16;
|
$width = $size[0] * 16;
|
||||||
$height = $size[1] * 16;
|
$height = $size[1] * 16;
|
||||||
if($dir == 2 || $dir == 0){
|
if($dir == 2 || $dir == 0){
|
||||||
|
|
@ -144,7 +144,7 @@ class Painting extends Entity{
|
||||||
$cubes = $this->level->getCubes($this, $this->boundingBox);
|
$cubes = $this->level->getCubes($this, $this->boundingBox);
|
||||||
if(count($cubes) == 0){
|
if(count($cubes) == 0){
|
||||||
|
|
||||||
$size = PaintingItem::$motives[$this->motive] ?? array(1, 1);
|
$size = PaintingItem::$motives[$this->motive] ?? [1, 1];
|
||||||
$width = $size[0];
|
$width = $size[0];
|
||||||
$width2 = $width * 16 / 32;
|
$width2 = $width * 16 / 32;
|
||||||
$height = $size[1];
|
$height = $size[1];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ThrownEgg extends Projectile{
|
class ThrownEgg extends Projectile{
|
||||||
const TYPE = OBJECT_EGG;
|
const TYPE = OBJECT_EGG;
|
||||||
|
|
||||||
|
|
@ -28,5 +29,4 @@ class ThrownEgg extends Projectile{
|
||||||
$this->close();
|
$this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ThrownSnowball extends Projectile{
|
class ThrownSnowball extends Projectile{
|
||||||
const TYPE = OBJECT_SNOWBALL;
|
const TYPE = OBJECT_SNOWBALL;
|
||||||
public function onHit(MovingObjectPosition $hitResult){
|
public function onHit(MovingObjectPosition $hitResult){
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugins that create events must use this class as the base
|
* Plugins that create events must use this class as the base
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ class PacketReceiveEvent extends ServerEvent implements CancellableEvent{
|
||||||
|
|
||||||
private $packet;
|
private $packet;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Packet $packet){
|
public function __construct(Packet $packet){
|
||||||
$this->packet = $packet;
|
$this->packet = $packet;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ class PacketSendEvent extends ServerEvent implements CancellableEvent{
|
||||||
|
|
||||||
private $packet;
|
private $packet;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Packet $packet){
|
public function __construct(Packet $packet){
|
||||||
$this->packet = $packet;
|
$this->packet = $packet;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ if(!function_exists("cli_set_process_title")){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dummy(){
|
function dummy(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -69,8 +68,6 @@ function nullsafe(&$a, $null){
|
||||||
return $a ?? $null;
|
return $a ?? $null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function require_all($path, &$count = 0){
|
function require_all($path, &$count = 0){
|
||||||
$dir = dir($path . "/");
|
$dir = dir($path . "/");
|
||||||
$dirs = [];
|
$dirs = [];
|
||||||
|
|
|
||||||
|
|
@ -143,13 +143,12 @@ LICENSE;
|
||||||
|
|
||||||
$config->save();
|
$config->save();
|
||||||
|
|
||||||
|
|
||||||
echo "[*] " . $this->lang->ip_get . "\n";
|
echo "[*] " . $this->lang->ip_get . "\n";
|
||||||
|
|
||||||
$externalIP = Utils::getIP();
|
$externalIP = Utils::getIP();
|
||||||
$internalIP = gethostbyname(trim(`hostname`));
|
$internalIP = gethostbyname(trim(`hostname`));
|
||||||
|
|
||||||
echo "[!] ".$this->lang->get("ip_warning", array("{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"), array($externalIP, $internalIP))."\n";
|
echo "[!] " . $this->lang->get("ip_warning", ["{{EXTERNAL_IP}}", "{{INTERNAL_IP}}"], [$externalIP, $internalIP]) . "\n";
|
||||||
echo "[!] " . $this->lang->ip_confirm;
|
echo "[!] " . $this->lang->ip_confirm;
|
||||||
$this->getInput();
|
$this->getInput();
|
||||||
}
|
}
|
||||||
|
|
@ -166,11 +165,10 @@ LICENSE;
|
||||||
return $input === "" ? $default:$input;
|
return $input === "" ? $default:$input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class InstallerLang{
|
class InstallerLang{
|
||||||
public static $languages = array(
|
public static $languages = [
|
||||||
"ru" => "Pyccĸий",
|
"ru" => "Pyccĸий",
|
||||||
"en" => "English",
|
"en" => "English",
|
||||||
"es" => "Español",
|
"es" => "Español",
|
||||||
|
|
@ -189,8 +187,8 @@ LICENSE;
|
||||||
"tr" => "Türkçe",
|
"tr" => "Türkçe",
|
||||||
"uk" => "Український"
|
"uk" => "Український"
|
||||||
//"et" => "Eesti",
|
//"et" => "Eesti",
|
||||||
);
|
];
|
||||||
private $texts = array();
|
private $texts = [];
|
||||||
private $lang;
|
private $lang;
|
||||||
private $langfile;
|
private $langfile;
|
||||||
public function __construct($lang = ""){
|
public function __construct($lang = ""){
|
||||||
|
|
@ -200,7 +198,7 @@ LICENSE;
|
||||||
}else{
|
}else{
|
||||||
$l = glob(FILE_PATH . "src/lang/Installer/" . $lang . "_*.ini");
|
$l = glob(FILE_PATH . "src/lang/Installer/" . $lang . "_*.ini");
|
||||||
if(count($l) > 0){
|
if(count($l) > 0){
|
||||||
$files = array();
|
$files = [];
|
||||||
foreach($l as $file){
|
foreach($l as $file){
|
||||||
$files[$file] = filesize($file);
|
$files[$file] = filesize($file);
|
||||||
}
|
}
|
||||||
|
|
@ -228,19 +226,19 @@ LICENSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadLang($langfile, $lang = "en"){
|
public function loadLang($langfile, $lang = "en"){
|
||||||
$this->texts[$lang] = array();
|
$this->texts[$lang] = [];
|
||||||
$texts = explode("\n", str_replace(array("\r", "\/\/"), array("", "//"), file_get_contents($langfile)));
|
$texts = explode("\n", str_replace(["\r", "\/\/"], ["", "//"], file_get_contents($langfile)));
|
||||||
foreach($texts as $line){
|
foreach($texts as $line){
|
||||||
$line = trim($line);
|
$line = trim($line);
|
||||||
if($line === ""){
|
if($line === ""){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$line = explode("=", $line);
|
$line = explode("=", $line);
|
||||||
$this->texts[$lang][array_shift($line)] = str_replace(array("\\n", "\\N",), "\n", implode("=", $line));
|
$this->texts[$lang][array_shift($line)] = str_replace(["\\n", "\\N",], "\n", implode("=", $line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($name, $search = array(), $replace = array()){
|
public function get($name, $search = [], $replace = []){
|
||||||
if(!isset($this->texts[$this->lang][$name])){
|
if(!isset($this->texts[$this->lang][$name])){
|
||||||
if($this->lang !== "en" and isset($this->texts["en"][$name])){
|
if($this->lang !== "en" and isset($this->texts["en"][$name])){
|
||||||
return $this->texts["en"][$name];
|
return $this->texts["en"][$name];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class Block extends Position{
|
abstract class Block extends Position{
|
||||||
public static $class = array(
|
public static $class = [
|
||||||
AIR => "AirBlock",
|
AIR => "AirBlock",
|
||||||
STONE => "StoneBlock",
|
STONE => "StoneBlock",
|
||||||
GRASS => "GrassBlock",
|
GRASS => "GrassBlock",
|
||||||
|
|
@ -132,7 +132,7 @@ abstract class Block extends Position{
|
||||||
INFO_UPDATE => "InfoUpdateBlock",
|
INFO_UPDATE => "InfoUpdateBlock",
|
||||||
INFO_UPDATE2 => "InfoUpdate2Block",
|
INFO_UPDATE2 => "InfoUpdate2Block",
|
||||||
RESERVED6 => "Reserved6Block",
|
RESERVED6 => "Reserved6Block",
|
||||||
);
|
];
|
||||||
public $id;
|
public $id;
|
||||||
public $meta;
|
public $meta;
|
||||||
public $name;
|
public $name;
|
||||||
|
|
@ -230,7 +230,6 @@ abstract class Block extends Position{
|
||||||
}
|
}
|
||||||
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){}
|
public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){}
|
||||||
|
|
||||||
|
|
||||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||||
$this->id = (int) $id;
|
$this->id = (int) $id;
|
||||||
$this->meta = (int) $meta;
|
$this->meta = (int) $meta;
|
||||||
|
|
@ -269,11 +268,11 @@ abstract class Block extends Position{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if(!isset(Block::$class[$this->id])){ //Unknown blocks
|
if(!isset(Block::$class[$this->id])){ //Unknown blocks
|
||||||
return array();
|
return [];
|
||||||
}else{
|
}else{
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta, 1),
|
[$this->id, $this->meta, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class Item{
|
||||||
|
|
||||||
const DEF_DAMAGE = 1;
|
const DEF_DAMAGE = 1;
|
||||||
|
|
||||||
public static $class = array(
|
public static $class = [
|
||||||
|
|
||||||
//armor
|
//armor
|
||||||
LEATHER_CAP => "LeatherCapItem",
|
LEATHER_CAP => "LeatherCapItem",
|
||||||
|
|
@ -128,7 +128,7 @@ class Item{
|
||||||
CLOCK => "ClockItem",
|
CLOCK => "ClockItem",
|
||||||
SHEARS => "ShearsItem",
|
SHEARS => "ShearsItem",
|
||||||
|
|
||||||
);
|
];
|
||||||
public $block;
|
public $block;
|
||||||
public $id;
|
public $id;
|
||||||
public $meta;
|
public $meta;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*value - durability*/
|
/*value - durability*/
|
||||||
class Material{
|
class Material{
|
||||||
const LEATHER = 5; //when enums
|
const LEATHER = 5; //when enums
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,6 @@ class StaticBlock
|
||||||
return $bb->setBounds($x + $bb->minX, $y + $bb->minY, $z + $bb->minZ, $x + $bb->maxX, $y + $bb->maxY, $z + $bb->maxZ);
|
return $bb->setBounds($x + $bb->minX, $y + $bb->minY, $z + $bb->minZ, $x + $bb->maxX, $y + $bb->maxY, $z + $bb->maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getSlipperiness($id){
|
public static function getSlipperiness($id){
|
||||||
return self::$slipperiness[$id] ?? StaticBlock::DEFAULT_SLIPPERINESS;
|
return self::$slipperiness[$id] ?? StaticBlock::DEFAULT_SLIPPERINESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return [$aabb->offset($x, $y, $z)];
|
return [$aabb->offset($x, $y, $z)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +104,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
return $metaLower & 7 | (($myMeta & 8) != 0 ? 8 : 0) | (($metaUpper & 1 != 0) ? 16 : 0);
|
return $metaLower & 7 | (($myMeta & 8) != 0 ? 8 : 0) | (($metaUpper & 1 != 0) ? 16 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
if($level->level->getBlockID($x, $y - 1, $z) == AIR){ //Replace with common break method
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
|
||||||
|
|
@ -121,12 +119,7 @@ class DoorBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
* @param Block $block
|
|
||||||
* @param Block $target
|
|
||||||
* @param integer $face
|
* @param integer $face
|
||||||
* @param integer $fx
|
* @param integer $fx
|
||||||
* @param integer $fy
|
* @param integer $fy
|
||||||
|
|
@ -142,12 +135,12 @@ class DoorBlock extends TransparentBlock{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$direction = $player->entity->getDirection();
|
$direction = $player->entity->getDirection();
|
||||||
$face = array(
|
$face = [
|
||||||
0 => 3,
|
0 => 3,
|
||||||
1 => 4,
|
1 => 4,
|
||||||
2 => 2,
|
2 => 2,
|
||||||
3 => 5,
|
3 => 5,
|
||||||
);
|
];
|
||||||
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
$next = $this->getSide($face[(($direction + 2) % 4)]);
|
||||||
$next2 = $this->getSide($face[$direction]);
|
$next2 = $this->getSide($face[$direction]);
|
||||||
$metaUp = 0x08;
|
$metaUp = 0x08;
|
||||||
|
|
@ -164,8 +157,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -186,8 +177,6 @@ class DoorBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ class FallableBlock extends SolidBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
* @param Block $block
|
|
||||||
* @param Block $target
|
|
||||||
* @param int $face
|
* @param int $face
|
||||||
* @param int $fx
|
* @param int $fx
|
||||||
* @param int $fy
|
* @param int $fy
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class GenericBlock extends Block{
|
class GenericBlock extends Block{
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
|
@ -12,10 +11,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
* @param Block $block
|
|
||||||
* @param Block $target
|
|
||||||
* @param integer $face
|
* @param integer $face
|
||||||
* @param integer $fx
|
* @param integer $fx
|
||||||
* @param integer $fy
|
* @param integer $fy
|
||||||
|
|
@ -28,8 +23,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,8 +31,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,12 +51,12 @@ class GenericBlock extends Block{
|
||||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
||||||
$data = array(
|
$data = [
|
||||||
"x" => $x + 0.5,
|
"x" => $x + 0.5,
|
||||||
"y" => $y - 0.5,
|
"y" => $y - 0.5,
|
||||||
"z" => $z + 0.5,
|
"z" => $z + 0.5,
|
||||||
"Tile" => $id,
|
"Tile" => $id,
|
||||||
);
|
];
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||||
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||||
|
|
@ -74,7 +65,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $type
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
@ -86,8 +76,6 @@ class GenericBlock extends Block{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -184,9 +184,8 @@ class LiquidBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLiquidHeight(){
|
public function getLiquidHeight(){
|
||||||
|
|
|
||||||
|
|
@ -319,10 +319,6 @@ class StairBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
* @param Block $block
|
|
||||||
* @param Block $target
|
|
||||||
* @param int $face
|
* @param int $face
|
||||||
* @param int $fx
|
* @param int $fx
|
||||||
* @param int $fy
|
* @param int $fy
|
||||||
|
|
@ -331,12 +327,12 @@ class StairBlock extends TransparentBlock{
|
||||||
* @return bool|mixed
|
* @return bool|mixed
|
||||||
*/
|
*/
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 0,
|
0 => 0,
|
||||||
1 => 2,
|
1 => 2,
|
||||||
2 => 1,
|
2 => 1,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||||
if(($fy > 0.5 and $face !== 1) or $face === 0){
|
if(($fy > 0.5 and $face !== 1) or $face === 0){
|
||||||
$this->meta |= 0x04; //Upside-down stairs
|
$this->meta |= 0x04; //Upside-down stairs
|
||||||
|
|
@ -346,18 +342,16 @@ class StairBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item $item
|
|
||||||
* @param Player $player
|
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ class LadderBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ class SignPostBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(SIGN, 0, 1),
|
[SIGN, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,13 +33,13 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($target->isTransparent === false and $face !== 0){
|
if($target->isTransparent === false and $face !== 0){
|
||||||
$faces = array(
|
$faces = [
|
||||||
1 => 5,
|
1 => 5,
|
||||||
2 => 4,
|
2 => 4,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
4 => 2,
|
4 => 2,
|
||||||
5 => 1,
|
5 => 1,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$face];
|
$this->meta = $faces[$face];
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -51,8 +51,8 @@ class TorchBlock extends FlowableBlock implements LightingBlock{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -59,21 +59,21 @@ class TrapdoorBlock extends TransparentBlock{
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
|
if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){
|
||||||
$faces = array(
|
$faces = [
|
||||||
2 => 0,
|
2 => 0,
|
||||||
3 => 1,
|
3 => 1,
|
||||||
4 => 2,
|
4 => 2,
|
||||||
5 => 3,
|
5 => 3,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$face] & 0x03;
|
$this->meta = $faces[$face] & 0x03;
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
$attach = match($level->level->getBlockDamage($x, $y, $z)){
|
$attach = match($level->level->getBlockDamage($x, $y, $z)){
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||||
|
|
||||||
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
class LavaBlock extends LiquidBlockDynamic implements LightingBlock{
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,4 @@ class LiquidBlockStatic extends LiquidBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
||||||
|
|
||||||
class StillLavaBlock extends LiquidBlockStatic{
|
class StillLavaBlock extends LiquidBlockStatic{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
/***REM_START***/
|
/***REM_START***/
|
||||||
require_once("WaterBlock.php"); //TODO class loader?
|
require_once("WaterBlock.php"); //TODO class loader?
|
||||||
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
require_once("LiquidBlockStatic.php"); //TODO class loader?
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
require_once("LiquidBlockDynamic.php"); //TODO class loader?
|
||||||
|
|
||||||
class WaterBlock extends LiquidBlockDynamic{
|
class WaterBlock extends LiquidBlockDynamic{
|
||||||
|
|
|
||||||
|
|
@ -172,9 +172,9 @@ class BedBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(BED, 0, 1),
|
[BED, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
public function getMaxLightValue(){
|
public function getMaxLightValue(){
|
||||||
return 15;
|
return 15;
|
||||||
|
|
@ -79,6 +79,5 @@ class FireBlock extends FlowableBlock implements LightingBlock{
|
||||||
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
parent::place($item, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||||
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
$this->level->scheduleBlockUpdate($this, 30, BLOCK_UPDATE_SCHEDULED);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,24 +15,24 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
$this->meta = 1;
|
$this->meta = 1;
|
||||||
$this->level->setBlock($this,$this);
|
$this->level->setBlock($this,$this);
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
$server->schedule(40, array($this, "glow"), 1);
|
$server->schedule(40, [$this, "glow"], 1);
|
||||||
$server->schedule(60, array($this, "glow"), 2);
|
$server->schedule(60, [$this, "glow"], 2);
|
||||||
$server->schedule(80, array($this, "glow"), 3);
|
$server->schedule(80, [$this, "glow"], 3);
|
||||||
$server->schedule(140, array($this, "glow"), 4);
|
$server->schedule(140, [$this, "glow"], 4);
|
||||||
$server->schedule(200, array($this, "spawnItems"), [0,15,2,true]); //200
|
$server->schedule(200, [$this, "spawnItems"], [0,15,2,true]); //200
|
||||||
$server->schedule(260, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
$server->schedule(260, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||||
$server->schedule(300, array($this, "spawnItems"), [0,15,"checkPigmen",true]);
|
$server->schedule(300, [$this, "spawnItems"], [0,15,"checkPigmen",true]);
|
||||||
$server->schedule(340, array($this, "spawnItems"), [11,20,"checkPigmen",false]);
|
$server->schedule(340, [$this, "spawnItems"], [11,20,"checkPigmen",false]);
|
||||||
$server->schedule(400, array($this, "spawnItems"), [0,10,"checkPigmen",false]);
|
$server->schedule(400, [$this, "spawnItems"], [0,10,"checkPigmen",false]);
|
||||||
$server->schedule(500, array($this, "spawnItems"), [17,32, "checkPigmen",false]); //500
|
$server->schedule(500, [$this, "spawnItems"], [17,32, "checkPigmen",false]); //500
|
||||||
$server->schedule(580, array($this, "spawnItems"), [17,32, "checkPigmen",false]);
|
$server->schedule(580, [$this, "spawnItems"], [17,32, "checkPigmen",false]);
|
||||||
$server->schedule(620, array($this, "spawnItems"), [1,32, "checkPigmen",false]);
|
$server->schedule(620, [$this, "spawnItems"], [1,32, "checkPigmen",false]);
|
||||||
$server->schedule(660, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
$server->schedule(660, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||||
$server->schedule(700, array($this, "spawnItems"), [1,32,"checkPigmen",false]);
|
$server->schedule(700, [$this, "spawnItems"], [1,32,"checkPigmen",false]);
|
||||||
$server->schedule(860, array($this, "glow"), 5);
|
$server->schedule(860, [$this, "glow"], 5);
|
||||||
$server->schedule(880, array($this, "glow"), 6);
|
$server->schedule(880, [$this, "glow"], 6);
|
||||||
$server->schedule(900, array($this, "glow"), 7);
|
$server->schedule(900, [$this, "glow"], 7);
|
||||||
$server->schedule(920, array($this, "destroy"));
|
$server->schedule(920, [$this, "destroy"]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
@ -105,11 +105,11 @@ class NetherReactorBlock extends SolidBlock{
|
||||||
$randomRange = floor(lcg_value() * 5 + 3);
|
$randomRange = floor(lcg_value() * 5 + 3);
|
||||||
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
|
$shiftX = cos(floor(lcg_value() * 360) * (pi() / 180));
|
||||||
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
|
$shiftZ = sin(floor(lcg_value() * 360) * (pi() / 180));
|
||||||
$data = array(
|
$data = [
|
||||||
"x" => $x + ($shiftX * $randomRange) + 0.5,
|
"x" => $x + ($shiftX * $randomRange) + 0.5,
|
||||||
"y" => $y,
|
"y" => $y,
|
||||||
"z" => $z + ($shiftZ * $randomRange) + 0.5,
|
"z" => $z + ($shiftZ * $randomRange) + 0.5,
|
||||||
);
|
];
|
||||||
$e = $server->api->entity->add($this->level, ENTITY_MOB, MOB_PIGMAN, $data);
|
$e = $server->api->entity->add($this->level, ENTITY_MOB, MOB_PIGMAN, $data);
|
||||||
$server->api->entity->spawnToAll($e);
|
$server->api->entity->spawnToAll($e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ class TNTBlock extends SolidBlock{
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
$item->useOn($this);
|
$item->useOn($this);
|
||||||
}
|
}
|
||||||
$data = array(
|
$data = [
|
||||||
"x" => $this->x + 0.5,
|
"x" => $this->x + 0.5,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z + 0.5,
|
"z" => $this->z + 0.5,
|
||||||
"power" => 3,
|
"power" => 3,
|
||||||
"fuse" => 20 * 4, //4 seconds
|
"fuse" => 20 * 4, //4 seconds
|
||||||
);
|
];
|
||||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, 0, 0, true);
|
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, 0, 0, true);
|
||||||
$e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
|
$e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
|
||||||
ServerAPI::request()->api->entity->spawnToAll($e);
|
ServerAPI::request()->api->entity->spawnToAll($e);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class CakeBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class CarpetBlock extends FlowableBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(CARPET, $meta, "Carpet");
|
parent::__construct(CARPET, $meta, "Carpet");
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "White Carpet",
|
0 => "White Carpet",
|
||||||
1 => "Orange Carpet",
|
1 => "Orange Carpet",
|
||||||
2 => "Magenta Carpet",
|
2 => "Magenta Carpet",
|
||||||
|
|
@ -21,7 +21,7 @@ class CarpetBlock extends FlowableBlock{
|
||||||
13 => "Green Carpet",
|
13 => "Green Carpet",
|
||||||
14 => "Red Carpet",
|
14 => "Red Carpet",
|
||||||
15 => "Black Carpet",
|
15 => "Black Carpet",
|
||||||
);
|
];
|
||||||
$this->name = $names[$this->meta];
|
$this->name = $names[$this->meta];
|
||||||
$this->hardness = 0;
|
$this->hardness = 0;
|
||||||
$this->isFullBlock = false;
|
$this->isFullBlock = false;
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ class ChestBlock extends TransparentBlock{
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 4,
|
0 => 4,
|
||||||
1 => 2,
|
1 => 2,
|
||||||
2 => 5,
|
2 => 5,
|
||||||
3 => 3,
|
3 => 3,
|
||||||
);
|
];
|
||||||
|
|
||||||
$chest = false;
|
$chest = false;
|
||||||
$this->meta = $faces[$player->entity->getDirection()];
|
$this->meta = $faces[$player->entity->getDirection()];
|
||||||
|
|
@ -40,13 +40,13 @@ class ChestBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
$tile = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||||
"Items" => array(),
|
"Items" => [],
|
||||||
"id" => TILE_CHEST,
|
"id" => TILE_CHEST,
|
||||||
"x" => $this->x,
|
"x" => $this->x,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z
|
"z" => $this->z
|
||||||
));
|
]);
|
||||||
$server->api->tile->spawnToAll($tile);
|
$server->api->tile->spawnToAll($tile);
|
||||||
|
|
||||||
if($chest instanceof Tile){
|
if($chest instanceof Tile){
|
||||||
|
|
@ -77,17 +77,15 @@ class ChestBlock extends TransparentBlock{
|
||||||
if($t !== false){
|
if($t !== false){
|
||||||
$chest = $t;
|
$chest = $t;
|
||||||
}else{
|
}else{
|
||||||
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
$chest = $server->api->tile->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, [
|
||||||
"Items" => array(),
|
"Items" => [],
|
||||||
"id" => TILE_CHEST,
|
"id" => TILE_CHEST,
|
||||||
"x" => $this->x,
|
"x" => $this->x,
|
||||||
"y" => $this->y,
|
"y" => $this->y,
|
||||||
"z" => $this->z
|
"z" => $this->z
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(($player->gamemode & 0x01) === 0x01){
|
if(($player->gamemode & 0x01) === 0x01){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -97,15 +95,15 @@ class ChestBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
$drops = array(
|
$drops = [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
$t = ServerAPI::request()->api->tile->get($this);
|
$t = ServerAPI::request()->api->tile->get($this);
|
||||||
if($t !== false and $t->class === TILE_CHEST){
|
if($t !== false and $t->class === TILE_CHEST){
|
||||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||||
$slot = $t->getSlot($s);
|
$slot = $t->getSlot($s);
|
||||||
if($slot->getID() > AIR and $slot->count > 0){
|
if($slot->getID() > AIR and $slot->count > 0){
|
||||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
$drops[] = [$slot->getID(), $slot->getMetadata(), $slot->count];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class CobwebBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
elseif ($item->isShears()){
|
elseif ($item->isShears()){
|
||||||
return [
|
return [
|
||||||
array(COBWEB, 0, 1),
|
[COBWEB, 0, 1],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ class FarmlandBlock extends TransparentBlock{
|
||||||
$this->hardness = 3;
|
$this->hardness = 3;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(DIRT, 0, 1),
|
[DIRT, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public function hasCrops(){
|
public function hasCrops(){
|
||||||
//TODO vanilla 0.8.1 detection method
|
//TODO vanilla 0.8.1 detection method
|
||||||
|
|
@ -42,7 +42,6 @@ class FarmlandBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkWaterStatic(Level $level, $x, $y, $z)
|
public static function checkWaterStatic(Level $level, $x, $y, $z)
|
||||||
|
|
|
||||||
|
|
@ -33,20 +33,20 @@ class FenceGateBlock extends TransparentBlock{
|
||||||
$this->hardness = 15;
|
$this->hardness = 15;
|
||||||
}
|
}
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$faces = array(
|
$faces = [
|
||||||
0 => 3,
|
0 => 3,
|
||||||
1 => 0,
|
1 => 0,
|
||||||
2 => 1,
|
2 => 1,
|
||||||
3 => 2,
|
3 => 2,
|
||||||
);
|
];
|
||||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
$this->level->setBlock($block, $this, true, false, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ class GlassPaneBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(GLASS_PANE, 0, 0),
|
[GLASS_PANE, 0, 0],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,11 +24,11 @@ class IronDoorBlock extends DoorBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(IRON_DOOR, 0, 1),
|
[IRON_DOOR, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("RailBaseBlock.php");
|
require_once("RailBaseBlock.php");
|
||||||
class PoweredRailBlock extends RailBaseBlock{
|
class PoweredRailBlock extends RailBaseBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("RailBaseBlock.php");
|
require_once("RailBaseBlock.php");
|
||||||
class RailBlock extends RailBaseBlock{
|
class RailBlock extends RailBaseBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
|
|
|
||||||
|
|
@ -106,11 +106,11 @@ class SlabBlock extends TransparentBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta & 0x07, 1),
|
[$this->id, $this->meta & 0x07, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ class SnowLayerBlock extends FlowableBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->isShovel() !== false){
|
if($item->isShovel() !== false){
|
||||||
return array(
|
return [
|
||||||
array(SNOWBALL, 0, 1),
|
[SNOWBALL, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,8 +9,8 @@ class WoodDoorBlock extends DoorBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array(WOODEN_DOOR, 0, 1),
|
[WOODEN_DOOR, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
//TODO make it extend SlabBlock
|
//TODO make it extend SlabBlock
|
||||||
class WoodSlabBlock extends TransparentBlock{
|
class WoodSlabBlock extends TransparentBlock{
|
||||||
public static $blockID;
|
public static $blockID;
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(WOOD_SLAB, $meta, "Wooden Slab");
|
parent::__construct(WOOD_SLAB, $meta, "Wooden Slab");
|
||||||
$names = array(
|
$names = [
|
||||||
0 => "Oak",
|
0 => "Oak",
|
||||||
1 => "Spruce",
|
1 => "Spruce",
|
||||||
2 => "Birch",
|
2 => "Birch",
|
||||||
3 => "Jungle",
|
3 => "Jungle",
|
||||||
);
|
];
|
||||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
|
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Wooden Slab";
|
||||||
if(($this->meta & 0x08) === 0x08){
|
if(($this->meta & 0x08) === 0x08){
|
||||||
$this->isFullBlock = true;
|
$this->isFullBlock = true;
|
||||||
|
|
@ -101,8 +102,8 @@ class WoodSlabBlock extends TransparentBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, $this->meta & 0x07, 1),
|
[$this->id, $this->meta & 0x07, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ class BirchWoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,8 @@ class JungleWoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,8 +7,8 @@ class SpruceWoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,8 +21,8 @@ class WoodStairsBlock extends StairBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return [
|
||||||
array($this->id, 0, 1),
|
[$this->id, 0, 1],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ class CoalOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 1){
|
if($item->getPickaxeLevel() >= 1){
|
||||||
return array(
|
return [
|
||||||
array(COAL, 0, 1),
|
[COAL, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ class DiamondOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(DIAMOND, 0, 1),
|
[DIAMOND, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ class GoldOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(GOLD_ORE, 0, 1),
|
[GOLD_ORE, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ class IronOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
|
if($item->getPickaxeLevel() >= ItemTool::STONE_LEVEL){
|
||||||
return array(
|
return [
|
||||||
array(IRON_ORE, 0, 1),
|
[IRON_ORE, 0, 1],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ class LapisOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 3){
|
if($item->getPickaxeLevel() >= 3){
|
||||||
return array(
|
return [
|
||||||
array(DYE, 4, mt_rand(4, 8)),
|
[DYE, 4, mt_rand(4, 8)],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ class RedstoneOreBlock extends SolidBlock{
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
if($item->getPickaxeLevel() >= 4){
|
if($item->getPickaxeLevel() >= 4){
|
||||||
return array(
|
return [
|
||||||
array(REDSTONE_DUST, 0, mt_rand(4, 5)),
|
[REDSTONE_DUST, 0, mt_rand(4, 5)],
|
||||||
);
|
];
|
||||||
}else{
|
}else{
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -69,8 +69,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],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,6 @@ class CyanFlowerBlock extends FlowableBlock{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||||
$downId = $level->level->getBlockID($x, $y - 1, $z);
|
$downId = $level->level->getBlockID($x, $y - 1, $z);
|
||||||
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
|
if(StaticBlock::getIsTransparent($downId) and $downId !== FARMLAND){ //Replace with common break method
|
||||||
|
|
@ -30,8 +29,6 @@ class CyanFlowerBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
@ -64,8 +64,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;
|
||||||
}
|
}
|
||||||
|
|
@ -27,9 +27,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,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 [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,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;
|
||||||
|
|
@ -35,13 +35,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){
|
||||||
|
|
@ -67,16 +67,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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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