Skip to content

Commit

Permalink
Merge pull request #259 from Exotelis/feature/moon-phase-infoWorldTim…
Browse files Browse the repository at this point in the history
…eFormatted

Feature: Add support to display moon phase in infoWorldTimeFormatted
  • Loading branch information
maruohon authored Aug 12, 2022
2 parents 95b5fcb + 6c7af7d commit bc9300b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/fi/dy/masa/minihud/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static class Generic
public static final ConfigInteger BLOCK_GRID_OVERLAY_RADIUS = new ConfigInteger("blockGridOverlayRadius", 32, 0, 128, "The radius of the block grid lines to render");
public static final ConfigString COORDINATE_FORMAT_STRING = new ConfigString("coordinateFormat", "x: %.1f y: %.1f z: %.1f", "The format string for the coordinate line.\nNeeds to have three %f format strings!\nDefault: x: %.1f y: %.1f z: %.1f");
public static final ConfigString DATE_FORMAT_REAL = new ConfigString("dateFormatReal", "yyyy-MM-dd HH:mm:ss", "The format string for real time, see the Java SimpleDateFormat\nclass for the format patterns, if needed.");
public static final ConfigString DATE_FORMAT_MINECRAFT = new ConfigString("dateFormatMinecraft", "MC time: (day {DAY}) {HOUR}:{MIN}:xx", "The format string for the Minecraft time.\nThe supported placeholders are: {DAY_1}, {DAY}, {HOUR}, {MIN}, {SEC}.\n{DAY_1} starts the day counter from 1, {DAY} starts from 0.");
public static final ConfigString DATE_FORMAT_MINECRAFT = new ConfigString("dateFormatMinecraft", "MC time: (day {DAY}) {HOUR}:{MIN}:xx", "The format string for the Minecraft time.\nThe supported placeholders are: {DAY_1}, {DAY}, {HOUR}, {MIN}, {SEC}, {MOON}.\n{DAY_1} starts the day counter from 1, {DAY} starts from 0.");
public static final ConfigBoolean DEBUG_MESSAGES = new ConfigBoolean("debugMessages", false, "Enables some debug messages in the game console");
public static final ConfigBoolean DEBUG_RENDERER_PATH_MAX_DIST = new ConfigBoolean("debugRendererPathFindingEnablePointWidth", true, "If true, then the vanilla pathfinding debug renderer\nwill render the path point width boxes.");
public static final ConfigBoolean DONT_RESET_SEED_ON_DIMENSION_CHANGE = new ConfigBoolean("dontClearStoredSeedOnDimensionChange", true, "Don't clear the stored world seed when just changing dimensions.\nSome mods may use per-dimension seeds, so you may need to change\nthis in case the different dimensions on your server/mod pack\nhave different world seeds.");
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/fi/dy/masa/minihud/event/RenderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,28 @@ else if (type == InfoToggle.TIME_WORLD_FORMATTED)
int hour = (int) ((dayTicks / 1000) + 6) % 24;
int min = (int) (dayTicks / 16.666666) % 60;
int sec = (int) (dayTicks / 0.277777) % 60;
// Moonphase has 8 different states in MC
String moon = "Invalid";
switch ((int) day % 8)
{
case 0: moon = "Full moon"; break;
case 1: moon = "Waning gibbous"; break;
case 2: moon = "Last quarter"; break;
case 3: moon = "Waning crescent"; break;
case 4: moon = "New moon"; break;
case 5: moon = "Waxing crescent"; break;
case 6: moon = "First quarter"; break;
case 7: moon = "Waxing gibbous"; break;
default:
}

String str = Configs.Generic.DATE_FORMAT_MINECRAFT.getStringValue();
str = str.replace("{DAY}", String.format("%d", day));
str = str.replace("{DAY_1}",String.format("%d", day + 1));
str = str.replace("{HOUR}", String.format("%02d", hour));
str = str.replace("{MIN}", String.format("%02d", min));
str = str.replace("{SEC}", String.format("%02d", sec));
str = str.replace("{MOON}", String.format("%s", moon));

this.addLine(str);
}
Expand Down

0 comments on commit bc9300b

Please sign in to comment.