mojira.dev
MC-266763

PlayerList.class cause lag spike

After death, when player respawn. Minecraft run function placeNewPlayer. In this function call other function: this.sendPlayerPermissionLevel(serverPlayer); In this functino calls this.server.getCommands().sendCommands(serverPlayer);
When call sendCommands, all commands collect for player - place all command to packet if permission exists.
Example singleplayer world without cheat.
gamerule command require cheat - ignore.
trigger command not require cheat. Collect arguments (list of arguments u can see at wiki)
Than all collected command parse in constructor of class ClientboundCommandsPacket.
And last - send to client.

What problem? If add some new modded command. Run game. Set gamerule doImmediateRespawn true. Run kill command. Watch video before run command /say second part - item loaded after wait 1-2 second. If add some more command i can walk and server not track any my movement, only result. If i place command block, that kill all player in distance 1..2 around spawn - dont kill on spawn position and far spawn position, i can walk and not death - server think that i stay, than teleport to position.

How to fix?

Solution first. Its increase speed of loading singleplayer world, because packet with commands tree can configured more than 1-2 second. Player can play without command while it configured. And its increase speed of joining to server - same reason - client havent command, because server in configure command tree packet and sent when end.
Run function in new thread Commands#sendCommand
public void sendCommands(ServerPlayer serverPlayer) {
<body>
}
to
Executors.newSingleThreadExecutor().execute(() -> {<body>});
Watch video after run command /say second part

Solution second.
Cache command tree or not send when respawn. Commands tree don't change after death and client already have its. Than, send same command tree - spent resource of server side and internet (not lan player), because tree on client is same, that sent in packet.

Linked issues

Attachments

Comments

ampolive

Does this affect vanilla in any way?

migrated

Than more command or command node (argument) add mojang - than more lag spike after every respawn. Than more mod installed, than more this lag will be seeing by player

migrated

Its bug work for all java edition of Minecraft -vanilla, forge, fabric. But at this time, it can be found after add several command. In next versions it will affect more - more command. More lag

Fantastime

Modded only issue

migrated

(Unassigned)

Plausible

Performance

death, lag, lag-spike, respawn, respawning

1.20.2, 23w46a

Retrieved