-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed InfoHud in place of separate HUD elements.
- Loading branch information
1 parent
cec27b1
commit f220be2
Showing
5 changed files
with
105 additions
and
91 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package net.aoba.gui.navigation.huds; | ||
|
||
import net.aoba.gui.GuiManager; | ||
import net.aoba.gui.Rectangle; | ||
import net.aoba.gui.navigation.HudWindow; | ||
import net.aoba.utils.render.Render2D; | ||
import net.minecraft.client.gui.DrawContext; | ||
|
||
public class DayHud extends HudWindow { | ||
private String timeText = null; | ||
|
||
public DayHud(int x, int y) { | ||
super("DayHud", x, y, 0, 20); | ||
inheritHeightFromChildren = false; | ||
|
||
this.minHeight = 20f; | ||
this.maxHeight = 20f; | ||
|
||
resizeable = false; | ||
} | ||
|
||
@Override | ||
public void update() { | ||
super.update(); | ||
timeText = "Day: " + (int) (MC.world.getTime() / 24000); | ||
int textWidth = MC.textRenderer.getWidth(timeText); | ||
setWidth(textWidth * 2); | ||
} | ||
|
||
@Override | ||
public void draw(DrawContext drawContext, float partialTicks) { | ||
if (timeText != null && getVisible()) { | ||
Rectangle pos = position.getValue(); | ||
if (pos.isDrawable()) { | ||
Render2D.drawString(drawContext, timeText, pos.getX(), pos.getY(), GuiManager.foregroundColor.getValue().getColorAsInt()); | ||
} | ||
} | ||
|
||
super.draw(drawContext, partialTicks); | ||
} | ||
} |
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
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,59 @@ | ||
package net.aoba.gui.navigation.huds; | ||
|
||
import net.aoba.gui.GuiManager; | ||
import net.aoba.gui.Rectangle; | ||
import net.aoba.gui.navigation.HudWindow; | ||
import net.aoba.utils.render.Render2D; | ||
import net.minecraft.client.gui.DrawContext; | ||
|
||
public class TimeHud extends HudWindow { | ||
private String timeText = null; | ||
|
||
public TimeHud(int x, int y) { | ||
super("TimeHud", x, y, 0, 20); | ||
inheritHeightFromChildren = false; | ||
|
||
this.minHeight = 20f; | ||
this.maxHeight = 20f; | ||
|
||
resizeable = false; | ||
} | ||
|
||
@Override | ||
public void update() { | ||
super.update(); | ||
int time = ((int) MC.world.getTime() + 6000) % 24000; | ||
String suffix = time >= 12000 ? "PM" : "AM"; | ||
StringBuilder timeString = new StringBuilder((time / 10) % 1200 + ""); | ||
for (int n = timeString.length(); n < 4; ++n) { | ||
timeString.insert(0, "0"); | ||
} | ||
final String[] strsplit = timeString.toString().split(""); | ||
String hours = strsplit[0] + strsplit[1]; | ||
if (hours.equalsIgnoreCase("00")) { | ||
hours = "12"; | ||
} | ||
final int minutes = (int) Math.floor(Double.parseDouble(strsplit[2] + strsplit[3]) / 100.0 * 60.0); | ||
String sm = minutes + ""; | ||
if (minutes < 10) { | ||
sm = "0" + minutes; | ||
} | ||
timeString = new StringBuilder(hours + ":" + sm.charAt(0) + sm.charAt(1) + suffix); | ||
|
||
timeText = timeString.toString(); | ||
int textWidth = MC.textRenderer.getWidth(timeText); | ||
setWidth(textWidth * 2); | ||
} | ||
|
||
@Override | ||
public void draw(DrawContext drawContext, float partialTicks) { | ||
if (timeText != null && getVisible()) { | ||
Rectangle pos = position.getValue(); | ||
if (pos.isDrawable()) { | ||
Render2D.drawString(drawContext, timeText, pos.getX(), pos.getY(), GuiManager.foregroundColor.getValue().getColorAsInt()); | ||
} | ||
} | ||
|
||
super.draw(drawContext, partialTicks); | ||
} | ||
} |