Fix crash on MacOS since v1.6.0

- Closes #67
- Temporarily disabled function popups on MacOS until a solution without non-headless java mode is found
- Also exposed a couple of fields for an upcoming Puzzle update
This commit is contained in:
Martin Prokoph
2024-09-06 12:00:06 +02:00
parent b8a54e339a
commit 765ad60d0b
3 changed files with 10 additions and 6 deletions

View File

@@ -22,9 +22,10 @@ public class MidnightLib {
@Environment(EnvType.CLIENT)
public static void onInitializeClient() {
try { System.setProperty("java.awt.headless", "false");
if (!IS_SYSTEM_MAC) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) { LOGGER.error("Error setting system look and feel", e); }
try { if (!IS_SYSTEM_MAC) {
System.setProperty("java.awt.headless", "false");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}} catch (Exception e) { LOGGER.error("Error setting system look and feel", e); }
MidnightLibConfig.init(MOD_ID, MidnightLibConfig.class);
}
public static void registerAutoCommand() {

View File

@@ -25,6 +25,8 @@ import java.util.*;
import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate;
import java.util.regex.Pattern;
import static net.minecraft.client.MinecraftClient.IS_SYSTEM_MAC;
/** MidnightConfig v2.6.0 by Martin "Motschen" Prokoph
* Single class config library - feel free to copy!
* Based on <a href="https://github.com/Minenash/TinyConfig">...</a>
@@ -372,6 +374,7 @@ public abstract class MidnightConfig {
}
List<ClickableWidget> widgets = Lists.newArrayList(widget, resetButton);
if (info.actionButton != null) {
if (IS_SYSTEM_MAC) info.actionButton.active = false;
widget.setWidth(widget.getWidth() - 22); widget.setX(widget.getX() + 22);
widgets.add(info.actionButton);
} if (cycleButton != null) {
@@ -401,7 +404,7 @@ public abstract class MidnightConfig {
}
@Environment(EnvType.CLIENT)
public static class MidnightConfigListWidget extends ElementListWidget<ButtonEntry> {
boolean renderHeaderSeparator = true;
public boolean renderHeaderSeparator = true;
public MidnightConfigListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) { super(client, width, height, y, itemHeight); }
@Override public int getScrollbarX() { return this.width -7; }
@@ -418,7 +421,7 @@ public abstract class MidnightConfig {
}
public static class ButtonEntry extends ElementListWidget.Entry<ButtonEntry> {
private static final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
private final Text text;
public final Text text;
public final List<ClickableWidget> buttons;
public final EntryInfo info;
public boolean centered = false;

View File

@@ -6,7 +6,7 @@ yarn_mappings=1.21+build.1
enabled_platforms=fabric,neoforge
archives_base_name=midnightlib
mod_version=1.6.2
mod_version=1.6.3
maven_group=eu.midnightdust
release_type=release
curseforge_id=488090