mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
added force-20-tps as extra property
This commit is contained in:
parent
657beafb2a
commit
f3228ece20
2 changed files with 40 additions and 27 deletions
|
|
@ -11,7 +11,7 @@ class PocketMinecraftServer{
|
||||||
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0;
|
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0;
|
||||||
|
|
||||||
public $doTick, $levelData, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $difficulty, $stop, $asyncThread;
|
public $doTick, $levelData, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $difficulty, $stop, $asyncThread;
|
||||||
|
public static $FORCE_20_TPS = false;
|
||||||
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
|
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;
|
||||||
|
|
@ -89,15 +89,20 @@ class PocketMinecraftServer{
|
||||||
"despawn-mobs" => true,
|
"despawn-mobs" => true,
|
||||||
"mob-despawn-ticks" => 18000,
|
"mob-despawn-ticks" => 18000,
|
||||||
"16x16x16_chunk_sending" => false,
|
"16x16x16_chunk_sending" => false,
|
||||||
"experimental-mob-ai" => false,
|
"experimental-mob-ai" => false,
|
||||||
|
"force-20-tps" => false,
|
||||||
]);
|
]);
|
||||||
Player::$smallChunks = $this->extraprops->get("16x16x16_chunk_sending");
|
Player::$smallChunks = $this->extraprops->get("16x16x16_chunk_sending");
|
||||||
Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
|
Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
|
||||||
Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
|
Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
|
||||||
|
self::$FORCE_20_TPS = $this->extraprops->get("force-20-tps");
|
||||||
PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data");
|
PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data");
|
||||||
MobController::$ADVANCED = $this->extraprops->get("experimental-mob-ai");
|
MobController::$ADVANCED = $this->extraprops->get("experimental-mob-ai");
|
||||||
Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");
|
Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");
|
||||||
NetherReactorBlock::$enableReactor = $this->extraprops->get("enable-nether-reactor");
|
NetherReactorBlock::$enableReactor = $this->extraprops->get("enable-nether-reactor");
|
||||||
|
if(self::$FORCE_20_TPS){
|
||||||
|
ConsoleAPI::warn("Forcing 20 tps. This may result in higher CPU usage!");
|
||||||
|
}
|
||||||
if($this->extraprops->get("discord-msg") == true){
|
if($this->extraprops->get("discord-msg") == true){
|
||||||
if($this->extraprops->get("discord-webhook-url") !== "none"){
|
if($this->extraprops->get("discord-webhook-url") !== "none"){
|
||||||
console("[INFO] Discord Logger is enabled.");
|
console("[INFO] Discord Logger is enabled.");
|
||||||
|
|
@ -467,27 +472,38 @@ class PocketMinecraftServer{
|
||||||
public function process()
|
public function process()
|
||||||
{
|
{
|
||||||
$lastLoop = 0;
|
$lastLoop = 0;
|
||||||
while($this->stop === false){
|
|
||||||
$packet = $this->interface->readPacket();
|
if(self::$FORCE_20_TPS){
|
||||||
if($packet instanceof Packet){
|
while($this->stop === false){
|
||||||
$this->packetHandler($packet);
|
$packet = $this->interface->readPacket();
|
||||||
$lastLoop = 0;
|
if($packet instanceof Packet) $this->packetHandler($packet);
|
||||||
} elseif($this->tick() > 0){
|
$this->tick();
|
||||||
$lastLoop = 0;
|
}
|
||||||
} else{
|
}else{
|
||||||
++ $lastLoop;
|
while($this->stop === false){
|
||||||
if($lastLoop < 16){
|
$packet = $this->interface->readPacket();
|
||||||
usleep(1);
|
if($packet instanceof Packet){
|
||||||
} elseif($lastLoop < 128){
|
$this->packetHandler($packet);
|
||||||
usleep(100);
|
$lastLoop = 0;
|
||||||
} elseif($lastLoop < 256){
|
} elseif($this->tick() > 0){
|
||||||
usleep(512);
|
$lastLoop = 0;
|
||||||
} else{
|
} else{
|
||||||
usleep(10000);
|
++ $lastLoop;
|
||||||
}
|
if($lastLoop < 16){
|
||||||
|
usleep(1);
|
||||||
|
} elseif($lastLoop < 128){
|
||||||
|
usleep(100);
|
||||||
|
} elseif($lastLoop < 256){
|
||||||
|
usleep(512);
|
||||||
|
} else{
|
||||||
|
usleep(10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->tick();
|
||||||
}
|
}
|
||||||
$this->tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function packetHandler(Packet $packet){
|
public function packetHandler(Packet $packet){
|
||||||
|
|
|
||||||
|
|
@ -638,12 +638,9 @@ class Entity extends Position
|
||||||
|
|
||||||
if($update === true){
|
if($update === true){
|
||||||
$hasUpdate = true;
|
$hasUpdate = true;
|
||||||
if(($this->server->ticks % 4 === 0 && $this->class === ENTITY_ITEM) || $this->class != ENTITY_ITEM){ //update item speed every 4 ticks
|
$this->lastSpeedZ = $this->speedZ;
|
||||||
//$this->server->api->handle("entity.motion", $this);
|
$this->lastSpeedY = $this->speedY;
|
||||||
$this->lastSpeedZ = $this->speedZ;
|
$this->lastSpeedX = $this->speedX;
|
||||||
$this->lastSpeedY = $this->speedY;
|
|
||||||
$this->lastSpeedX = $this->speedX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->updateFallState($this->speedY);
|
$this->updateFallState($this->speedY);
|
||||||
} elseif($this->player instanceof Player){
|
} elseif($this->player instanceof Player){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue