mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
Changes.
This commit is contained in:
parent
d5a6be70ac
commit
1e29cbbbeb
20 changed files with 98 additions and 96 deletions
|
|
@ -146,9 +146,9 @@ class BanAPI{
|
||||||
case "op":
|
case "op":
|
||||||
$user = strtolower($params[0]);
|
$user = strtolower($params[0]);
|
||||||
if($user == NULL){
|
if($user == NULL){
|
||||||
$output .= "Usage: /op <player>\n";
|
$output .= "Usage: /op <player>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$player = $this->server->api->player->get($user);
|
$player = $this->server->api->player->get($user);
|
||||||
if(!($player instanceof Player)){
|
if(!($player instanceof Player)){
|
||||||
$this->ops->set($user);
|
$this->ops->set($user);
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,21 @@ class EntityAPI{
|
||||||
if($item->getID() === AIR or $item->count <= 0){
|
if($item->getID() === AIR or $item->count <= 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$i = 0;
|
||||||
|
do { // drop the block to the first supporting block
|
||||||
|
$i++;
|
||||||
|
$v = new Vector3($pos->x, $pos->y - $i, $pos->z);
|
||||||
|
$b = $pos->level->getBlock($v);
|
||||||
|
if($b->isSolid === true) break;
|
||||||
|
if(($b instanceof LiquidBlock) or $b->getID() === COBWEB or $b->getID() === LADDER or $b->getID() === FENCE or $b->getID() === STONE_WALL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
while ($i<200);
|
||||||
|
if ($i==200) $i=0;
|
||||||
$data = array(
|
$data = array(
|
||||||
"x" => $pos->x + mt_rand(-10, 10) / 50,
|
"x" => $pos->x + mt_rand(-10, 10) / 50,
|
||||||
"y" => $pos->y + 0.19,
|
"y" => $pos->y + 0.19 - $i + 1,
|
||||||
"z" => $pos->z + mt_rand(-10, 10) / 50,
|
"z" => $pos->z + mt_rand(-10, 10) / 50,
|
||||||
"level" => $pos->level,
|
"level" => $pos->level,
|
||||||
//"speedX" => mt_rand(-3, 3) / 8,
|
//"speedX" => mt_rand(-3, 3) / 8,
|
||||||
|
|
@ -130,6 +142,7 @@ class EntityAPI{
|
||||||
//"speedZ" => mt_rand(-3, 3) / 8,
|
//"speedZ" => mt_rand(-3, 3) / 8,
|
||||||
"item" => $item,
|
"item" => $item,
|
||||||
);
|
);
|
||||||
|
|
||||||
if($this->server->api->handle("item.drop", $data) !== false){
|
if($this->server->api->handle("item.drop", $data) !== false){
|
||||||
for($count = $item->count; $count > 0; ){
|
for($count = $item->count; $count > 0; ){
|
||||||
$item->count = min($item->getMaxStackSize(), $count);
|
$item->count = min($item->getMaxStackSize(), $count);
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ class LevelAPI{
|
||||||
|
|
||||||
$timeu = microtime(true);
|
$timeu = microtime(true);
|
||||||
foreach($blockUpdates->getAll() as $bupdate){
|
foreach($blockUpdates->getAll() as $bupdate){
|
||||||
$this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"],(int) $bupdate["y"],(int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
$this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"],(int) $bupdate["y"],(int) $bupdate["z"], $this->levels["name"]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,6 @@ class PluginAPI extends stdClass{
|
||||||
$this->randomNonce = Utils::getRandomBytes(16, false);
|
$this->randomNonce = Utils::getRandomBytes(16, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct(){
|
|
||||||
foreach($this->plugins as $p){
|
|
||||||
$p[0]->__destruct();
|
|
||||||
}
|
|
||||||
unset($plugins);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getList(){
|
public function getList(){
|
||||||
$list = array();
|
$list = array();
|
||||||
foreach($this->plugins as $p){
|
foreach($this->plugins as $p){
|
||||||
|
|
|
||||||
|
|
@ -1285,8 +1285,6 @@ class Player{
|
||||||
$this->username = $data["username"];
|
$this->username = $data["username"];
|
||||||
$this->iusername = strtolower($this->username);
|
$this->iusername = strtolower($this->username);
|
||||||
}else{
|
}else{
|
||||||
$this->username = $data["username"];
|
|
||||||
$this->iusername = strtolower($this->username);
|
|
||||||
$this->close("Bad username", false);
|
$this->close("Bad username", false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1309,6 +1307,11 @@ class Player{
|
||||||
$u->close("logged in from another location");
|
$u->close("logged in from another location");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($this->CID) or $this->CID == null){
|
||||||
|
console("[DEBUG] Player ".$this->username." does not have a CID", true, true, 2);
|
||||||
|
$this->CID = Utils::readLong(Utils::getRandomBytes(8, false));
|
||||||
|
}
|
||||||
|
|
||||||
$this->server->api->player->add($this->CID);
|
$this->server->api->player->add($this->CID);
|
||||||
if($this->server->api->handle("player.join", $this) === false){
|
if($this->server->api->handle("player.join", $this) === false){
|
||||||
$this->close("join cancelled", false);
|
$this->close("join cancelled", false);
|
||||||
|
|
@ -1370,7 +1373,7 @@ class Player{
|
||||||
));
|
));
|
||||||
if(($this->gamemode & 0x01) === 0x01){
|
if(($this->gamemode & 0x01) === 0x01){
|
||||||
$this->slot = 0;
|
$this->slot = 0;
|
||||||
$this->hotbar = array();
|
$this->hotbar = array();
|
||||||
}elseif($this->data->exists("hotbar")){
|
}elseif($this->data->exists("hotbar")){
|
||||||
$this->hotbar = $this->data->get("hotbar");
|
$this->hotbar = $this->data->get("hotbar");
|
||||||
$this->slot = $this->hotbar[0];
|
$this->slot = $this->hotbar[0];
|
||||||
|
|
@ -2218,6 +2221,7 @@ class Player{
|
||||||
foreach($this->hotbar as $slot){
|
foreach($this->hotbar as $slot){
|
||||||
$hotbar[] = $slot <= -1 ? -1 : $slot + 9;
|
$hotbar[] = $slot <= -1 ? -1 : $slot + 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dataPacket(MC_CONTAINER_SET_CONTENT, array(
|
$this->dataPacket(MC_CONTAINER_SET_CONTENT, array(
|
||||||
"windowid" => 0,
|
"windowid" => 0,
|
||||||
"count" => count($this->inventory),
|
"count" => count($this->inventory),
|
||||||
|
|
|
||||||
|
|
@ -413,7 +413,6 @@ class PocketMinecraftServer{
|
||||||
if(stripos($er["file"], "plugin") !== false){
|
if(stripos($er["file"], "plugin") !== false){
|
||||||
$dump .= "THIS ERROR WAS CAUSED BY A PLUGIN. REPORT IT TO THE PLUGIN DEVELOPER.\r\n";
|
$dump .= "THIS ERROR WAS CAUSED BY A PLUGIN. REPORT IT TO THE PLUGIN DEVELOPER.\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$dump .= "Code: \r\n";
|
$dump .= "Code: \r\n";
|
||||||
$file = @file($er["file"], FILE_IGNORE_NEW_LINES);
|
$file = @file($er["file"], FILE_IGNORE_NEW_LINES);
|
||||||
for($l = max(0, $er["line"] - 10); $l < $er["line"] + 10; ++$l){
|
for($l = max(0, $er["line"] - 10); $l < $er["line"] + 10; ++$l){
|
||||||
|
|
@ -444,7 +443,6 @@ class PocketMinecraftServer{
|
||||||
}
|
}
|
||||||
$dump .= "\r\n\r\n";
|
$dump .= "\r\n\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
foreach(get_loaded_extensions() as $ext){
|
foreach(get_loaded_extensions() as $ext){
|
||||||
$extensions[$ext] = phpversion($ext);
|
$extensions[$ext] = phpversion($ext);
|
||||||
|
|
|
||||||
|
|
@ -21,23 +21,36 @@
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set("GMT");
|
if(ini_get("date.timezone") == ""){ //No Timezone set
|
||||||
if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){
|
date_default_timezone_set("GMT");
|
||||||
$time = time();
|
if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){
|
||||||
$time -= $time % 60;
|
$time = time();
|
||||||
exec("time.exe /T", $hour);
|
$time -= $time % 60;
|
||||||
$i = array_map("intval", explode(":", trim($hour[0])));
|
//TODO: Parse different time & date formats by region. ¬¬ world
|
||||||
exec("date.exe /T", $date);
|
//Example: USA
|
||||||
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
|
exec("time.exe /T", $hour);
|
||||||
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
|
$i = array_map("intval", explode(":", trim($hour[0])));
|
||||||
}else{
|
exec("date.exe /T", $date);
|
||||||
exec("date +%s", $t);
|
$j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0])));
|
||||||
$offset = round((intval(trim($t[0])) - time()) / 60) * 60;
|
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
|
||||||
}
|
}else{
|
||||||
|
exec("date +%s", $t);
|
||||||
|
$offset = round((intval(trim($t[0])) - time()) / 60) * 60;
|
||||||
|
}
|
||||||
|
|
||||||
$daylight = (int) date("I");
|
$daylight = (int) date("I");
|
||||||
|
|
||||||
date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight));
|
$d = timezone_name_from_abbr("", $offset, $daylight);
|
||||||
|
ini_set("date.timezone", $d);
|
||||||
|
date_default_timezone_set($d);
|
||||||
|
}else{
|
||||||
|
$d = @date_default_timezone_get();
|
||||||
|
if(strpos($d, "/") === false){
|
||||||
|
$d = timezone_name_from_abbr($d);
|
||||||
|
ini_set("date.timezone", $d);
|
||||||
|
date_default_timezone_set($d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gc_enable();
|
gc_enable();
|
||||||
error_reporting(E_ALL | E_STRICT);
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ function console($message, $EOL = true, $log = true, $level = 1){
|
||||||
if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){
|
if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){
|
||||||
switch($matches[1]){
|
switch($matches[1]){
|
||||||
case "ERROR":
|
case "ERROR":
|
||||||
case "SEVERE":
|
case "SEVERE":
|
||||||
$add .= FORMAT_RED;
|
$add .= FORMAT_RED;
|
||||||
break;
|
break;
|
||||||
case "INTERNAL":
|
case "INTERNAL":
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,3 @@ class Window{
|
||||||
$this->server = ServerAPI::request();
|
$this->server = ServerAPI::request();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
@ -37,12 +37,12 @@ class SugarcaneBlock extends FlowableBlock{
|
||||||
for($y = 1; $y < 3; ++$y){
|
for($y = 1; $y < 3; ++$y){
|
||||||
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||||
if($b->getID() === AIR){
|
if($b->getID() === AIR){
|
||||||
$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
|
//$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->meta = 0;
|
$this->meta = 0;
|
||||||
$this->level->setBlock($this, $this, true, false, true);
|
//$this->level->setBlock($this, $this, true, false, true);
|
||||||
}
|
}
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
$item->count--;
|
$item->count--;
|
||||||
|
|
@ -56,25 +56,25 @@ class SugarcaneBlock extends FlowableBlock{
|
||||||
if($type === BLOCK_UPDATE_NORMAL){
|
if($type === BLOCK_UPDATE_NORMAL){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method
|
if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method
|
||||||
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
|
//ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
|
||||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||||
return BLOCK_UPDATE_NORMAL;
|
return BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
}elseif($type === BLOCK_UPDATE_RANDOM){
|
}elseif($type === BLOCK_UPDATE_RANDOM){
|
||||||
if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
|
if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
|
||||||
if($this->meta === 0x0F){
|
if($this->meta === 0x0F){
|
||||||
for($y = 1; $y < 3; ++$y){
|
//for($y = 1; $y < 3; ++$y){
|
||||||
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
//$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||||
if($b->getID() === AIR){
|
//if($b->getID() === AIR){
|
||||||
$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
|
// $this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
|
||||||
break;
|
//break;
|
||||||
}
|
//}
|
||||||
}
|
//}
|
||||||
$this->meta = 0;
|
$this->meta = 0;
|
||||||
$this->level->setBlock($this, $this, true, false, true);
|
//$this->level->setBlock($this, $this, true, false, true);
|
||||||
}else{
|
}else{
|
||||||
++$this->meta;
|
++$this->meta;
|
||||||
$this->level->setBlock($this, $this, true, false, true);
|
//$this->level->setBlock($this, $this, true, false, true);
|
||||||
}
|
}
|
||||||
return BLOCK_UPDATE_RANDOM;
|
return BLOCK_UPDATE_RANDOM;
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +85,7 @@ class SugarcaneBlock extends FlowableBlock{
|
||||||
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){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
if($down->getID() === SUGARCANE_BLOCK){
|
if($down->getID() === SUGARCANE_BLOCK){
|
||||||
$this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
|
//$this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
|
||||||
return true;
|
return true;
|
||||||
}elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
|
}elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
|
||||||
$block0 = $down->getSide(2);
|
$block0 = $down->getSide(2);
|
||||||
|
|
@ -93,8 +93,8 @@ class SugarcaneBlock extends FlowableBlock{
|
||||||
$block2 = $down->getSide(4);
|
$block2 = $down->getSide(4);
|
||||||
$block3 = $down->getSide(5);
|
$block3 = $down->getSide(5);
|
||||||
if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
|
if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
|
||||||
$this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
|
// $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
|
||||||
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
|
// $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ class LeavesBlock extends TransparentBlock{
|
||||||
if(mt_rand(1,20) === 1){ //Saplings
|
if(mt_rand(1,20) === 1){ //Saplings
|
||||||
$drops[] = array(SAPLING, $this->meta & 0x03, 1);
|
$drops[] = array(SAPLING, $this->meta & 0x03, 1);
|
||||||
}
|
}
|
||||||
if(($this->meta & 0x03) === LeavesBlock::OAK and mt_rand(1,200) === 1){ //Apples
|
if(($this->meta & 0x03) === LeavesBlock::OAK and mt_rand(1,100) === 1){ //Apples
|
||||||
$drops[] = array(APPLE, 0, 1);
|
$drops[] = array(APPLE, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,24 +28,9 @@ class BucketItem extends Item{
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($this->meta === AIR){
|
if($this->meta === AIR){
|
||||||
if($target instanceof LiquidBlock){
|
//Nope
|
||||||
$level->setBlock($target, new AirBlock(), true, false, true);
|
|
||||||
if(($player->gamemode & 0x01) === 0){
|
|
||||||
$this->meta = ($target instanceof WaterBlock) ? WATER:LAVA;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}elseif($this->meta === WATER){
|
}elseif($this->meta === WATER){
|
||||||
//Support Make Non-Support Water to Support Water
|
//Nope
|
||||||
if($block->getID() === AIR || ( $block instanceof WaterBlock && ($block->getMetadata() & 0x07) != 0x00 ) ){
|
|
||||||
$water = new WaterBlock();
|
|
||||||
$level->setBlock($block, $water, true, false, true);
|
|
||||||
$water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
|
||||||
if(($player->gamemode & 0x01) === 0){
|
|
||||||
$this->meta = 0;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}elseif($this->meta === LAVA){
|
}elseif($this->meta === LAVA){
|
||||||
if($block->getID() === AIR){
|
if($block->getID() === AIR){
|
||||||
$level->setBlock($block, new LavaBlock(), true, false, true);
|
$level->setBlock($block, new LavaBlock(), true, false, true);
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,11 @@ class Cache{
|
||||||
public static $cached = array();
|
public static $cached = array();
|
||||||
|
|
||||||
public static function add($identifier, $blob, $minTTL = 30){
|
public static function add($identifier, $blob, $minTTL = 30){
|
||||||
self::$cached[$identifier] = array($blob, microtime(true) + $minTTL, $minTTL);
|
self::$cached[$identifier] = array($blob, microtime(true) + $minTTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get($identifier){
|
public static function get($identifier){
|
||||||
if(isset(self::$cached[$identifier])){
|
if(isset(self::$cached[$identifier])){
|
||||||
self::$cached[$identifier][1] += $minTTL;
|
|
||||||
return self::$cached[$identifier][0];
|
return self::$cached[$identifier][0];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -256,13 +256,13 @@ class Config{
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function exists($k, $lowercase = false){
|
public function exists($k, $lowercase = false){
|
||||||
if($lowercase === true){
|
if($lowercase === true){
|
||||||
$k = strtolower($k);//Convert requested key to lower
|
$k = strtolower($k);//Convert requested key to lower
|
||||||
$array = array_change_key_case($this->config, CASE_LOWER);//Change all keys in array to lower
|
$array = array_change_key_case($this->config, CASE_LOWER);//Change all keys in array to lower
|
||||||
return isset($array[$k]);//Find $k in modified array
|
return isset($array[$k]);//Find $k in modified array
|
||||||
}else{
|
}else{
|
||||||
return isset($this->config[$k]);
|
return isset($this->config[$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readTriad($str){
|
public static function readTriad($str){
|
||||||
list(,$unpacked) = unpack("N", "\x00".$str);
|
list(,$unpacked) = @unpack("N", "\x00".$str);
|
||||||
return $unpacked;
|
return $unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -457,7 +457,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readShort($str, $signed = true){
|
public static function readShort($str, $signed = true){
|
||||||
list(,$unpacked) = unpack("n", $str);
|
list(,$unpacked) = @unpack("n", $str);
|
||||||
if($unpacked > 0x7fff and $signed === true){
|
if($unpacked > 0x7fff and $signed === true){
|
||||||
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
||||||
}
|
}
|
||||||
|
|
@ -472,7 +472,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readLShort($str, $signed = true){
|
public static function readLShort($str, $signed = true){
|
||||||
list(,$unpacked) = unpack("v", $str);
|
list(,$unpacked) = @unpack("v", $str);
|
||||||
if($unpacked > 0x7fff and $signed === true){
|
if($unpacked > 0x7fff and $signed === true){
|
||||||
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
$unpacked -= 0x10000; // Convert unsigned short to signed short
|
||||||
}
|
}
|
||||||
|
|
@ -487,7 +487,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readInt($str){
|
public static function readInt($str){
|
||||||
list(,$unpacked) = unpack("N", $str);
|
list(,$unpacked) = @unpack("N", $str);
|
||||||
if($unpacked >= 2147483648){
|
if($unpacked >= 2147483648){
|
||||||
$unpacked -= 4294967296;
|
$unpacked -= 4294967296;
|
||||||
}
|
}
|
||||||
|
|
@ -502,7 +502,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readLInt($str){
|
public static function readLInt($str){
|
||||||
list(,$unpacked) = unpack("V", $str);
|
list(,$unpacked) = @unpack("V", $str);
|
||||||
if($unpacked >= 2147483648){
|
if($unpacked >= 2147483648){
|
||||||
$unpacked -= 4294967296;
|
$unpacked -= 4294967296;
|
||||||
}
|
}
|
||||||
|
|
@ -517,7 +517,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readFloat($str){
|
public static function readFloat($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("f", $str):unpack("f", strrev($str));
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", $str):@unpack("f", strrev($str));
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -526,7 +526,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readLFloat($str){
|
public static function readLFloat($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("f", strrev($str)):unpack("f", $str);
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("f", strrev($str)):@unpack("f", $str);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -539,7 +539,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readDouble($str){
|
public static function readDouble($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("d", $str):unpack("d", strrev($str));
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", $str):@unpack("d", strrev($str));
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,7 +548,7 @@ class Utils{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function readLDouble($str){
|
public static function readLDouble($str){
|
||||||
list(,$value) = ENDIANNESS === BIG_ENDIAN ? unpack("d", strrev($str)):unpack("d", $str);
|
list(,$value) = ENDIANNESS === BIG_ENDIAN ? @unpack("d", strrev($str)):@unpack("d", $str);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -569,7 +569,7 @@ class Utils{
|
||||||
|
|
||||||
for($i = 0; $i < 8; $i += 4){
|
for($i = 0; $i < 8; $i += 4){
|
||||||
$value = bcmul($value, "4294967296", 0); //4294967296 == 2^32
|
$value = bcmul($value, "4294967296", 0); //4294967296 == 2^32
|
||||||
$value = bcadd($value, 0x1000000 * ord($x{$i}) + ((ord($x{$i + 1}) << 16) | (ord($x{$i + 2}) << 8) | ord($x{$i + 3})), 0);
|
$value = bcadd($value, 0x1000000 * ord(@$x{$i}) + ((ord(@$x{$i + 1}) << 16) | (ord(@$x{$i + 2}) << 8) | ord(@$x{$i + 3})), 0);
|
||||||
}
|
}
|
||||||
return ($negative === true ? "-".$value:$value);
|
return ($negative === true ? "-".$value:$value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@ class Entity extends Position{
|
||||||
case MOB_PIGMAN:
|
case MOB_PIGMAN:
|
||||||
return array(
|
return array(
|
||||||
array(COOKED_PORKCHOP, 0, mt_rand(0,2)),
|
array(COOKED_PORKCHOP, 0, mt_rand(0,2)),
|
||||||
|
array(GOLD_INGOT, 0, mt_rand(0,2)),
|
||||||
);
|
);
|
||||||
case MOB_CREEPER:
|
case MOB_CREEPER:
|
||||||
return array(
|
return array(
|
||||||
|
|
@ -367,10 +368,7 @@ class Entity extends Position{
|
||||||
break;
|
break;
|
||||||
case FIRE: //Fire block damage
|
case FIRE: //Fire block damage
|
||||||
if($this->inBlock(new Vector3($x, $y, $z))){
|
if($this->inBlock(new Vector3($x, $y, $z))){
|
||||||
$this->harm(1, "fire");
|
//patched
|
||||||
$this->fire = 300;
|
|
||||||
$this->updateMetadata();
|
|
||||||
$hasUpdate = true;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CACTUS: //Cactus damage
|
case CACTUS: //Cactus damage
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,11 @@ class Explosion{
|
||||||
$server->api->entity->spawnToAll($e);
|
$server->api->entity->spawnToAll($e);
|
||||||
}elseif(mt_rand(0, 10000) < ((1/$this->size) * 10000)){
|
}elseif(mt_rand(0, 10000) < ((1/$this->size) * 10000)){
|
||||||
if(isset(self::$specialDrops[$block->getID()])){
|
if(isset(self::$specialDrops[$block->getID()])){
|
||||||
$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem(self::$specialDrops[$block->getID()], 0));
|
//$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem(self::$specialDrops[$block->getID()], 0));
|
||||||
|
return;
|
||||||
}else{
|
}else{
|
||||||
$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z)));
|
//$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z)));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
|
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
|
||||||
|
|
|
||||||
|
|
@ -389,7 +389,7 @@ class Level{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Cache::remove("world:{$this->name}:$X:$Z");
|
Cache::remove("world:{$this->name}:$X:$Z");
|
||||||
return $this->level->unloadChunk($X, $Z);
|
return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrderedChunk($X, $Z, $Yndex){
|
public function getOrderedChunk($X, $Z, $Yndex){
|
||||||
|
|
@ -404,7 +404,6 @@ class Level{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$raw = array();
|
$raw = array();
|
||||||
for($Y = 0; $Y < 8; ++$Y){
|
for($Y = 0; $Y < 8; ++$Y){
|
||||||
if(($Yndex & (1 << $Y)) > 0){
|
if(($Yndex & (1 << $Y)) > 0){
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class MineshaftPopulator extends Populator{
|
||||||
|
|
||||||
public function populate(Level $level, $chunkX, $chunkZ, Random $random){
|
public function populate(Level $level, $chunkX, $chunkZ, Random $random){
|
||||||
if($random->nextRange(0, MineshaftPopulator::$ODD) === 0){
|
if($random->nextRange(0, MineshaftPopulator::$ODD) === 0){
|
||||||
//$mineshaft = new Mineshaft($random);
|
$mineshaft = new Mineshaft($random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue