29
29
import net .minecraft .world .NextTickListEntry ;
30
30
import net .minecraft .world .WorldServer ;
31
31
32
+ /**
33
+ * <p>Extends the savestate storage to store {@link NextTickListEntry NextTickListEntries} from the {@link WorldServer}.
34
+ * <p>TickListEntries are timed blocks like pressure plates,<br>
35
+ * which schedule their update time, when they are pressed.<br>
36
+ * The timer that is used is the world time.
37
+ * <p>As we can "rewind" the world time with savestates,<br>
38
+ * we also have to update the scheduledTime to account for that
39
+ * @author Scribble
40
+ */
32
41
public class NextTickListEntryStorage extends AbstractExtendStorage {
33
42
34
43
private Path file = Paths .get ("ticklistEntries.json" );
@@ -40,6 +49,7 @@ public void onServerSavestate(MinecraftServer server, int index, Path target, Pa
40
49
41
50
Path path = current .resolve (SavestateHandlerServer .storageDir ).resolve (file );
42
51
52
+ // Ticklistentries can be in every dimension, so this array stores them one by one. Also supports modded dimensions
43
53
JsonArray dimensionJson = new JsonArray ();
44
54
for (WorldServer world : worlds ) {
45
55
WorldServerDuck worldserverDuck = (WorldServerDuck ) world ;
@@ -89,10 +99,12 @@ public void onServerLoadstate(MinecraftServer server, int index, Path target, Pa
89
99
for (JsonElement jsonTickListEntries : dimensionJson ) {
90
100
JsonArray jsonTickListEntriesArray = jsonTickListEntries .getAsJsonArray ();
91
101
WorldServer world = worlds [i ];
102
+
92
103
WorldServerDuck worldserverDuck = (WorldServerDuck ) world ;
93
104
Set <NextTickListEntry > tickListEntries = worldserverDuck .getTickListEntriesHashSet ();
94
105
TreeSet <NextTickListEntry > tickListTreeSet = worldserverDuck .getTickListEntriesTreeSet ();
95
106
107
+ // Clear all existing tickListEntries
96
108
tickListEntries .clear ();
97
109
tickListTreeSet .clear ();
98
110
0 commit comments