Skip to content

Commit

Permalink
refactor: Refactor thunderstorm translation into sleepMessage
Browse files Browse the repository at this point in the history
Also improved the readability of the way the translation is built.
  • Loading branch information
Steveplays28 committed Oct 1, 2023
1 parent 54b29e3 commit 822c62a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) {

nightTimeStepPerTick = SleepMath.calculateNightTimeStepPerTick(sleepingRatio, config.sleepSpeedMultiplier, nightTimeStepPerTick);
nightTimeStepPerTickRounded = (int) Math.round(nightTimeStepPerTick);
var nightOrDayText = worldProperties.getTimeOfDay() > DAY_LENGTH / 2 ? Text.translatable(
String.format("%s.text.night", MOD_ID)) : Text.translatable(String.format("%s.text.day", MOD_ID));
var isNight = worldProperties.getTimeOfDay() > DAY_LENGTH / 2;
var nightDayOrThunderstormText = Text.translatable(
String.format("%s.text.%s", MOD_ID, worldProperties.isThundering() ? "thunderstorm" : isNight ? "night" : "day"));

int blockEntityTickSpeedMultiplier = (int) Math.round(config.blockEntityTickSpeedMultiplier);
int chunkTickSpeedMultiplier = (int) Math.round(config.chunkTickSpeedMultiplier);
Expand All @@ -119,7 +120,7 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) {
for (ServerPlayerEntity player : players) {
player.sendMessage(
Text.translatable(String.format("%s.text.not_enough_players_sleeping_message", MOD_ID), sleepingPlayerCount,
playerCount, playersRequiredToSleep, playerCount, nightOrDayText
playerCount, playersRequiredToSleep, playerCount, nightDayOrThunderstormText
), true);
}

Expand Down Expand Up @@ -156,7 +157,7 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) {

if (config.sendSleepingMessage) {
sleepMessage = Text.translatable(String.format("%s.text.sleep_message", MOD_ID), sleepingPlayerCount, playerCount).append(
worldProperties.isThundering() ? Text.translatable(String.format("%s.text.thunderstorm", MOD_ID)) : nightOrDayText);
nightDayOrThunderstormText);

if (config.showTimeUntilDawn) {
sleepMessage.append(Text.translatable(String.format("%s.text.time_until_dawn", MOD_ID), secondsUntilAwake));
Expand Down

0 comments on commit 822c62a

Please sign in to comment.