Skip to content

Commit af7e72d

Browse files
committed
Update version to 1.0.0-beta2 and enhance main menu with new buttons and Optifine guide
1 parent 691b369 commit af7e72d

File tree

8 files changed

+545
-313
lines changed

8 files changed

+545
-313
lines changed

build.gradle.kts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ val mcVersion: String by project
2020
val version: String by project
2121
val modid: String by project
2222

23+
// You can adjust these to the proper versions you want to use.
24+
val elementaVersion = "2.0.0" // Replace with latest Elementa version if desired
25+
val ucVersion = "1.0.3" // Replace with latest UniversalCraft version if desired
26+
27+
val mixinGroup = "$baseGroup.mixin"
28+
val transformerFile = file("src/main/resources/accesstransformer.cfg")
29+
2330
// -------------------------------------------------------------------------------------------------
2431
// Toolchains
2532
// -------------------------------------------------------------------------------------------------
@@ -34,6 +41,8 @@ loom {
3441
log4jConfigs.from(file("log4j2.xml"))
3542
launchConfigs {
3643
"client" {
44+
property("mixin.debug", "true")
45+
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
3746
arg("--tweakClass", "com.github.kdgaming0.packcore.tweaker.PackConfigTweaker")
3847
}
3948
}
@@ -48,6 +57,14 @@ loom {
4857
}
4958
forge {
5059
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
60+
mixinConfig("mixins.$modid.json")
61+
if (transformerFile.exists()) {
62+
println("Installing access transformer")
63+
accessTransformer(transformerFile)
64+
}
65+
}
66+
mixin {
67+
defaultRefmapName.set("mixins.$modid.refmap.json")
5168
}
5269
}
5370

@@ -65,7 +82,7 @@ repositories {
6582
// DevAuth repository (if you need it for debugging/logging in with alt)
6683
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
6784
// Essential's public Maven for Elementa
68-
maven(url = "https://repo.essential.gg/repository/maven-public")
85+
maven("https://repo.essential.gg/repository/maven-public")
6986
}
7087

7188
// -------------------------------------------------------------------------------------------------
@@ -84,6 +101,12 @@ dependencies {
84101
mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
85102
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
86103

104+
// Sponge Mixin library (if you're using mixins)
105+
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
106+
isTransitive = false
107+
}
108+
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
109+
87110
// Add DevAuth for debugging if desired
88111
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
89112

@@ -112,6 +135,12 @@ tasks.withType<org.gradle.jvm.tasks.Jar> {
112135
this["FMLCorePluginContainsFMLMod"] = "true"
113136
this["ForceLoadAsMod"] = "true"
114137
this["TweakClass"] = "com.github.kdgaming0.packcore.tweaker.PackConfigTweaker"
138+
// If you don't want mixins, remove these lines:
139+
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
140+
this["MixinConfigs"] = "mixins.$modid.json"
141+
if (transformerFile.exists()) {
142+
this["FMLAT"] = "${modid}_at.cfg"
143+
}
115144
}
116145
}
117146

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-beta1
6+
version = 1.0.0-beta2

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ private void initializeUI() {
7979
+ "<h2>Welcome to Skyblock Enhanced!</h2>"
8080
+ "Before playing, please select the ready-to-use zip file that best matches your needs for the best experience:<br><br>"
8181
+ "<b><i>Normal (1080p / 1440p):</i></b> Recommended for most players. This option has more features enabled by default, offering a rich and complex experience. However, new players may find it overwhelming at first due to the amount of on-screen information when joining Skyblock for the first time with mods.<br>"
82-
+ "<b><i>Lite (1080p / 1440p):</i></b> Designed for complete beginners, with fewer features enabled to simplify the experience. This is a great starting point to get familiar with the mod features. As you gain experience, you can enable additional features to create your perfect setup.<br><br>"
83-
+ "Custom configurations you’ve added will also appear here. (You can create them in-game via <i>/packcore</i> or the <i>packcore</i> button in the ESC menu.)<br><br>"
82+
+ "<b><i>Lite (3-5 Business Days) (1080p / 1440p):</i></b> Designed for complete beginners, with fewer features enabled to simplify the experience. This is a great starting point to get familiar with the mod features. As you gain experience, you can enable additional features to create your perfect setup.<br><br>"
83+
+ "Custom configurations you’ve added will also appear here. (You can create them in-game via <i>/packcore</i> or the <i>Config Management</i> button on the main menu.)<br><br>"
8484
+ "If you skip this step, mods will use their default settings, as if downloaded individually and clicked play. This will cause many features to be disabled and have overlapping GUI elements. (I can't promise there won't be any overlapping with the ready-to-use configs but there will be less.)<br><br>"
85+
+ "<b>If you are updating from a <i>pre-2.0</i> version of <b>Skyblock Enhanced</b> and don't want to reset the configs, click <b><i>Skip</i></b>.</b><br><br>"
8586
+ "Click <b><i>Extract</i></b> to apply your chosen configuration or <b><i>Skip</i></b> to launch Minecraft with default mod settings."
8687
+ "</body></html>"
8788
);
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
package com.github.kdgaming0.packcore.init;
2+
3+
import org.spongepowered.asm.lib.tree.ClassNode;
4+
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
5+
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
6+
7+
import java.io.IOException;
8+
import java.net.MalformedURLException;
9+
import java.net.URISyntaxException;
10+
import java.net.URL;
11+
import java.nio.file.Files;
12+
import java.nio.file.Path;
13+
import java.nio.file.Paths;
14+
import java.util.ArrayList;
15+
import java.util.List;
16+
import java.util.Set;
17+
import java.util.stream.Stream;
18+
import java.util.zip.ZipEntry;
19+
import java.util.zip.ZipInputStream;
20+
21+
/**
22+
* A mixin plugin to automatically discover all mixins in the current JAR.
23+
* <p>
24+
* This mixin plugin automatically scans your entire JAR (or class directory, in case of an in-IDE launch) for classes inside of your
25+
* mixin package and registers those. It does this recursively for sub packages of the mixin package as well. This means you will need
26+
* to only have mixin classes inside of your mixin package, which is good style anyway.
27+
*
28+
* @author Linnea Gräf
29+
*/
30+
public class AutoDiscoveryMixinPlugin implements IMixinConfigPlugin {
31+
private static final List<AutoDiscoveryMixinPlugin> mixinPlugins = new ArrayList<>();
32+
33+
public static List<AutoDiscoveryMixinPlugin> getMixinPlugins() {
34+
return mixinPlugins;
35+
}
36+
37+
private String mixinPackage;
38+
39+
@Override
40+
public void onLoad(String mixinPackage) {
41+
this.mixinPackage = mixinPackage;
42+
mixinPlugins.add(this);
43+
}
44+
45+
/**
46+
* Resolves the base class root for a given class URL. This resolves either the JAR root, or the class file root.
47+
* In either case the return value of this + the class name will resolve back to the original class url, or to other
48+
* class urls for other classes.
49+
*/
50+
public URL getBaseUrlForClassUrl(URL classUrl) {
51+
String string = classUrl.toString();
52+
if (classUrl.getProtocol().equals("jar")) {
53+
try {
54+
return new URL(string.substring(4).split("!")[0]);
55+
} catch (MalformedURLException e) {
56+
throw new RuntimeException(e);
57+
}
58+
}
59+
if (string.endsWith(".class")) {
60+
try {
61+
return new URL(string.replace("\\", "/")
62+
.replace(getClass().getCanonicalName()
63+
.replace(".", "/") + ".class", ""));
64+
} catch (MalformedURLException e) {
65+
throw new RuntimeException(e);
66+
}
67+
}
68+
return classUrl;
69+
}
70+
71+
/**
72+
* Get the package that contains all the mixins. This value is set by mixin itself using {@link #onLoad}.
73+
*/
74+
public String getMixinPackage() {
75+
return mixinPackage;
76+
}
77+
78+
/**
79+
* Get the path inside the class root to the mixin package
80+
*/
81+
public String getMixinBaseDir() {
82+
return mixinPackage.replace(".", "/");
83+
}
84+
85+
/**
86+
* A list of all discovered mixins.
87+
*/
88+
private List<String> mixins = null;
89+
90+
/**
91+
* Try to add mixin class ot the mixins based on the filepath inside of the class root.
92+
* Removes the {@code .class} file suffix, as well as the base mixin package.
93+
* <p><b>This method cannot be called after mixin initialization.</p>
94+
*
95+
* @param className the name or path of a class to be registered as a mixin.
96+
*/
97+
public void tryAddMixinClass(String className) {
98+
String norm = (className.endsWith(".class") ? className.substring(0, className.length() - ".class".length()) : className)
99+
.replace("\\", "/")
100+
.replace("/", ".");
101+
if (norm.startsWith(getMixinPackage() + ".") && !norm.endsWith(".")) {
102+
mixins.add(norm.substring(getMixinPackage().length() + 1));
103+
}
104+
}
105+
106+
/**
107+
* Search through the JAR or class directory to find mixins contained in {@link #getMixinPackage()}
108+
*/
109+
@Override
110+
public List<String> getMixins() {
111+
if (mixins != null) return mixins;
112+
System.out.println("Trying to discover mixins");
113+
mixins = new ArrayList<>();
114+
URL classUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
115+
System.out.println("Found classes at " + classUrl);
116+
Path file;
117+
try {
118+
file = Paths.get(getBaseUrlForClassUrl(classUrl).toURI());
119+
} catch (URISyntaxException e) {
120+
throw new RuntimeException(e);
121+
}
122+
System.out.println("Base directory found at " + file);
123+
if (Files.isDirectory(file)) {
124+
walkDir(file);
125+
} else {
126+
walkJar(file);
127+
}
128+
System.out.println("Found mixins: " + mixins);
129+
130+
return mixins;
131+
}
132+
133+
/**
134+
* Search through directory for mixin classes based on {@link #getMixinBaseDir}.
135+
*
136+
* @param classRoot The root directory in which classes are stored for the default package.
137+
*/
138+
private void walkDir(Path classRoot) {
139+
System.out.println("Trying to find mixins from directory");
140+
try (Stream<Path> classes = Files.walk(classRoot.resolve(getMixinBaseDir()))) {
141+
classes.map(it -> classRoot.relativize(it).toString())
142+
.forEach(this::tryAddMixinClass);
143+
} catch (IOException e) {
144+
throw new RuntimeException(e);
145+
}
146+
}
147+
148+
/**
149+
* Read through a JAR file, trying to find all mixins inside.
150+
*/
151+
private void walkJar(Path file) {
152+
System.out.println("Trying to find mixins from jar file");
153+
try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(file))) {
154+
ZipEntry next;
155+
while ((next = zis.getNextEntry()) != null) {
156+
tryAddMixinClass(next.getName());
157+
zis.closeEntry();
158+
}
159+
} catch (IOException e) {
160+
throw new RuntimeException(e);
161+
}
162+
}
163+
164+
@Override
165+
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
166+
167+
}
168+
169+
@Override
170+
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
171+
172+
}
173+
174+
@Override
175+
public String getRefMapperConfig() {
176+
return null;
177+
}
178+
179+
@Override
180+
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
181+
return true;
182+
}
183+
184+
@Override
185+
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
186+
187+
}
188+
}

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

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,16 @@ class OptifineGuide : UIContainer() {
112112

113113
val guideInstructionsText = MarkdownComponent(
114114
"""
115-
## Optifine install guide
116-
1. Download Optifine from [here](https://optifine.net/downloads)
117-
2. Open the downloaded file
118-
3. Click install
119-
4. Open the Minecraft launcher
120-
5. Click the installations tab
121-
6. Click the new installation button
122-
7. Name the installation
123-
8. Select the version you installed Optifine for
124-
9. Click create
125-
10. Select the new installation
126-
11. Click play
127-
12. Enjoy Optifine!
128-
13. If you have any issues, please contact support
129-
""".trimIndent()
115+
## Optifine install guide
116+
1. Go to the Optfine website and download Optifine for 1.8.9. [Direct link to The download.](https://optifine.net/adloadx?f=preview_OptiFine_1.8.9_HD_U_M6_pre2.jar)
117+
2. When you have downloaded find it in the Download folder in the File Explorer.
118+
3. Open the Modrinth app and locate the SkyBlock Enhanced installation.
119+
- It should be 3 dots on the right side of the installation.
120+
- Click on the 3 dots and then click on Open Folder.
121+
5. Then locate the mods folder and open it.
122+
6. When opened copy the Optifine file over from the Download folder and into the mods folder that you just opened.
123+
7. Click play and have fun.
124+
""".trimIndent()
130125
).constrain {
131126
x = CenterConstraint()
132127
width = 100.percent() - 10.pixels()

0 commit comments

Comments
 (0)