generated from JamCoreModding/multi-loader-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
still missing metadata stuff like credits, icon, and description, but it's working
- Loading branch information
1 parent
187f6f1
commit 36929a7
Showing
38 changed files
with
225 additions
and
371 deletions.
There are no files selected for viewing
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ build | |
eclipse | ||
run | ||
.architectury-transformer | ||
|
||
backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
common/src/main/java/io/github/jamalam360/wake_up_time/WakeUpTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.github.jamalam360.wake_up_time; | ||
|
||
import dev.architectury.event.events.client.ClientTickEvent; | ||
import dev.architectury.platform.Platform; | ||
import dev.architectury.registry.client.keymappings.KeyMappingRegistry; | ||
import io.github.jamalam360.jamlib.JamLib; | ||
import io.github.jamalam360.jamlib.JamLibPlatform; | ||
import io.github.jamalam360.jamlib.config.ConfigManager; | ||
import net.minecraft.client.KeyMapping; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.network.chat.Component; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_V; | ||
|
||
//TODO: make this only execute on client | ||
public class WakeUpTime { | ||
public static final String MOD_ID = "wake_up_time"; | ||
public static final String MOD_NAME = "Wake Up Time"; | ||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); | ||
public static final ConfigManager<Config> CONFIG = new ConfigManager<>(MOD_ID, Config.class); | ||
private static final KeyMapping sendStatusToActionBar = new KeyMapping("key.wake_up_time.status", GLFW_KEY_V, "category.wake_up_time"); | ||
private static boolean enabled = false; | ||
|
||
public static void init() { | ||
LOGGER.info("Initializing Wake Up Time on " + JamLibPlatform.getPlatform().name()); | ||
|
||
if (JamLibPlatform.getPlatform() == JamLibPlatform.Platform.FABRIC || JamLibPlatform.getPlatform() == JamLibPlatform.Platform.QUILT) { | ||
Path configFolder = Platform.getConfigFolder(); | ||
Path oldConfig = configFolder.resolve("wake_up_time.json"); | ||
Path newConfig = configFolder.resolve("wake_up_time.json5"); | ||
|
||
if (oldConfig.toFile().exists()) { | ||
LOGGER.info("Found an legacy config file, recovering it"); | ||
|
||
if (newConfig.toFile().exists()) { | ||
LOGGER.warn("Found a new config file, not recovering the legacy config"); | ||
} else { | ||
if (oldConfig.toFile().renameTo(newConfig.toFile())) { | ||
LOGGER.info("Recovered the legacy config file"); | ||
} else { | ||
LOGGER.error("Failed to recover the legacy config file"); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
JamLib.checkForJarRenaming(WakeUpTime.class); | ||
KeyMappingRegistry.register(sendStatusToActionBar); | ||
ClientTickEvent.CLIENT_LEVEL_POST.register((level) -> { | ||
if (sendStatusToActionBar.consumeClick()) { | ||
enabled = !enabled; | ||
sendStatusToActionBar(level); | ||
} | ||
|
||
if (CONFIG.get().persistent && enabled) { | ||
sendStatusToActionBar(level); | ||
} | ||
}); | ||
} | ||
|
||
private static void sendStatusToActionBar(ClientLevel level) { | ||
if (Minecraft.getInstance().player != null) { | ||
Minecraft.getInstance().player.displayClientMessage(Component.translatable("text.wake_up_time.status", getStageComponent(level)), true); | ||
} | ||
} | ||
|
||
private static Component getStageComponent(ClientLevel level) { | ||
long time = level.getDayTime(); | ||
while (time > 24000) time = time - 24000; | ||
|
||
if (time < 9000 && time >= 2000) { | ||
return Component.translatable("text.wake_up_time.working", "§a" + (9000 - time) / 20); | ||
} | ||
|
||
Component status = Component.translatable("text.wake_up_time.wandering"); | ||
if (time >= 12000 || time < 10) status = Component.translatable("text.wake_up_time.sleeping"); | ||
if (time >= 9000 && time < 11000) status = Component.translatable("text.wake_up_time.gathering"); | ||
|
||
final long timeUntilWork = time > 9000 ? 26000 - time : 2000 - time; | ||
|
||
return Component.translatable("text.wake_up_time.lazy_bums", "§a" + status.getString(), "§a" + timeUntilWork / 20); | ||
} | ||
|
||
public static class Config { | ||
public boolean persistent = false; | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
...src/main/java/{{#replace "\." "%%"}}{{group}}.{{mod_id}}{{%%replace}}/{{main_class}}.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
.../java/{{#replace "\." "%%"}}{{group}}.{{mod_id}}{{%%replace}}/{{main_class}}Platform.java
This file was deleted.
Oops, something went wrong.
File renamed without changes
13 changes: 13 additions & 0 deletions
13
common/src/main/resources/assets/wake_up_time/lang/en_us.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"config.wake_up_time.title": "Wake Up Time Config", | ||
"config.wake_up_time.persistent": "Persistent notification", | ||
"config.wake_up_time.persistent.tooltip": "If enabled, pressing the keybind will toggle the message on and off. If disabled, the message will only be displayed for a short time.", | ||
"category.wake_up_time.": "Wake Up Time", | ||
"key.wake_up_time.send_status": "Send villager clock status", | ||
"text.wake_up_time.status": "§bEmployed villagers are currently %s", | ||
"text.wake_up_time.lazy_bums": "%s§b; %s§a seconds§b until working time", | ||
"text.wake_up_time.working": "§aworking§b; %s§a seconds§b until workday ends", | ||
"text.wake_up_time.sleeping": "§asleeping", | ||
"text.wake_up_time.gathering": "§agathering", | ||
"text.wake_up_time.wandering": "§awandering" | ||
} |
13 changes: 13 additions & 0 deletions
13
common/src/main/resources/assets/wake_up_time/lang/ru_ru.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"config.wake_up_time.title": "Wake Up Time Config", | ||
"config.wake_up_time.persistent": "Persistent notification", | ||
"config.wake_up_time.persistent.tooltip": "If enabled, pressing the keybind will toggle the message on and off. If disabled, the message will only be displayed for a short time.", | ||
"category.wake_up_time.": "Wake Up Time", | ||
"key.wake_up_time.send_status": "Показать статус жителей", | ||
"text.wake_up_time.status": "§bСтатус жителей - %s", | ||
"text.wake_up_time.lazy_bums": "%s§b; %s§a секунды§b до рабочего времени", | ||
"text.wake_up_time.working": "§aработа§b; %s§a секунды§b до окончания рабочего дня", | ||
"text.wake_up_time.sleeping": "§aсон", | ||
"text.wake_up_time.gathering": "§aсбор", | ||
"text.wake_up_time.wandering": "§aсвободное время" | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.