Commit 3ed8098
committed
Adjust tick loop logic
There were a few problems in the tick loop code:
1. Not all tasks may be executed before server stop
2. Not all tasks may have been executed before server tick
3. Tasks may not have been executed while waiting for next server tick
Note that tasks exclusively refer to tasks scheduled directly
to the MinecraftServer.
For the first issue, we apply a fix where we execute all tasks
on server stop. However, this is not a true fix. Tasks could be
scheduled while the server is stopping. This simply reduces us
to being no worse off than Vanilla.
This particularly fixes the client freezing when disconnecting
from a singleplayer world - see the logic in
Minecraft#disconnect(Screen, boolean, boolean) where it invokes
IntegratedServer#halt(boolean).
For the second issue, we rework the tick tracking on TickTask so
that it uses our own counter which we increment immediately
before beginning to process tasks. Additionally, we fix the
shouldRun logic so that it allows tasks as long as the current
tick is strictly greater-than the task tick (before, it checked
if the task tick + 1 (3 Vanilla) was strictly less-than).
See comments in the server mixin around #shouldRun,
details.
We fix the final issue by allowing task execution in #shouldRun
if we are currently awaiting the next tick. The reason this is a
fix is due to the fact that our logic to await the next tick
does not run in the managedBlock function, which bypasses
the shouldRun check.
Tuinity/Moonrise@e394e331 parent c700325 commit 3ed8098
File tree
2 files changed
+69
-12
lines changed- paper-server/patches/sources/net/minecraft
- server
- util/thread
2 files changed
+69
-12
lines changedLines changed: 45 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
119 | 134 | | |
120 | 135 | | |
121 | 136 | | |
| |||
562 | 577 | | |
563 | 578 | | |
564 | 579 | | |
565 | | - | |
| 580 | + | |
566 | 581 | | |
567 | 582 | | |
568 | 583 | | |
| |||
578 | 593 | | |
579 | 594 | | |
580 | 595 | | |
| 596 | + | |
581 | 597 | | |
582 | 598 | | |
583 | 599 | | |
| |||
648 | 664 | | |
649 | 665 | | |
650 | 666 | | |
651 | | - | |
| 667 | + | |
652 | 668 | | |
653 | 669 | | |
654 | 670 | | |
| |||
699 | 715 | | |
700 | 716 | | |
701 | 717 | | |
702 | | - | |
703 | | - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
704 | 725 | | |
705 | 726 | | |
706 | 727 | | |
| |||
737 | 758 | | |
738 | 759 | | |
739 | 760 | | |
740 | | - | |
741 | 761 | | |
742 | 762 | | |
743 | 763 | | |
| |||
836 | 856 | | |
837 | 857 | | |
838 | 858 | | |
839 | | - | |
| 859 | + | |
840 | 860 | | |
841 | 861 | | |
842 | 862 | | |
| |||
912 | 932 | | |
913 | 933 | | |
914 | 934 | | |
915 | | - | |
| 935 | + | |
916 | 936 | | |
917 | 937 | | |
918 | 938 | | |
919 | 939 | | |
| 940 | + | |
920 | 941 | | |
921 | 942 | | |
922 | 943 | | |
923 | 944 | | |
924 | 945 | | |
925 | 946 | | |
926 | 947 | | |
927 | | - | |
| 948 | + | |
928 | 949 | | |
929 | 950 | | |
930 | 951 | | |
931 | 952 | | |
932 | 953 | | |
933 | | - | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
934 | 969 | | |
935 | 970 | | |
936 | 971 | | |
| |||
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
21 | 43 | | |
22 | 44 | | |
23 | 45 | | |
| |||
0 commit comments