Skip to content

Commit 8fbe5d5

Browse files
committed
Renamed some Variables to improve readability
1 parent 5531acc commit 8fbe5d5

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/main/java/com/vltno/timeloop/Commands.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
8383
.then(CommandManager.literal("setTicks")
8484
.requires(source -> source.hasPermissionLevel(2))
8585
.executes(context -> {
86-
context.getSource().sendMessage(Text.literal("Loop ticks is set to: " + mod.loopTicks + " ticks"));
86+
context.getSource().sendMessage(Text.literal("Loop ticks is set to: " + mod.loopLengthTicks + " ticks"));
8787
return 1;
8888
})
8989
.then(CommandManager.argument("ticks", IntegerArgumentType.integer(20))
9090
.executes(context -> {
9191
int newTicks = IntegerArgumentType.getInteger(context, "ticks");
92-
mod.loopTicks = newTicks;
93-
mod.config.loopTicks = newTicks;
92+
mod.loopLengthTicks = newTicks;
93+
mod.config.loopLengthTicks = newTicks;
9494

9595
mod.ticksLeft = newTicks;
9696
mod.config.ticksLeft = newTicks;
@@ -202,14 +202,14 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
202202
.executes(context -> {
203203
mod.stopLoop();
204204

205-
mod.timeOfDay = 0;
206-
mod.config.timeOfDay = 0;
205+
mod.startTimeOfDay = 0;
206+
mod.config.startTimeOfDay = 0;
207207

208208
mod.timeSetting = 0;
209209
mod.config.timeSetting = 0;
210210

211-
mod.ticksLeft = mod.loopTicks;
212-
mod.config.ticksLeft = mod.config.loopTicks;
211+
mod.ticksLeft = mod.loopLengthTicks;
212+
mod.config.ticksLeft = mod.config.loopLengthTicks;
213213

214214
mod.trackItems = false;
215215
mod.config.trackItems = false;

src/main/java/com/vltno/timeloop/TimeLoop.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public class TimeLoop implements ModInitializer {
3131

3232
// These fields will be initialized from the configuration file.
3333
public int loopIteration;
34-
public int loopTicks;
35-
public long timeOfDay; // Tracks the time of day
34+
public int loopLengthTicks;
35+
public long startTimeOfDay; // The Time the Loop was started
3636
public long timeSetting;
3737
public boolean trackTimeOfDay;
3838
public boolean isLooping;
@@ -84,9 +84,9 @@ public void onInitialize() {
8484
config = TimeLoopConfig.load(worldFolder);
8585

8686
loopIteration = config.loopIteration;
87-
loopTicks = config.loopTicks;
87+
loopLengthTicks = config.loopLengthTicks;
8888
isLooping = config.isLooping;
89-
timeOfDay = config.timeOfDay;
89+
startTimeOfDay = config.startTimeOfDay;
9090
timeSetting = config.timeSetting;
9191
trackTimeOfDay = config.trackTimeOfDay;
9292
ticksLeft = config.ticksLeft;
@@ -100,7 +100,7 @@ public void onInitialize() {
100100
this.serverWorld = server.getOverworld();
101101

102102
// Loop boss bar info
103-
String loopInfo = (loopType == LoopTypes.TICKS ? "Ticks Left: " + loopTicks : loopType == LoopTypes.TIME_OF_DAY ? "Time left: " + (timeOfDay - timeSetting) : "");
103+
String loopInfo = (loopType == LoopTypes.TICKS ? "Ticks Left: " + loopLengthTicks : loopType == LoopTypes.TIME_OF_DAY ? "Time left: " + (startTimeOfDay - timeSetting) : "");
104104
loopBossBar.visible(false);
105105
loopBossBar.setBossBarName(loopInfo);
106106

@@ -126,6 +126,7 @@ public void onInitialize() {
126126

127127
// Send message to all ops
128128
for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) {
129+
LOOP_LOGGER.info("GRRRRRRRRRRRRRRRRRRRRRRRRRRR");
129130
if (server.getPlayerManager().isOperator(player.getGameProfile())) {
130131
player.sendMessage(Text.literal(("Use '/loop start' to start the Time loop!")));
131132
}
@@ -178,9 +179,8 @@ public void onInitialize() {
178179

179180
if (isLooping) {
180181
if (loopType == LoopTypes.TIME_OF_DAY) {
181-
timeOfDay = serverWorld.getTimeOfDay();
182-
183-
long timeLeft = (timeOfDay > timeSetting) ? Math.abs(serverWorld.getTimeOfDay() - (2 * timeSetting)) : Math.abs(timeOfDay - timeSetting);
182+
long time = serverWorld.getTimeOfDay();
183+
long timeLeft = (time > timeSetting) ? Math.abs(serverWorld.getTimeOfDay() - (2 * timeSetting)) : Math.abs(startTimeOfDay - timeSetting);
184184

185185
if (showLoopInfo && isLooping) {
186186
loopBossBar.setBossBarName("Time Left: " + timeLeft);
@@ -194,15 +194,15 @@ public void onInitialize() {
194194

195195
else if (loopType == LoopTypes.TICKS) {
196196
tickCounter++;
197-
ticksLeft = loopTicks - tickCounter;
197+
ticksLeft = loopLengthTicks - tickCounter;
198198
if (showLoopInfo && isLooping) {
199199
loopBossBar.setBossBarName("Ticks Left: " + ticksLeft);
200-
loopBossBar.setBossBarPercentage(loopTicks, tickCounter);
200+
loopBossBar.setBossBarPercentage(loopLengthTicks, tickCounter);
201201
}
202202

203-
if (tickCounter >= loopTicks) {
203+
if (tickCounter >= loopLengthTicks) {
204204
tickCounter = 0; // Reset counter
205-
ticksLeft = loopTicks; // Reset
205+
ticksLeft = loopLengthTicks; // Reset
206206
runLoopIteration();
207207
}
208208
}
@@ -223,10 +223,10 @@ public void startLoop() {
223223
if (showLoopInfo) {loopBossBar.visible(true);}
224224
isLooping = true;
225225
config.isLooping = true;
226-
timeOfDay = serverWorld.getTimeOfDay();
227-
config.timeOfDay = timeOfDay;
226+
startTimeOfDay = serverWorld.getTimeOfDay();
227+
config.startTimeOfDay = startTimeOfDay;
228228
tickCounter = 0;
229-
ticksLeft = loopTicks;
229+
ticksLeft = loopLengthTicks;
230230
LOOP_LOGGER.info("Starting Loop");
231231
startRecordings();
232232
}
@@ -235,11 +235,11 @@ public void startLoop() {
235235
* Runs the next iteration of the loop.
236236
*/
237237
private void runLoopIteration() {
238-
LOOP_LOGGER.info("Starting iteration {} of recording loop", loopIteration);
238+
LOOP_LOGGER.info("Starting iteration {} of loop", loopIteration);
239239
saveRecordings();
240240
removeOldSceneEntries();
241241
startRecordings();
242-
if (trackTimeOfDay) { serverWorld.setTimeOfDay(timeOfDay); }
242+
if (trackTimeOfDay) { serverWorld.setTimeOfDay(startTimeOfDay); }
243243
executeCommand("mocap playback stop_all including_others");
244244
executeCommand(String.format("mocap playback start .%s", sceneName));
245245
loopIteration++;
@@ -287,7 +287,7 @@ public void stopLoop() {
287287
saveRecordings();
288288
executeCommand("mocap playback stop_all including_others");
289289
tickCounter = 0;
290-
ticksLeft = loopTicks;
290+
ticksLeft = loopLengthTicks;
291291
LOOP_LOGGER.info("Loop stopped!");
292292
}
293293
}

src/main/java/com/vltno/timeloop/TimeLoopConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public class TimeLoopConfig {
1515
public boolean firstStart = true;
1616
public int loopIteration = 1;
1717
public boolean isLooping = false;
18-
public int loopTicks = 6000; // Default: 6000 ticks (i.e. 5 minutes)
18+
public int loopLengthTicks = 6000; // Default: 6000 ticks (i.e. 5 minutes)
1919
public int maxLoops = 0; //No limit by default
2020
public long timeSetting = 13000;
21-
public long timeOfDay = 0;
21+
public long startTimeOfDay = 0;
2222
public boolean trackTimeOfDay = true;
2323
public int ticksLeft;
2424

0 commit comments

Comments
 (0)