Skip to content

Commit 8cac8d8

Browse files
committed
- Bossbar now only visible when the loop is active and showLoopInfo is true
-added first message. but it doesnt work D:
1 parent dca14b8 commit 8cac8d8

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ yarn_mappings=1.21.1+build.3
99
loader_version=0.16.10
1010

1111
# Mod Properties
12-
mod_version=1.6.1
12+
mod_version=1.6.2
1313
maven_group=com.vltno.timeloop
1414
archives_base_name=time-loop
1515

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minecraft.server.MinecraftServer;
1313
import net.minecraft.server.network.ServerPlayerEntity;
1414
import net.minecraft.server.world.ServerWorld;
15+
import net.minecraft.text.Text;
1516
import net.minecraft.util.Identifier;
1617
import net.minecraft.util.WorldSavePath;
1718
import org.slf4j.Logger;
@@ -119,6 +120,17 @@ public void onInitialize() {
119120
executeCommand(String.format("mocap playback start .%s", sceneName));
120121
startLoop();
121122
}
123+
if (config.firstStart) {
124+
config.firstStart = false;
125+
config.save();
126+
127+
// Send message to all ops
128+
for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) {
129+
if (server.getPlayerManager().isOperator(player.getGameProfile())) {
130+
player.sendMessage(Text.literal(("Use '/loop start' to start the Time loop!")));
131+
}
132+
}
133+
}
122134
});
123135

124136
ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
@@ -163,34 +175,27 @@ public void onInitialize() {
163175

164176
ServerTickEvents.END_SERVER_TICK.register(server -> {
165177
if (loopType == LoopTypes.SLEEP || loopType == LoopTypes.DEATH) { return; }
166-
178+
167179
if (isLooping) {
168180
if (loopType == LoopTypes.TIME_OF_DAY) {
169-
LOOP_LOGGER.info("TimeOfDay: {}", serverWorld.getTimeOfDay());
170181
timeOfDay = serverWorld.getTimeOfDay();
171-
182+
172183
long timeLeft = (timeOfDay > timeSetting) ? Math.abs(serverWorld.getTimeOfDay() - (2 * timeSetting)) : Math.abs(timeOfDay - timeSetting);
173-
174-
LOOP_LOGGER.info("Time Left: {}", timeLeft);
175-
176-
LOOP_LOGGER.info("Time setting: {}", timeSetting);
177-
178-
LOOP_LOGGER.info("Time setting - timeleft: {}", timeSetting - timeLeft);
179-
180-
if (showLoopInfo) {
184+
185+
if (showLoopInfo && isLooping) {
181186
loopBossBar.setBossBarName("Time Left: " + timeLeft);
182187
loopBossBar.setBossBarPercentage((int)timeSetting, (int)(timeSetting - timeLeft));
183188
}
184-
189+
185190
if (timeSetting - timeLeft == timeSetting) {
186191
runLoopIteration();
187192
}
188193
}
189-
194+
190195
else if (loopType == LoopTypes.TICKS) {
191196
tickCounter++;
192197
ticksLeft = loopTicks - tickCounter;
193-
if (showLoopInfo) {
198+
if (showLoopInfo && isLooping) {
194199
loopBossBar.setBossBarName("Ticks Left: " + ticksLeft);
195200
loopBossBar.setBossBarPercentage(loopTicks, tickCounter);
196201
}
@@ -215,9 +220,7 @@ public void startLoop() {
215220
LOOP_LOGGER.info("Attempted to start already running recording loop");
216221
return;
217222
}
218-
if (showLoopInfo && (loopType == LoopTypes.TICKS || loopType == LoopTypes.TIME_OF_DAY)) {
219-
loopBossBar.visible(true);
220-
}
223+
if (showLoopInfo) {loopBossBar.visible(true);}
221224
isLooping = true;
222225
config.isLooping = true;
223226
timeOfDay = serverWorld.getTimeOfDay();
@@ -277,10 +280,10 @@ public void saveRecordings() {
277280
*/
278281
public void stopLoop() {
279282
if (isLooping) {
280-
if (showLoopInfo && (loopType == LoopTypes.TICKS || loopType == LoopTypes.TIME_OF_DAY)) { loopBossBar.visible(true); }
281283
LOOP_LOGGER.info("Stopping loop");
282284
isLooping = false;
283285
config.isLooping = false;
286+
loopBossBar.visible(false);
284287
saveRecordings();
285288
executeCommand("mocap playback stop_all including_others");
286289
tickCounter = 0;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
public class TimeLoopConfig {
1313
// These values will be loaded/saved from/to the JSON config file.
1414
public String sceneName = "loop_scene";
15+
public boolean firstStart = true;
1516
public int loopIteration = 1;
1617
public boolean isLooping = false;
1718
public int loopTicks = 6000; // Default: 6000 ticks (i.e. 5 minutes)

0 commit comments

Comments
 (0)