Skip to content

Commit 4835542

Browse files
committed
Bump version to 1.0.0-beta6, improve config start dialog system
1 parent 6a3ed1e commit 4835542

File tree

11 files changed

+110
-170
lines changed

11 files changed

+110
-170
lines changed

build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ loom {
4141
log4jConfigs.from(file("log4j2.xml"))
4242
launchConfigs {
4343
"client" {
44-
arg("--tweakClass", "com.github.kdgaming0.packcore.tweaker.PackConfigTweaker")
44+
property("mixin.debug", "true")
45+
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
4546
}
4647
}
4748
runConfigs {
@@ -132,10 +133,12 @@ tasks.withType<org.gradle.jvm.tasks.Jar> {
132133
manifest.attributes.run {
133134
this["FMLCorePluginContainsFMLMod"] = "true"
134135
this["ForceLoadAsMod"] = "true"
135-
this["TweakClass"] = "com.github.kdgaming0.packcore.tweaker.PackConfigTweaker"
136-
if (transformerFile.exists()) {
137-
this["FMLAT"] = "${modid}_at.cfg"
138-
}
136+
// If you don't want mixins, remove these lines:
137+
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
138+
this["MixinConfigs"] = "mixins.$modid.json"
139+
if (transformerFile.exists())
140+
this["FMLAT"] = "${modid}_at.cfg"
141+
139142
}
140143
}
141144

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g
33
baseGroup = com.github.kdgaming0.packcore
44
mcVersion = 1.8.9
55
modid = packcore
6-
version = 1.0.0-beta4
6+
version = 1.0.0-beta6

src/main/java/com/github/kdgaming0/packcore/PackCore.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.github.kdgaming0.packcore.screen.SEMainMenu;
55
import com.github.kdgaming0.packcore.utils.ModpackInfo;
66

7+
import net.minecraft.client.Minecraft;
78
import net.minecraft.client.gui.GuiMainMenu;
89
import net.minecraft.client.settings.KeyBinding;
910
import net.minecraftforge.common.MinecraftForge;
@@ -12,6 +13,7 @@
1213
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
1314
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
1415
import net.minecraftforge.client.event.GuiOpenEvent;
16+
1517
import org.apache.logging.log4j.LogManager;
1618
import org.apache.logging.log4j.Logger;
1719
import org.lwjgl.input.Keyboard;
@@ -33,10 +35,19 @@ public void init(FMLInitializationEvent event) {
3335

3436
@SubscribeEvent
3537
public void onGuiOpen(GuiOpenEvent event) {
36-
// Check if the GUI being opened is the main menu
38+
// Check config setting first
39+
if (!ModConfig.getEnableCustomMenu()) {
40+
return;
41+
}
42+
3743
if (event.gui instanceof GuiMainMenu) {
38-
// Replace it with your custom menu
39-
event.gui = new SEMainMenu();
44+
if (!event.isCanceled()) {
45+
event.setCanceled(true);
46+
Minecraft.getMinecraft().displayGuiScreen(new SEMainMenu());
47+
LOGGER.info("PackCore: Loading custom main menu");
48+
} else {
49+
LOGGER.info("PackCore: Another mod has already modified the main menu");
50+
}
4051
}
4152
}
4253
}

src/main/java/com/github/kdgaming0/packcore/config/ModConfig.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
55
import com.google.gson.JsonObject;
6+
import net.minecraft.client.Minecraft;
67
import net.minecraftforge.fml.common.Loader;
78
import org.apache.logging.log4j.LogManager;
89
import org.apache.logging.log4j.Logger;
@@ -17,7 +18,7 @@
1718
public class ModConfig {
1819
private static final Logger LOGGER = LogManager.getLogger(MOD_ID);
1920
private static final String CONFIG_FILENAME = "PackCore.json";
20-
private static final File CONFIG_FILE = new File(Loader.instance().getConfigDir(), CONFIG_FILENAME);
21+
private static final File CONFIG_FILE = new File(new File(Minecraft.getMinecraft().mcDataDir, "config"), CONFIG_FILENAME);
2122
private static JsonObject configData;
2223
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
2324

@@ -28,19 +29,42 @@ public static void loadConfig() {
2829

2930
try (FileReader reader = new FileReader(CONFIG_FILE)) {
3031
configData = gson.fromJson(reader, JsonObject.class);
32+
updateConfigWithDefaults();
3133
} catch (IOException e) {
3234
LOGGER.error("Failed to load config file: " + CONFIG_FILE.getAbsolutePath(), e);
3335
// Create default config if reading fails
3436
createDefaultConfig();
3537
}
3638
}
3739

40+
private static void updateConfigWithDefaults() {
41+
boolean updated = false;
42+
43+
if (!configData.has("PromptSetDefaultConfig")) {
44+
configData.addProperty("PromptSetDefaultConfig", true);
45+
updated = true;
46+
}
47+
if (!configData.has("ShowOptifineGuide")) {
48+
configData.addProperty("ShowOptifineGuide", true);
49+
updated = true;
50+
}
51+
if (!configData.has("EnableCustomMenu")) {
52+
configData.addProperty("EnableCustomMenu", true);
53+
updated = true;
54+
}
55+
56+
if (updated) {
57+
saveConfig();
58+
}
59+
}
60+
3861
private static void createDefaultConfig() {
3962
JsonObject defaultConfig = new JsonObject();
4063

4164
// Add your config values here
4265
defaultConfig.addProperty("PromptSetDefaultConfig", true);
4366
defaultConfig.addProperty("ShowOptifineGuide", true);
67+
defaultConfig.addProperty("EnableCustomMenu", true);
4468

4569
configData = defaultConfig; // Set the default config as current
4670
saveConfig(); // Save to file
@@ -57,6 +81,11 @@ public static boolean getShowOptifineGuide() {
5781
return configData.get("ShowOptifineGuide").getAsBoolean();
5882
}
5983

84+
public static boolean getEnableCustomMenu() {
85+
if (configData == null) loadConfig();
86+
return configData.get("EnableCustomMenu").getAsBoolean();
87+
}
88+
6089
// Setter methods
6190
public static void setPromptSetDefaultConfig(boolean value) {
6291
if (configData == null) loadConfig();
@@ -70,6 +99,12 @@ public static void setShowOptifineGuide(boolean value) {
7099
saveConfig();
71100
}
72101

102+
public static void setEnableCustomMenu(boolean value) {
103+
if (configData == null) loadConfig();
104+
configData.addProperty("EnableCustomMenu", value);
105+
saveConfig();
106+
}
107+
73108
// Save config to file
74109
public static void saveConfig() {
75110
try (FileWriter writer = new FileWriter(CONFIG_FILE)) {

src/main/java/com/github/kdgaming0/packcore/copysystem/ZipSelectionDialog.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.kdgaming0.packcore.copysystem;
22

3+
import com.github.kdgaming0.packcore.config.ModConfig;
34
import com.github.kdgaming0.packcore.copysystem.utils.ExtractionProgressListener;
45

56
import javax.swing.JButton;
@@ -154,6 +155,7 @@ public void actionPerformed(ActionEvent e) {
154155
@Override
155156
public void actionPerformed(ActionEvent e) {
156157
userFinished = true;
158+
ModConfig.setPromptSetDefaultConfig(false); // Disable prompt for next time
157159
dispose();
158160
System.exit(0); // Exits the game
159161
}
@@ -274,7 +276,7 @@ protected void done() {
274276
} else {
275277
JOptionPane.showMessageDialog(
276278
ZipSelectionDialog.this,
277-
"Extraction of \"" + finalSelectedZip + "\" encountered an error.",
279+
"Extraction of \"" + finalSelectedZip + "\" encountered an error. Report this to the mod author.",
278280
"Error",
279281
JOptionPane.ERROR_MESSAGE
280282
);
@@ -285,6 +287,7 @@ protected void done() {
285287
progressBar.setValue(0);
286288

287289
userFinished = true;
290+
ModConfig.setPromptSetDefaultConfig(false); // Disable prompt for next time
288291
dispose(); // Close dialog to continue Minecraft startup
289292
}
290293
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.kdgaming0.packcore.mixin;
2+
3+
import com.github.kdgaming0.packcore.config.ModConfig;
4+
import com.github.kdgaming0.packcore.copysystem.ZipSelectionDialog;
5+
import net.minecraft.client.Minecraft;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Unique;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
import java.io.File;
13+
14+
@Mixin(Minecraft.class)
15+
public class PackCoreShowConfigMixin {
16+
17+
@Inject(method = "startGame", at = @At("HEAD"))
18+
private void onGameStart(CallbackInfo ci) {
19+
// Get Minecraft instance and game directory
20+
Minecraft mc = (Minecraft)(Object)this;
21+
File gameDir = mc.mcDataDir;
22+
23+
// Load and check config
24+
if (packCore$shouldShowDialog()) {
25+
// Show the ZIP selection dialog
26+
ZipSelectionDialog.showDialog(gameDir);
27+
}
28+
}
29+
30+
@Unique
31+
private boolean packCore$shouldShowDialog() {
32+
return ModConfig.getPromptSetDefaultConfig();
33+
}
34+
}

src/main/java/com/github/kdgaming0/packcore/screen/ConfigGui.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ class ConfigGui : WindowScreen(ElementaVersion.V7) {
171171
ModConfig.setShowOptifineGuide(newValue)
172172
}
173173

174+
createToggleSetting(
175+
innerContainer,
176+
"Enable Custom Main Menu",
177+
"Use a custom main menu with a skyblock-themed background. This provides a fuller Skyblock Enhanced experience. Recommended",
178+
ModConfig.getEnableCustomMenu()
179+
) { newValue ->
180+
ModConfig.setEnableCustomMenu(newValue)
181+
}
182+
174183
// Save & Close button
175184
UIRoundedRectangle(4f).constrain {
176185
x = CenterConstraint()

src/main/java/com/github/kdgaming0/packcore/screen/SEMainMenu.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SEMainMenu : WindowScreen(ElementaVersion.V7) {
7676

7777
val buttonContainer2 = UIContainer().constrain {
7878
x = CenterConstraint()
79-
y = 65.pixels()
79+
y = 70.pixels()
8080
width = ChildBasedMaxSizeConstraint()
8181
height = 100.percent()
8282
} childOf buttonBackgroundEffect

0 commit comments

Comments
 (0)