Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/main/java/co/skyclient/scc/gui/CustomSplashProgress.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ private static boolean getBool(String name, boolean def) {
return Boolean.parseBoolean(getString(name, Boolean.toString(def)));
}

private static String fetchOneLine(String source) {
String stringList = WebUtil.fetchString(source);
if (stringList != null) {
String[] lines = stringList.split("\n");
int index = (int) (Math.random() * lines.length);
return lines[index];
}
return null;
}

public static void start() {
File configFile = new File(Minecraft.getMinecraft().mcDataDir, "config/splash.properties");

Expand Down Expand Up @@ -186,11 +196,10 @@ public void printStackTrace(final PrintStream s) {

Multithreading.runAsync(() -> {
try {
String text = WebUtil.fetchString("https://cdn.jsdelivr.net/gh/KTibow/Skyclient@main/docs/assets/funfacts.txt");
if (text != null) {
String[] lines = text.split("\n");
int index = (int) (Math.random() * lines.length);
funFact = lines[index];
if (Math.random() > 0.4) {
funFact = fetchOneLine("https://cdn.jsdelivr.net/gh/KTibow/Skyclient@main/docs/assets/funfacts.txt");
} else {
funFact = fetchOneLine("https://cdn.jsdelivr.net/gh/KTibow/Skyclient@main/docs/assets/unfunfacts.txt");
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -267,9 +276,11 @@ public void run() {
glScalef(2, 2, 1);
glEnable(GL_TEXTURE_2D);
int offset = 0;
for (String segment : funFact.split("\\\\n")) {
fontRenderer.drawString(segment, 160 - (fontRenderer.getStringWidth(segment) / 2), 180 - textHeight2 + offset, 0x000000);
offset += 10;
if (funFact != null && !funFact.isEmpty()) {
for (String segment : funFact.split("\\\\n")) {
fontRenderer.drawString(segment, 160 - (fontRenderer.getStringWidth(segment) / 2), 180 - textHeight2 + offset, 0x000000);
offset += 10;
}
}
glDisable(GL_TEXTURE_2D);
glPopMatrix();
Expand All @@ -291,7 +302,7 @@ public void run() {
} else {
if (first != null) {
glPushMatrix();
glTranslatef(320 - (float) barWidth / 2, 310, 0);
glTranslatef(320 - (float) barWidth / 2, 320, 0);
drawBar(first);
int barOffset = 55;
if (penult != null) {
Expand Down