mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-13 04:33:52 +00:00
Feature/plugin api experimental (#12)
* added a null check to fix crash, expose internal latency value (its buggy) * fix latency calculations * sending packets from c# * world save event, move shutdown def, move called location of shutdown, expose FourKit.FireEvent * add docs --------- Co-authored-by: sylvessa <225480449+sylvessa@users.noreply.github.com>
This commit is contained in:
parent
682989c8f1
commit
21b5accc69
18 changed files with 1420 additions and 20 deletions
|
|
@ -350,7 +350,7 @@ void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet)
|
|||
// Anti-cheat: reject movement packets that exceed server-authoritative bounds.
|
||||
double velocitySq = player->xd * player->xd + player->yd * player->yd + player->zd * player->zd;
|
||||
double maxAllowedSq = kMoveBaseAllowanceSq + (velocitySq * kMoveVelocityAllowanceScale);
|
||||
if (player->isAllowedToFly() || player->gameMode->isCreative())
|
||||
if (player->isAllowedToFly() || (player->gameMode != nullptr && player->gameMode->isCreative()))
|
||||
{
|
||||
// Creative / flight-allowed players can move farther legitimately per tick.
|
||||
maxAllowedSq *= 1.5;
|
||||
|
|
@ -1717,8 +1717,13 @@ void PlayerConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
|
|||
{
|
||||
if (packet->id == lastKeepAliveId)
|
||||
{
|
||||
int time = static_cast<int>(System::nanoTime() / 1000000 - lastKeepAliveTime);
|
||||
player->latency = (player->latency * 3 + time) / 4;
|
||||
int64_t now = (System::nanoTime() / 1000000);
|
||||
if (lastKeepAliveTime == 0) lastKeepAliveTime = now;
|
||||
int64_t delta = static_cast<int64_t>(now - lastKeepAliveTime);
|
||||
|
||||
player->latency = (player->latency * 3 + delta) / 4;
|
||||
|
||||
lastKeepAliveTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue