mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
added ability to disable light updates
This commit is contained in:
parent
207dd0ffcd
commit
c2faff0f22
3 changed files with 15 additions and 4 deletions
|
|
@ -12,7 +12,7 @@ class PocketMinecraftServer{
|
|||
|
||||
public $doTick, $levelData, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $difficulty, $stop, $asyncThread;
|
||||
public static $FORCE_20_TPS = false, $KEEP_CHUNKS_LOADED = true, $PACKET_READING_LIMIT = 100;
|
||||
|
||||
public static $ENABLE_LIGHT_UPDATES = true;
|
||||
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
|
||||
$this->port = (int) $port;
|
||||
$this->doTick = true;
|
||||
|
|
@ -97,7 +97,8 @@ class PocketMinecraftServer{
|
|||
"keep-items-on-death" => Entity::$keepInventory,
|
||||
"disable-emojis-in-chat" => Player::$disableEmojisInChat,
|
||||
"disable-emojis-on-signs" => Level::$disableEmojisOnSigns,
|
||||
"allow-dropping-single-items" => Player::$allowDroppingSingleItems
|
||||
"allow-dropping-single-items" => Player::$allowDroppingSingleItems,
|
||||
"enable-light-updates" => self::$ENABLE_LIGHT_UPDATES,
|
||||
]);
|
||||
Player::$disableEmojisInChat = $this->extraprops->get("disable-emojis-in-chat");
|
||||
Level::$disableEmojisOnSigns = $this->extraprops->get("disable-emojis-on-signs");
|
||||
|
|
@ -109,6 +110,7 @@ class PocketMinecraftServer{
|
|||
Living::$entityPushing = $this->extraprops->get("enable-mob-pushing");
|
||||
self::$FORCE_20_TPS = $this->extraprops->get("force-20-tps");
|
||||
self::$KEEP_CHUNKS_LOADED = $this->extraprops->get("keep-chunks-loaded");
|
||||
self::$ENABLE_LIGHT_UPDATES = $this->extraprops->get("enable-light-updates");
|
||||
PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data");
|
||||
MobController::$ADVANCED = $this->extraprops->get("experimental-mob-ai");
|
||||
Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");
|
||||
|
|
@ -116,6 +118,9 @@ class PocketMinecraftServer{
|
|||
if(self::$FORCE_20_TPS){
|
||||
ConsoleAPI::warn("Forcing 20 tps. This may result in higher CPU usage!");
|
||||
}
|
||||
if(!self::$ENABLE_LIGHT_UPDATES){
|
||||
ConsoleAPI::warn("Light updates are disabled: this should decrease memory consumption and increase performance, but will prevent all existing light from updating and disable some light-dependant features.");
|
||||
}
|
||||
if($this->extraprops->get("discord-msg")){
|
||||
if($this->extraprops->get("discord-webhook-url") !== "none"){
|
||||
console("[INFO] Discord Logger is enabled.");
|
||||
|
|
|
|||
|
|
@ -394,6 +394,10 @@ class PMFLevel extends PMF{
|
|||
}
|
||||
|
||||
public function forceLightUpdatesIfNeeded(){
|
||||
if(!PocketMinecraftServer::$ENABLE_LIGHT_UPDATES) {
|
||||
$this->checkLight = [];
|
||||
return;
|
||||
}
|
||||
foreach($this->checkLight as $index => [$X, $Z]){
|
||||
$update = false;
|
||||
if(!$this->hasBlocklight($X, $Z)){
|
||||
|
|
@ -508,7 +512,7 @@ class PMFLevel extends PMF{
|
|||
}
|
||||
|
||||
public function getBlockLight($x, $y, $z){
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255 || $y < 0 || $y > 127) return 0;
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255 || $y < 0 || $y > 127 || !PocketMinecraftServer::$ENABLE_LIGHT_UPDATES) return 0;
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
|
|
@ -522,7 +526,7 @@ class PMFLevel extends PMF{
|
|||
}
|
||||
|
||||
public function setBlockLight($x, $y, $z, $value){
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255 || $y < 0 || $y > 127) return false;
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255 || $y < 0 || $y > 127 || !PocketMinecraftServer::$ENABLE_LIGHT_UPDATES) return false;
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
|
|
|
|||
|
|
@ -532,6 +532,7 @@ class Level{
|
|||
public $lightUpdates = [];
|
||||
public $lightUpdateIndx = -1;
|
||||
public function handleBlockLightUpdate($minX, $minY, $minZ, $maxX, $maxY, $maxZ){
|
||||
if(!PocketMinecraftServer::$ENABLE_LIGHT_UPDATES) return;
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
for($y = $minY; $y <= $maxY; ++$y){
|
||||
|
|
@ -604,6 +605,7 @@ class Level{
|
|||
* @param int $maxZ - must be in range (0, 255). Must be more than minZ.
|
||||
*/
|
||||
public function updateLight($layer, $minX, $minY, $minZ, $maxX, $maxY, $maxZ){
|
||||
if(!PocketMinecraftServer::$ENABLE_LIGHT_UPDATES) return;
|
||||
/*$max = 5; //no idea is it needed for block light
|
||||
$sz = $this->lightUpdateIndx;
|
||||
if($sz < $max) $max = $sz;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue