From 9a8f14c7d34da82820e50f077e2066ab71bf5215 Mon Sep 17 00:00:00 2001 From: Cutiepie <43445785+Ran-Mewo@users.noreply.github.com> Date: Wed, 17 Jan 2024 23:47:47 +0600 Subject: [PATCH 01/23] Attempt to remove arch and add AWToAt.java --- .gitignore | 3 + build.gradle | 37 ++- buildSrc/src/main/java/AWToAT.java | 239 ++++++++++++++++++ fabric/build.gradle | 17 +- forge/build.gradle | 184 ++++++++++---- .../distanthorizons/forge/ForgeMain.java | 2 +- .../DistantHorizons.forge.mixins.json | 3 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 2 + gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 4 + versionProperties/1.20.1.properties | 1 + versionProperties/1.20.2.properties | 1 + versionProperties/1.20.4.properties | 3 +- 14 files changed, 425 insertions(+), 75 deletions(-) create mode 100644 buildSrc/src/main/java/AWToAT.java diff --git a/.gitignore b/.gitignore index 16bdd9507..d69b9c48c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ build.properties # Sqlite databases *.sqlite + +# Don't add access transformers to git as it's dynamically generated +accesstransformer.cfg diff --git a/build.gradle b/build.gradle index f6a938675..e6c680bd0 100644 --- a/build.gradle +++ b/build.gradle @@ -8,13 +8,18 @@ plugins { id "io.github.pacifistmc.forgix" version "1.2.6" // Manifold preprocessor - id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" +// id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" // // Provides mc libraries to core // id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false // Architectury is used here only as a replacement for forge's own loom - id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false +// id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false + id "fabric-loom" version "1.4-SNAPSHOT" apply false + + id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' apply false + id 'org.spongepowered.mixin' version '0.7.+' apply false + id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false } /** @@ -104,8 +109,8 @@ subprojects { p -> // Apply plugins apply plugin: "java" apply plugin: "com.github.johnrengelman.shadow" - if (isMinecraftSubProject) - apply plugin: "systems.manifold.manifold-gradle-plugin" +// if (isMinecraftSubProject) +// apply plugin: "systems.manifold.manifold-gradle-plugin" if (p == project(":core")) apply plugin: "application" // apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries @@ -114,14 +119,20 @@ subprojects { p -> if ( (findProject(":forge") && p == project(":forge")) || (findProject(":neoforge") && p == project(":neoforge")) - ) - apply plugin: "dev.architectury.loom" + ) { +// apply plugin: 'net.minecraftforge.gradle' +// apply plugin: 'org.spongepowered.mixin' +// apply plugin: 'org.parchmentmc.librarian.forgegradle' + + /* The code below creates the access transformer file */ + new AWToAT().remap(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), accessWidenerVersion) + } // Set the manifold version (may not be required tough) - manifold { - manifoldVersion = rootProject.manifold_version - } +// manifold { +// manifoldVersion = rootProject.manifold_version +// } // set up custom configurations (configurations are a way to handle dependencies) @@ -143,7 +154,7 @@ subprojects { p -> // this should match shadowMe pretty closely implementation.extendsFrom(forgeShadowMe) shadowMe.extendsFrom(forgeShadowMe) - forgeRuntimeLibrary.extendsFrom(forgeShadowMe) + runtimeOnly.extendsFrom(forgeShadowMe) if (isMinecraftSubProject && p != project(":common")) { @@ -154,14 +165,18 @@ subprojects { p -> runtimeClasspath.extendsFrom common if (findProject(":forge")) developmentForge.extendsFrom common + implementation.extendsFrom common if (findProject(":neoforge")) developmentNeoForge.extendsFrom common + implementation.extendsFrom common compileClasspath.extendsFrom coreProjects runtimeClasspath.extendsFrom coreProjects if (findProject(":forge")) developmentForge.extendsFrom coreProjects + implementation.extendsFrom coreProjects if (findProject(":neoforge")) developmentNeoForge.extendsFrom coreProjects + implementation.extendsFrom coreProjects if (findProject(":fabricLike") && p != project(":fabricLike")) { // Shadow fabricLike @@ -615,7 +630,7 @@ allprojects { p -> into p.file("build/resources/main") } - tasks.withType(JavaCompile) { + compileJava { if (isMinecraftSubProject) { options.release = rootProject.java_version as Integer options.compilerArgs += ["-Xplugin:Manifold"] diff --git a/buildSrc/src/main/java/AWToAT.java b/buildSrc/src/main/java/AWToAT.java new file mode 100644 index 000000000..2f851b264 --- /dev/null +++ b/buildSrc/src/main/java/AWToAT.java @@ -0,0 +1,239 @@ +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class AWToAT { + private static final Map ACCESS_POINT_MAP = new HashMap<>(); + + static { + ACCESS_POINT_MAP.put("accessible", "public"); + ACCESS_POINT_MAP.put("extendable", "public-f"); + ACCESS_POINT_MAP.put("mutable", "public-f"); + } + + public String minecraftVersion; + + public File remap(File file, String minecraftVersion) { + this.minecraftVersion = minecraftVersion.replace("_", "."); + File atFile = createATFile(file); + processFile(file, atFile); + return atFile; + } + + private File createATFile(File file) { + File metaInf = new File(file.getParentFile(), "META-INF"); + if (!metaInf.exists() && !metaInf.mkdir()) throw new RuntimeException("Error creating META-INF folder"); + File atFile = new File(metaInf, "accesstransformer.cfg"); + try { + atFile.createNewFile(); + } catch (IOException e) { + throw new RuntimeException("Error creating new file", e); + } + return atFile; + } + + private void processFile(File file, File atFile) { + /* Validates if we need to recreate the Access Transformer file if it's out of date */ + // Get the hash of the file + String fileHash = getFileHash(file); + try (Scanner atScanner = new Scanner(atFile)) { + // Check if the AT file is up-to-date by comparing the hash of the file with the hash stored in the AT file + boolean hashFound = false; + while (atScanner.hasNextLine()) { + String line = atScanner.nextLine(); + if (hashCheck(line, fileHash)) { + hashFound = true; + } + } + + // If the AT file is up-to-date, print a message and return + if (hashFound) { + System.out.println("Access Transformer file is already up to date."); + return; + } + } catch (FileNotFoundException ignored) { + // If the AT file does not exist, continue + } + + /* Creates the Access Transformer file */ + // Opens a scanner for reading the Access Widener file and a writer for writing to the Access Transformer file + try (Scanner scanner = new Scanner(file); FileWriter writer = new FileWriter(atFile)) { + // Create an ExecutorService with a fixed thread pool size equal to the number of available processors + ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + // List to hold Future objects representing results of computation + List> futures = new ArrayList<>(); + + // Write the hash of the file to the AT file + writer.write("#DH_MAPPING_HASH:" + fileHash + "\n"); + + // Read each line from the file + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + // Skip lines starting with "accessWidener", "#" or blank lines + if (line.startsWith("accessWidener") || line.startsWith("#") || line.isBlank()) continue; + + // Submit the line to the executor service for processing + // The processing is done by the processLine method + futures.add(executor.submit(() -> processLine(line.split(" ")))); + } + + // Write the results to the output file + // The results are obtained by calling the get method on each Future + for (Future future : futures) { + writer.write(future.get()); + } + + // Shutdown the executor service to free up resources + executor.shutdown(); + } catch (Exception e) { + throw new RuntimeException("Error reading or writing to file", e); + } + } + + private String processLine(String[] fields) { + // fields[0] = access point like "accessible", "extendable", "mutable" + // fields[1] = type like "field", "method", "class" + // fields[2] = class name + // fields[3] = field/method name + // fields[4] = field/method descriptor + + try { + // Store the original field/method name + String originalName = ""; + + // If there is a class name, replace the slashes with dots in the package name + if (fields.length > 2) fields[2] = fields[2].replace("/", "."); + + // If there is a field/method name, store the original name and remap it to SRG + if (fields.length > 3) { + originalName = fields[3]; + fields[3] = remapToSRG(fields[2], fields[3]); + } + + StringBuilder line = new StringBuilder(ACCESS_POINT_MAP.getOrDefault(fields[0], "public")).append(" "); + switch (fields[1]) { + case "field": + line.append(fields[2]).append(" ").append(fields[3]).append(" #").append(originalName); + // It'll be like: access-point class-name field-name-SRG # field-name-Mojmap + // Eg: public net.minecraft.client.Minecraft f_90981_ # instance + break; + case "method": + line.append(fields[2]).append(" ").append(fields[3]).append(fields[4]).append(" #").append(originalName); + // It'll be like: access-point class-name method-name-SRG method-descriptor # method-name-Mojmap + // Eg: public net.minecraft.client.Minecraft m_172797_()Lnet/minecraft/client/Minecraft; # getInstance + break; + default: + line.append(fields[2]); + // It'll be like: access-point class-name + // Eg: public net.minecraft.client.Minecraft + break; + } + line.append("\n"); + return line.toString(); + } catch (Exception e) { + throw new RuntimeException("Error processing line", e); + } + } + + private boolean hashCheck(String line, String fileHash) { + if (line.startsWith("#DH_MAPPING_HASH:")) { + String hash = line.substring(17); + return hash.equals(fileHash); + } + return false; + } + + public String getFileHash(File file) { + try { + MessageDigest shaDigest = MessageDigest.getInstance("SHA-256"); + try (InputStream fis = new FileInputStream(file)) { + byte[] byteArray = new byte[1024]; + int bytesCount; + + // Read file data and update in message digest + while ((bytesCount = fis.read(byteArray)) != -1) { + shaDigest.update(byteArray, 0, bytesCount); + } + } + + byte[] bytes = shaDigest.digest(); + + // Convert byte array into signum representation + StringBuilder sb = new StringBuilder(); + for (byte aByte : bytes) { + sb.append(Integer.toString((aByte & 0xff) + 0x100, 16).substring(1)); + } + + // Return complete hash + return sb.toString(); + } catch (NoSuchAlgorithmException | IOException e) { + throw new RuntimeException(e); + } + } + + + + // WARNING: BELOW LIES HIGHLY CURSED CODE AND MIGHT EVEN BE ILLEGAL + + + + + // Flag to track if there was an error in the GET request + boolean error = false; + + /** + * This method returns a field or method name from Mojang mappings as SRG mappings. + * It makes a GET request to the Linkie API to fetch the SRG name. + * + * @param clazz The class name + * @param name The field or method name + * @return The SRG name + * @throws Exception If there is an error in the GET request or the SRG name is not found in the response + */ + private String remapToSRG(String clazz, String name) throws Exception { + // Encode the class and field/method name to be used in the URL + String query = URLEncoder.encode(clazz + "." + name, StandardCharsets.UTF_8); + // Construct the URL for the GET request + String urlString = "https://linkieapi.shedaniel.me/api/search?namespace=mojang&query=" + query + "&version=" + this.minecraftVersion + "&limit=1&allowClasses=false&allowFields=true&allowMethods=true&translate=mojang_srg"; + URL url = new URI(urlString).toURL(); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + int responseCode = conn.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String inputLine; + StringBuilder content = new StringBuilder(); + // Read the response line by line + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); + } + in.close(); + conn.disconnect(); + // Regex to find the SRG name in the response + Pattern pattern = Pattern.compile("\"l\"\\s*:\\s*\\{[^}]*\"i\"\\s*:\\s*\"([^\"]*)\""); + Matcher matcher = pattern.matcher(content.toString()); + if (matcher.find()) return matcher.group(1); + else throw new Exception("Couldn't find the SRG mapping for name: " + name + "\nCould not find 'i' in 'l' object in the response"); // `i` is the SRG name which is stored in the `l` JSON object + } else { + if (error) { + // If there was an error in the GET request, and we already tried again, throw an exception + throw new Exception("The GET request failed"); + } + // If there was an error in the GET request, wait 2.5 seconds and try again as we probably got rate limited + error = true; + Thread.sleep(2500); + return remapToSRG(clazz, name); + } + } +} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index ee52d6df3..16b860c36 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,6 +1,4 @@ -plugins { - id "fabric-loom" version "1.4-SNAPSHOT" -} +apply plugin: "fabric-loom" loom { accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") @@ -22,17 +20,12 @@ loom { } } -remapJar { - inputFile = shadowJar.archiveFile - dependsOn shadowJar -// classifier null -} - configurations { // The addModJar basically embeds the mod to the built jar addModJar include.extendsFrom addModJar modImplementation.extendsFrom addModJar + dummy } def addMod(path, enabled) { @@ -114,6 +107,12 @@ dependencies { } } +remapJar { + inputFile = shadowJar.archiveFile + dependsOn shadowJar +// classifier null +} + task deleteResources(type: Delete) { delete file("build/resources/main") diff --git a/forge/build.gradle b/forge/build.gradle index 9c159a519..5b39fd074 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,15 +1,12 @@ -plugins { - // Note: This is only needed for multi-loader projects - // The main architectury loom version is set at the start of the root build.gradle - id "architectury-plugin" version "3.4-SNAPSHOT" -} +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'org.spongepowered.mixin' -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 +//sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 -architectury { - platformSetupLoomIde() - forge() -} +//architectury { +// platformSetupLoomIde() +// forge() +//} //loom { // forge { @@ -19,61 +16,138 @@ architectury { // } //} -loom { - silentMojangMappingsLicense() // Shut the licencing warning - accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") +//loom { +// silentMojangMappingsLicense() // Shut the licencing warning +// accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") +// +// forge { +// convertAccessWideners = true +// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name +// +// mixinConfigs = [ +// "DistantHorizons.forge.mixins.json" +// ] +// } +// +// // "runs" isn't required, but when we do need it then it can be useful +// runs { +// client { +// client() +// setConfigName("Forge Client") +// ideConfigGenerated(true) +// runDir("../run") +//// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg) +// } +// server { +// server() +// setConfigName("Forge Server") +// ideConfigGenerated(true) +// runDir("../run") +// } +// } +//} - forge { - convertAccessWideners = true - extraAccessWideners.add loom.accessWidenerPath.get().asFile.name - - mixinConfigs = [ - "DistantHorizons.forge.mixins.json" - ] - } - - // "runs" isn't required, but when we do need it then it can be useful +minecraft { + mappings channel: 'official', version: minecraft_version + accessTransformer = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg') runs { client { - client() - setConfigName("Forge Client") - ideConfigGenerated(true) - runDir("../run") -// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg) + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + taskName 'Client' + args "-mixins.config=${mod_name}.forge.mixins.json" + mods { + modClientRun { + source sourceSets.main + source project(":common").sourceSets.main + source project(":api").sourceSets.main + source project(":core").sourceSets.main + } + } + property 'forge.enabledGameTestNamespaces', mod_id + property 'forge.logging.console.level', 'debug' + properties 'mixin.env.remapRefMap': 'true' + property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" } + server { - server() - setConfigName("Forge Server") - ideConfigGenerated(true) - runDir("../run") + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + taskName 'Server' + args "-mixins.config=${mod_name}.forge.mixins.json" + mods { + modServerRun { + source sourceSets.main + source project(":common").sourceSets.main + source project(":api").sourceSets.main + source project(":core").sourceSets.main + } + } + property 'forge.logging.console.level', 'debug' + properties 'mixin.env.remapRefMap': 'true' + property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" + } + + data { + workingDirectory project.file('run') + ideaModule "${rootProject.name}.${project.name}.main" + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + taskName 'Data' + args "-mixins.config=${mod_name}.forge.mixins.json" + mods { + modDataRun { + source sourceSets.main + source project(":common").sourceSets.main + source project(":api").sourceSets.main + source project(":core").sourceSets.main + } + } + property 'forge.logging.console.level', 'debug' } } } +sourceSets.main.resources.srcDir 'src/generated/resources' -remapJar { - inputFile = shadowJar.archiveFile - dependsOn shadowJar -// classifier null +//remapJar { +// inputFile = shadowJar.archiveFile +// dependsOn shadowJar +//// classifier null +//} +shadowJar { + finalizedBy 'reobfShadowJar' +} +jar.dependsOn('shadowJar') +reobf { + shadowJar {} } +minecraft.runs.all { + lazyToken('minecraft_classpath') { +// configurations.implementation.exclude group: 'org.jetbrains', module: 'annotations' +// configurations.implementation.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) +// configurations.runtimeLibrary.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) + } +} def addMod(path, enabled) { if (enabled == "2") - dependencies { implementation(path) } +// dependencies { implementation(path) } + dependencies { implementation(fg.deobf(path)) } else if (enabled == "1") - dependencies { modCompileOnly(path) } +// dependencies { modCompileOnly(path) } + dependencies { compileOnly(fg.deobf(path)) } } dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings loom.layered() { - // Mojmap mappings - officialMojangMappings() - // Parchment mappings (it adds parameter mappings & javadoc) - parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip") - } +// minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" +// mappings loom.layered() { +// // Mojmap mappings +// officialMojangMappings() +// // Parchment mappings (it adds parameter mappings & javadoc) +// parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip") +// } // Forge - forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" + minecraft "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" // Architectury API // if (minecraft_version == "1.16.5") { @@ -89,12 +163,18 @@ dependencies { addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged) addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft) + + annotationProcessor "org.spongepowered:mixin:0.8.5:processor" // if (System.getProperty("idea.sync.active") != "true") { // annotationProcessor "org.spongepowered:mixin:0.8.4:processor" // } } +mixin { + add sourceSets.main, "${mod_name}-forge-refmap.json" +} + task deleteResources(type: Delete) { delete file("build/resources/main") } @@ -108,10 +188,14 @@ processResources { dependsOn(tasks.named('copyAllResources')) } -tasks.named('runClient') { - dependsOn(tasks.named('copyAllResources')) - finalizedBy(deleteResources) -} +//processResources { +// dependsOn(tasks.named('copyAllResources')) +//} + +//tasks.named('prepareClient') { +// dependsOn(tasks.named('copyAllResources')) +// finalizedBy(deleteResources) +//} sourcesJar { diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeMain.java b/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeMain.java index 4195b2dea..a86b24a9d 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeMain.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeMain.java @@ -86,7 +86,7 @@ import java.util.List; * @author James Seibel * @version 8-15-2022 */ -@Mod(ModInfo.ID) +@Mod("distanthorizons") // TODO: Change it back to ModInfo.ID when forge works public class ForgeMain implements LodForgeMethodCaller { private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName()); diff --git a/forge/src/main/resources/DistantHorizons.forge.mixins.json b/forge/src/main/resources/DistantHorizons.forge.mixins.json index b30ef91ed..cd96e8fec 100644 --- a/forge/src/main/resources/DistantHorizons.forge.mixins.json +++ b/forge/src/main/resources/DistantHorizons.forge.mixins.json @@ -20,5 +20,6 @@ "client.MixinTextureUtil" ], "server": [], - "plugin": "com.seibel.distanthorizons.forge.mixins.ForgeMixinPlugin" + "plugin": "com.seibel.distanthorizons.forge.mixins.ForgeMixinPlugin", + "refmap": "DistantHorizons-forge-refmap.json" } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 3f199093b..d9aab7f79 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -29,5 +29,5 @@ issueTrackerURL = "${issues}" mandatory = true # Forge syntax type = "required" # Neoforge syntax versionRange = "${compatible_forgemc_versions}" # Where we set what version of mc it is avalible for - ordering = "NONE" + ordering = "AFTER" side = "BOTH" \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ac5579831..68434b1e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,11 @@ org.gradle.jvmargs=-Xmx4096M org.gradle.parallel=true org.gradle.caching=true +fabric.loom.multiProjectOptimisation=true # Mod Info mod_name=DistantHorizons +mod_id=distanthorizons mod_version=2.0.2-a-dev api_version=1.1.0 maven_group=com.seibel.distanthorizons diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e6aba2515..1af9e0930 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index 5e8900e42..f90316ec2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -25,6 +25,10 @@ pluginManagement { name "Sponge" url "https://repo.spongepowered.org/repository/maven-public/" } + maven { + name "ParchmentMC" + url "https://maven.parchmentmc.org" + } mavenCentral() gradlePluginPortal() diff --git a/versionProperties/1.20.1.properties b/versionProperties/1.20.1.properties index ba4d8188b..c09f670e1 100644 --- a/versionProperties/1.20.1.properties +++ b/versionProperties/1.20.1.properties @@ -2,6 +2,7 @@ java_version=17 minecraft_version=1.20.1 parchment_version=1.20.1:2023.09.03 +parchment_forge_version=1.20.1-2023.09.03 compatible_minecraft_versions=["1.20", "1.20.1"] accessWidenerVersion=1_20 builds_for=fabric,forge diff --git a/versionProperties/1.20.2.properties b/versionProperties/1.20.2.properties index 1f15abab5..20b716662 100644 --- a/versionProperties/1.20.2.properties +++ b/versionProperties/1.20.2.properties @@ -2,6 +2,7 @@ java_version=17 minecraft_version=1.20.2 parchment_version=1.20.1:2023.09.03 +parchment_forge_version=1.20.1-2023.09.03 compatible_minecraft_versions=["1.20.2"] accessWidenerVersion=1_20_2 builds_for=fabric,forge diff --git a/versionProperties/1.20.4.properties b/versionProperties/1.20.4.properties index 1f588d1db..74ac59e5a 100644 --- a/versionProperties/1.20.4.properties +++ b/versionProperties/1.20.4.properties @@ -2,9 +2,10 @@ java_version=17 minecraft_version=1.20.4 parchment_version=1.20.2:2023.12.10 +parchment_forge_version=1.20.2-2023.12.10 compatible_minecraft_versions=["1.20.3", "1.20.4"] accessWidenerVersion=1_20_2 -builds_for=fabric,forge,neoforge +builds_for=forge,fabric # Fabric loader fabric_loader_version=0.15.1 From 1d8946702233f83edee3d870e86bfa11f449e13a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 20 Jan 2024 11:12:08 -0600 Subject: [PATCH 02/23] Fix Forge 1.20.1 launching (although crashes due to shadowJar fail) --- forge/build.gradle | 10 ++++++---- settings.gradle | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 5b39fd074..aaac92ced 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'maven-publish' apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' @@ -49,6 +52,9 @@ apply plugin: 'org.spongepowered.mixin' minecraft { mappings channel: 'official', version: minecraft_version + + copyIdeResources = true + accessTransformer = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg') runs { client { @@ -188,10 +194,6 @@ processResources { dependsOn(tasks.named('copyAllResources')) } -//processResources { -// dependsOn(tasks.named('copyAllResources')) -//} - //tasks.named('prepareClient') { // dependsOn(tasks.named('copyAllResources')) // finalizedBy(deleteResources) diff --git a/settings.gradle b/settings.gradle index f90316ec2..fafdfba49 100644 --- a/settings.gradle +++ b/settings.gradle @@ -37,6 +37,10 @@ pluginManagement { } } +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} + // Loads the version.properties From 6d7b557c36051d19c1f30b79a1322e68c01f6e90 Mon Sep 17 00:00:00 2001 From: Cutiepie <43445785+Ran-Mewo@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:44:50 +1100 Subject: [PATCH 03/23] Attempt to move over to Unimined --- build.gradle | 97 +++++----- .../RegionFileStorageExternalCache.java | 2 +- coreSubProjects | 2 +- fabric/build.gradle | 71 ++++--- forge/build.gradle | 173 ++---------------- .../mixins/client/MixinDynamicTexture.java | 2 +- .../DistantHorizons.forge.mixins.json | 4 +- forge/src/main/resources/META-INF/mods.toml | 7 +- forge/src/main/resources/pack.mcmeta | 10 - neoforge/build.gradle | 111 ++--------- settings.gradle | 6 + versionProperties/1.20.1.properties | 1 - versionProperties/1.20.2.properties | 1 - versionProperties/1.20.4.properties | 5 +- 14 files changed, 130 insertions(+), 362 deletions(-) delete mode 100644 forge/src/main/resources/pack.mcmeta diff --git a/build.gradle b/build.gradle index e6c680bd0..fd98ce39f 100644 --- a/build.gradle +++ b/build.gradle @@ -13,13 +13,8 @@ plugins { // // Provides mc libraries to core // id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false - // Architectury is used here only as a replacement for forge's own loom -// id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false - id "fabric-loom" version "1.4-SNAPSHOT" apply false - - id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' apply false - id 'org.spongepowered.mixin' version '0.7.+' apply false - id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false + // Use unimined which is our one in all solution to minecraft loaders + id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false } /** @@ -114,18 +109,30 @@ subprojects { p -> if (p == project(":core")) apply plugin: "application" // apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries + + if (p != project(":common") && isMinecraftSubProject) { + apply plugin: "xyz.wagyourtail.unimined" - // Apply forge's loom - if ( - (findProject(":forge") && p == project(":forge")) || - (findProject(":neoforge") && p == project(":neoforge")) - ) { -// apply plugin: 'net.minecraftforge.gradle' -// apply plugin: 'org.spongepowered.mixin' -// apply plugin: 'org.parchmentmc.librarian.forgegradle' + unimined.minecraft(sourceSets.main, true) { + version minecraft_version - /* The code below creates the access transformer file */ - new AWToAT().remap(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), accessWidenerVersion) + def parchmentVersionParts = parchment_version.split(":") + mappings { + mojmap() + parchment(parchmentVersionParts[0], parchmentVersionParts[1]) + devNamespace "mojmap" + } + } + + tasks.withType(JavaCompile).configureEach { + source(project(":common").sourceSets.main.allSource) + source(project(":api").sourceSets.main.allSource) + source(project(":core").sourceSets.main.allSource) + } + } + + tasks.withType(GenerateModuleMetadata) { + enabled = false } @@ -138,52 +145,33 @@ subprojects { p -> // set up custom configurations (configurations are a way to handle dependencies) configurations { // extends the shadowJar configuration - shadowMe + shadowMe // Configuration that contains coreProjects + shade // Configuration that doesn't contain coreProjects + // have implemented dependencies automatically embedded in the final jar implementation.extendsFrom(shadowMe) + implementation.extendsFrom(shade) + + // Add shaded libraries very early in the classpath (excluding coreProjects as that's added in a different way) + minecraftLibraries.extendsFrom(shade) // Configuration fpr core & api coreProjects shadowMe.extendsFrom(coreProjects) - // FIXME this additional configuration is necessary because forge - // needs forgeRuntimeLibrary, although adding it to shadowMe - // causes runtime issues where the libraries aren't properly added - forgeShadowMe - // this should match shadowMe pretty closely - implementation.extendsFrom(forgeShadowMe) - shadowMe.extendsFrom(forgeShadowMe) - runtimeOnly.extendsFrom(forgeShadowMe) - - if (isMinecraftSubProject && p != project(":common")) { // Shadow common common shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - if (findProject(":forge")) - developmentForge.extendsFrom common - implementation.extendsFrom common - if (findProject(":neoforge")) - developmentNeoForge.extendsFrom common - implementation.extendsFrom common - compileClasspath.extendsFrom coreProjects - runtimeClasspath.extendsFrom coreProjects - if (findProject(":forge")) - developmentForge.extendsFrom coreProjects - implementation.extendsFrom coreProjects - if (findProject(":neoforge")) - developmentNeoForge.extendsFrom coreProjects - implementation.extendsFrom coreProjects + implementation.extendsFrom common + implementation.extendsFrom coreProjects if (findProject(":fabricLike") && p != project(":fabricLike")) { // Shadow fabricLike fabricLike shadowFabricLike - compileClasspath.extendsFrom fabricLike - runtimeClasspath.extendsFrom fabricLike + implementation.extendsFrom fabricLike } } } @@ -202,7 +190,6 @@ subprojects { p -> // shared dependencies // //=====================// - // Manifold if (isMinecraftSubProject) { annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}") @@ -223,24 +210,24 @@ subprojects { p -> implementation("junit:junit:4.13") // Compression - forgeShadowMe("org.lz4:lz4-java:${rootProject.lz4_version}") + shade("org.lz4:lz4-java:${rootProject.lz4_version}") // Sqlite Database - forgeShadowMe("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}") + shade("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}") // NightConfig (includes Toml & Json) - forgeShadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}") - forgeShadowMe("com.electronwill.night-config:json:${rootProject.nightconfig_version}") + shade("com.electronwill.night-config:toml:${rootProject.nightconfig_version}") + shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}") // SVG (not needed atm) -// forgeShadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") +// shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") // Netty // Breaks 1.16.5 - //forgeShadowMe("io.netty:netty-all:${rootProject.netty_version}") + //shade("io.netty:netty-all:${rootProject.netty_version}") // Remember, for lwjgl dependencies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing - forgeShadowMe("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") { + shade("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") { exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it } @@ -291,7 +278,7 @@ subprojects { p -> shadowJar { - configurations = [project.configurations.shadowMe] + configurations = [project.configurations.shadowMe, project.configurations.shade] if (isMinecraftSubProject && p != project(":common")) { configurations.push(project.configurations.shadowCommon) // Shadow the common subproject relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java index edbc1c89f..757f5500c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java @@ -9,7 +9,7 @@ import net.minecraft.world.level.chunk.storage.RegionFile; import net.minecraft.world.level.chunk.storage.RegionFileStorage; import org.apache.logging.log4j.Logger; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import java.io.DataInputStream; import java.io.IOException; import java.nio.file.Files; diff --git a/coreSubProjects b/coreSubProjects index 754954326..fd80b0add 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 7549543268149eb5f93d44bf1b4651e10734247f +Subproject commit fd80b0adde7a545f3793729d31e6dce3254300f4 diff --git a/fabric/build.gradle b/fabric/build.gradle index 16b860c36..342f7704c 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,22 +1,7 @@ -apply plugin: "fabric-loom" - -loom { - accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") - - // "runs" isn't required, but when we do need it then it can be useful - runs { - client { - client() - setConfigName("Fabric Client") - ideConfigGenerated(true) - runDir("../run") - } - server { - server() - setConfigName("Fabric Server") - ideConfigGenerated(true) - runDir("../run") - } +unimined.minecraft { + fabric { + loader rootProject.fabric_loader_version + accessWidener(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")) } } @@ -32,27 +17,31 @@ def addMod(path, enabled) { if (enabled == "2") dependencies { modImplementation(path) } else if (enabled == "1") - dependencies { modCompileOnly(path) } + dependencies { compileOnly(path) } +} + +// TODO: There currently seems to be a bug which causes the regular addModJar to not work, swap back to the regular addModJar when fixed +def addModJar_(path) { + dependencies { + modImplementation(path) + include(path) + } } dependencies { - minecraft "com.mojang:minecraft:${minecraft_version}" - mappings loom.layered() { - // Mojmap mappings - officialMojangMappings() - // Parchment mappings (it adds parameter mappings & javadoc) - parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip") - } - // Fabric loader - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - + annotationProcessor "javax.annotation:javax.annotation-api:1.3.2" + implementation("javax.annotation:javax.annotation-api:1.3.2") + runtimeOnly "javax.annotation:javax.annotation-api:1.3.2" + compileOnly "javax.annotation:javax.annotation-api:1.3.2" + modImplementation "javax.annotation:javax.annotation-api:1.3.2" + // Fabric API - addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) - addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) - addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)) - addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version)) - addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy) - addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version)) + addModJar_(fabricApi.fabricModule("fabric-api-base", rootProject.fabric_api_version)) + addModJar_(fabricApi.fabricModule("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) + addModJar_(fabricApi.fabricModule("fabric-resource-loader-v0", rootProject.fabric_api_version)) + addModJar_(fabricApi.fabricModule("fabric-events-interaction-v0", rootProject.fabric_api_version)) + addModJar_(fabricApi.fabricModule("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy) + addModJar_(fabricApi.fabricModule("fabric-networking-api-v1", rootProject.fabric_api_version)) // Mod Menu modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") @@ -123,11 +112,13 @@ processResources { dependsOn(copyCommonLoaderResources) } -runClient { - dependsOn(copyCoreResources) - dependsOn(copyCommonLoaderResources) +afterEvaluate { + runClient { + dependsOn(copyCoreResources) + dependsOn(copyCommonLoaderResources) // jvmArgs([ "-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg ]) - finalizedBy(deleteResources) + finalizedBy(deleteResources) + } } //jar { diff --git a/forge/build.gradle b/forge/build.gradle index 5b39fd074..660022115 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,154 +1,19 @@ -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'org.spongepowered.mixin' - -//sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 - -//architectury { -// platformSetupLoomIde() -// forge() -//} - -//loom { -// forge { -// convertAccessWideners.set(true) -// extraAccessWideners.add("lod.accesswidener") -// mixinConfigs("DistantHorizons.mixins.json") -// } -//} - -//loom { -// silentMojangMappingsLicense() // Shut the licencing warning -// accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") -// -// forge { -// convertAccessWideners = true -// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name -// -// mixinConfigs = [ -// "DistantHorizons.forge.mixins.json" -// ] -// } -// -// // "runs" isn't required, but when we do need it then it can be useful -// runs { -// client { -// client() -// setConfigName("Forge Client") -// ideConfigGenerated(true) -// runDir("../run") -//// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg) -// } -// server { -// server() -// setConfigName("Forge Server") -// ideConfigGenerated(true) -// runDir("../run") -// } -// } -//} - -minecraft { - mappings channel: 'official', version: minecraft_version - accessTransformer = project(":common").file('src/main/resources/META-INF/accesstransformer.cfg') - runs { - client { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Client' - args "-mixins.config=${mod_name}.forge.mixins.json" - mods { - modClientRun { - source sourceSets.main - source project(":common").sourceSets.main - source project(":api").sourceSets.main - source project(":core").sourceSets.main - } - } - property 'forge.enabledGameTestNamespaces', mod_id - property 'forge.logging.console.level', 'debug' - properties 'mixin.env.remapRefMap': 'true' - property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" - } - - server { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - taskName 'Server' - args "-mixins.config=${mod_name}.forge.mixins.json" - mods { - modServerRun { - source sourceSets.main - source project(":common").sourceSets.main - source project(":api").sourceSets.main - source project(":core").sourceSets.main - } - } - property 'forge.logging.console.level', 'debug' - properties 'mixin.env.remapRefMap': 'true' - property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" - } - - data { - workingDirectory project.file('run') - ideaModule "${rootProject.name}.${project.name}.main" - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - taskName 'Data' - args "-mixins.config=${mod_name}.forge.mixins.json" - mods { - modDataRun { - source sourceSets.main - source project(":common").sourceSets.main - source project(":api").sourceSets.main - source project(":core").sourceSets.main - } - } - property 'forge.logging.console.level', 'debug' - } +unimined.minecraft { + minecraftForge { + loader forge_version + mixinConfig("DistantHorizons.forge.mixins.json") + accessTransformer(aw2at(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))) } } -sourceSets.main.resources.srcDir 'src/generated/resources' -//remapJar { -// inputFile = shadowJar.archiveFile -// dependsOn shadowJar -//// classifier null -//} -shadowJar { - finalizedBy 'reobfShadowJar' -} -jar.dependsOn('shadowJar') -reobf { - shadowJar {} -} - -minecraft.runs.all { - lazyToken('minecraft_classpath') { -// configurations.implementation.exclude group: 'org.jetbrains', module: 'annotations' -// configurations.implementation.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) -// configurations.runtimeLibrary.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) - } -} def addMod(path, enabled) { if (enabled == "2") -// dependencies { implementation(path) } - dependencies { implementation(fg.deobf(path)) } + dependencies { modImplementation(path) } else if (enabled == "1") -// dependencies { modCompileOnly(path) } - dependencies { compileOnly(fg.deobf(path)) } + dependencies { compileOnly(path) } } dependencies { -// minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" -// mappings loom.layered() { -// // Mojmap mappings -// officialMojangMappings() -// // Parchment mappings (it adds parameter mappings & javadoc) -// parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip") -// } - - // Forge - minecraft "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" - // Architectury API // if (minecraft_version == "1.16.5") { // implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}") @@ -164,17 +29,13 @@ dependencies { addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft) - annotationProcessor "org.spongepowered:mixin:0.8.5:processor" +// annotationProcessor "org.spongepowered:mixin:0.8.5:processor" // if (System.getProperty("idea.sync.active") != "true") { // annotationProcessor "org.spongepowered:mixin:0.8.4:processor" // } } -mixin { - add sourceSets.main, "${mod_name}-forge-refmap.json" -} - task deleteResources(type: Delete) { delete file("build/resources/main") } @@ -188,14 +49,18 @@ processResources { dependsOn(tasks.named('copyAllResources')) } -//processResources { -// dependsOn(tasks.named('copyAllResources')) -//} +afterEvaluate { + runClient { + dependsOn(tasks.named('copyAllResources')) + finalizedBy(deleteResources) + } +} -//tasks.named('prepareClient') { -// dependsOn(tasks.named('copyAllResources')) -// finalizedBy(deleteResources) -//} +remapJar { + inputFile = shadowJar.archiveFile + dependsOn shadowJar +// classifier null +} sourcesJar { diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinDynamicTexture.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinDynamicTexture.java index 7117e7063..36bf97035 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinDynamicTexture.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinDynamicTexture.java @@ -38,7 +38,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; @Mixin(DynamicTexture.class) public abstract class MixinDynamicTexture implements ILightTextureMarker diff --git a/forge/src/main/resources/DistantHorizons.forge.mixins.json b/forge/src/main/resources/DistantHorizons.forge.mixins.json index cd96e8fec..c7326a9e4 100644 --- a/forge/src/main/resources/DistantHorizons.forge.mixins.json +++ b/forge/src/main/resources/DistantHorizons.forge.mixins.json @@ -19,7 +19,5 @@ "client.MixinOptionsScreen", "client.MixinTextureUtil" ], - "server": [], - "plugin": "com.seibel.distanthorizons.forge.mixins.ForgeMixinPlugin", - "refmap": "DistantHorizons-forge-refmap.json" + "server": [] } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index d9aab7f79..07a9fb5ca 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -23,11 +23,16 @@ issueTrackerURL = "${issues}" #// Allow any version to be present (or not) on the server acceptableRemoteVersions = "*" +[[dependencies.distanthorizons]] + modId="forge" #mandatory + mandatory = true # Forge syntax + versionRange="[0,)" #mandatory + ordering="NONE" + side="BOTH" [[dependencies.distanthorizons]] modId = "minecraft" mandatory = true # Forge syntax - type = "required" # Neoforge syntax versionRange = "${compatible_forgemc_versions}" # Where we set what version of mc it is avalible for ordering = "AFTER" side = "BOTH" \ No newline at end of file diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index 37621f6f9..000000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,10 +0,0 @@ -{ - "pack": { - "pack_format": 7, - "supported_formats": { - "min_inclusive": 16, - "max_inclusive": 90000 - }, - "description": "Distant Horizons" - } -} diff --git a/neoforge/build.gradle b/neoforge/build.gradle index dd98c015a..31700a31b 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -1,100 +1,19 @@ -plugins { - // Note: This is only needed for multi-loader projects - // The main architectury loom version is set at the start of the root build.gradle - id "architectury-plugin" version "3.4-SNAPSHOT" -} - -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 - -architectury { - platformSetupLoomIde() - neoForge() -} - -repositories { - maven { - name "Neoforge" - url "https://maven.neoforged.net/releases/" +unimined.minecraft { + neoForged { + loader neoforge_version + mixinConfig("DistantHorizons.neoforge.mixins.json") + accessTransformer(aw2at(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))) } } -//loom { -// forge { -// convertAccessWideners.set(true) -// extraAccessWideners.add("lod.accesswidener") -// mixinConfigs("DistantHorizons.mixins.json") -// } -//} - -loom { - silentMojangMappingsLicense() // Shut the licencing warning - accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") - - neoForge { - // Access wideners are now defined in the `remapJar.atAccessWideners` -// convertAccessWideners = true -// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name - - // Mixins are now defined in the `mods.toml` -// mixinConfigs = [ -// "DistantHorizons.mixins.json" -// ] - } - mixin { - // Mixins are now defined in the `mods.toml` -// mixinConfigs = [ -// "DistantHorizons.mixins.json" -// ] - } - - // "runs" isn't required, but when we do need it then it can be useful - runs { - client { - client() - setConfigName("NeoForge Client") - ideConfigGenerated(true) - runDir("../run") -// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg) - } - server { - server() - setConfigName("NeoForge Server") - ideConfigGenerated(true) - runDir("../run") - } - } -} - -remapJar { - inputFile = shadowJar.archiveFile - dependsOn shadowJar -// classifier null - - atAccessWideners.add("distanthorizons.accesswidener") -} - def addMod(path, enabled) { if (enabled == "2") - dependencies { implementation(path) } + dependencies { modImplementation(path) } else if (enabled == "1") - dependencies { modCompileOnly(path) } + dependencies { compileOnly(path) } } dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings loom.layered() { - // Mojmap mappings - officialMojangMappings() - // Parchment mappings (it adds parameter mappings & javadoc) - parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip") - - // Architectury hackishness -// it.mappings "dev.architectury:yarn-mappings-patch-forge:${rootProject.mappings_patch}" - } - - // Neoforge - neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" - // Architectury API // if (minecraft_version == "1.16.5") { // implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}") @@ -110,6 +29,8 @@ dependencies { addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft) +// annotationProcessor "org.spongepowered:mixin:0.8.5:processor" + // if (System.getProperty("idea.sync.active") != "true") { // annotationProcessor "org.spongepowered:mixin:0.8.4:processor" // } @@ -128,9 +49,17 @@ processResources { dependsOn(tasks.named('copyAllResources')) } -tasks.named('runClient') { - dependsOn(tasks.named('copyAllResources')) - finalizedBy(deleteResources) +afterEvaluate { + runClient { + dependsOn(tasks.named('copyAllResources')) + finalizedBy(deleteResources) + } +} + +remapJar { + inputFile = shadowJar.archiveFile + dependsOn shadowJar +// classifier null } diff --git a/settings.gradle b/settings.gradle index f90316ec2..33c4c4554 100644 --- a/settings.gradle +++ b/settings.gradle @@ -29,6 +29,12 @@ pluginManagement { name "ParchmentMC" url "https://maven.parchmentmc.org" } + maven { + url = "https://maven.wagyourtail.xyz/releases" + } + maven { + url = "https://maven.wagyourtail.xyz/snapshots" + } mavenCentral() gradlePluginPortal() diff --git a/versionProperties/1.20.1.properties b/versionProperties/1.20.1.properties index c09f670e1..ba4d8188b 100644 --- a/versionProperties/1.20.1.properties +++ b/versionProperties/1.20.1.properties @@ -2,7 +2,6 @@ java_version=17 minecraft_version=1.20.1 parchment_version=1.20.1:2023.09.03 -parchment_forge_version=1.20.1-2023.09.03 compatible_minecraft_versions=["1.20", "1.20.1"] accessWidenerVersion=1_20 builds_for=fabric,forge diff --git a/versionProperties/1.20.2.properties b/versionProperties/1.20.2.properties index 20b716662..1f15abab5 100644 --- a/versionProperties/1.20.2.properties +++ b/versionProperties/1.20.2.properties @@ -2,7 +2,6 @@ java_version=17 minecraft_version=1.20.2 parchment_version=1.20.1:2023.09.03 -parchment_forge_version=1.20.1-2023.09.03 compatible_minecraft_versions=["1.20.2"] accessWidenerVersion=1_20_2 builds_for=fabric,forge diff --git a/versionProperties/1.20.4.properties b/versionProperties/1.20.4.properties index 74ac59e5a..315f01d8d 100644 --- a/versionProperties/1.20.4.properties +++ b/versionProperties/1.20.4.properties @@ -2,10 +2,9 @@ java_version=17 minecraft_version=1.20.4 parchment_version=1.20.2:2023.12.10 -parchment_forge_version=1.20.2-2023.12.10 compatible_minecraft_versions=["1.20.3", "1.20.4"] accessWidenerVersion=1_20_2 -builds_for=forge,fabric +builds_for=fabric,neoforge # Fabric loader fabric_loader_version=0.15.1 @@ -39,7 +38,7 @@ fabric_api_version=0.91.2+1.20.4 # (Neo)Forge loader forge_version=49.0.16 -neoforge_version=20.4.83-beta +neoforge_version=118-beta # (Neo)Forge mod versions starlight_version_forge= terraforged_version= From 03c4926b0997b4011656ff3bb8a58a7efa563a0b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 3 Feb 2024 19:45:29 -0600 Subject: [PATCH 04/23] update to latest core --- .../wrappers/block/BlockStateWrapper.java | 121 +++++++++++++++++- .../minecraft/MinecraftRenderWrapper.java | 6 - coreSubProjects | 2 +- 3 files changed, 118 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 23e635044..523d992e6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -24,7 +24,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import org.apache.logging.log4j.Logger; @@ -61,7 +64,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // must be defined before AIR, otherwise a null pointer will be thrown private static final Logger LOGGER = DhLoggerBuilder.getLogger(); - public static final ConcurrentHashMap WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>(); public static final String AIR_STRING = "AIR"; public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null); @@ -80,11 +83,13 @@ public class BlockStateWrapper implements IBlockStateWrapper public final BlockState blockState; /** technically final, but since it requires a method call to generate it can't be marked as such */ private String serialString; - /** + /** * Cached opacity value, -1 if not populated.
* Should be between {@link IBlockStateWrapper#FULLY_OPAQUE} and {@link IBlockStateWrapper#FULLY_OPAQUE} */ private int opacity = -1; + /** used by the Iris shader mod to determine how each LOD should be rendered */ + private byte irisBlockMaterialId = 0; @@ -116,7 +121,8 @@ public class BlockStateWrapper implements IBlockStateWrapper { this.blockState = blockState; this.serialString = this.serialize(levelWrapper); - LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"]"); + this.irisBlockMaterialId = this.calculateIrisBlockMaterialId(); + LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"] with material ID ["+this.irisBlockMaterialId+"]"); } @@ -125,7 +131,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // helper methods // //================// - /** + /** * Requires a {@link ILevelWrapper} since {@link BlockStateWrapper#deserialize(String,ILevelWrapper)} also requires one. * This way the method won't accidentally be called before the deserialization can be completed. */ @@ -274,6 +280,9 @@ public class BlockStateWrapper implements IBlockStateWrapper #endif } + @Override + public byte getIrisBlockMaterialId() { return this.irisBlockMaterialId; } + @Override public String toString() { return this.getSerialString(); } @@ -457,4 +466,108 @@ public class BlockStateWrapper implements IBlockStateWrapper + //==============// + // Iris methods // + //==============// + + private byte calculateIrisBlockMaterialId() + { + if (this.blockState == null) + { + return IrisBlockMaterial.AIR; + } + + + String serialString = this.getSerialString().toLowerCase(); + + if (this.blockState.is(BlockTags.LEAVES) + || serialString.contains("bamboo") + || serialString.contains("cactus") + || serialString.contains("chorus_flower") + || serialString.contains("mushroom") + ) + { + return IrisBlockMaterial.LEAVES; + } + else if (this.isLiquid() || this.blockState.is(Blocks.WATER)) + { + return IrisBlockMaterial.WATER; + } + else if (this.blockState.getSoundType() == SoundType.WOOD + || serialString.contains("root") + #if MC_VER >= MC_1_19_4 + || this.blockState.getSoundType() == SoundType.CHERRY_WOOD + #endif + ) + { + return IrisBlockMaterial.WOOD; + } + else if (this.blockState.getSoundType() == SoundType.METAL + #if MC_VER >= MC_1_19_2 + || this.blockState.getSoundType() == SoundType.COPPER + #endif + #if MC_VER >= MC_1_20_4 + || this.blockState.getSoundType() == SoundType.COPPER_BULB + || this.blockState.getSoundType() == SoundType.COPPER_GRATE + #endif + ) + { + return IrisBlockMaterial.METAL; + } + else if ( + serialString.contains("dirt") + || serialString.contains("grass_block") + || serialString.contains("gravel") + || serialString.contains("mud") + || serialString.contains("podzol") + || serialString.contains("mycelium") + ) + { + return IrisBlockMaterial.DIRT; + } + else if (this.blockState.is(Blocks.LAVA)) + { + return IrisBlockMaterial.LAVA; + } + #if MC_VER >= MC_1_17_1 + else if (this.blockState.getSoundType() == SoundType.DEEPSLATE + || this.blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS + || this.blockState.getSoundType() == SoundType.DEEPSLATE_TILES + || this.blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE + || serialString.contains("deepslate") ) + { + return IrisBlockMaterial.DEEPSLATE; + } + #endif + else if (this.serialString.contains("snow")) + { + return IrisBlockMaterial.SNOW; + } + else if (serialString.contains("sand")) + { + return IrisBlockMaterial.SAND; + } + else if (serialString.contains("terracotta")) + { + return IrisBlockMaterial.TERRACOTTA; + } + else if (this.blockState.is(BlockTags.BASE_STONE_NETHER)) + { + return IrisBlockMaterial.NETHER_STONE; + } + else if (serialString.contains("stone") + || serialString.contains("ore")) + { + return IrisBlockMaterial.STONE; + } + else if (this.blockState.getLightEmission() > 0) + { + return IrisBlockMaterial.ILLUMINATED; + } + else + { + return IrisBlockMaterial.UNKOWN; + } + } + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index 6a8ae1318..30eb60581 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -261,12 +261,6 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getTargetFrameBuffer() { - int frameBufferOverrideId = DhApiRenderProxy.INSTANCE.targetFrameBufferOverride; - if (frameBufferOverrideId != -1) - { - return frameBufferOverrideId; - } - // used so we can access the framebuffer shaders end up rendering to if (AbstractOptifineAccessor.optifinePresent()) { diff --git a/coreSubProjects b/coreSubProjects index fd80b0add..a07e43ad5 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit fd80b0adde7a545f3793729d31e6dce3254300f4 +Subproject commit a07e43ad5ce2fbb0b9107874edae600172229ed8 From a38551b3d0e4f8b06acb3cf363077fedc4d728aa Mon Sep 17 00:00:00 2001 From: Cutiepie <43445785+Ran-Mewo@users.noreply.github.com> Date: Sun, 4 Feb 2024 13:28:52 +1100 Subject: [PATCH 05/23] Disable tests for modloader projects --- build.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle b/build.gradle index fd98ce39f..be028fe31 100644 --- a/build.gradle +++ b/build.gradle @@ -134,6 +134,16 @@ subprojects { p -> tasks.withType(GenerateModuleMetadata) { enabled = false } + + // Disable testing for projects that isn't the core or api project + if (isMinecraftSubProject) { + test { + enabled = false + } + compileTestJava { + enabled = false + } + } // Set the manifold version (may not be required tough) From 794f524ae335a67013c47926f190eabc111af1d1 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 4 Feb 2024 15:52:27 -0600 Subject: [PATCH 06/23] gradle commenting and minor refactoring --- build.gradle | 99 ++++++++++++++++++++++--------------------------- settings.gradle | 10 ++--- 2 files changed, 49 insertions(+), 60 deletions(-) diff --git a/build.gradle b/build.gradle index be028fe31..da1fd718a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,29 +1,31 @@ plugins { id "java" - // Plugin to handle dependencies + // Plugin to put dependencies inside our final jar id "com.github.johnrengelman.shadow" version '7.1.2' apply false // Plugin to create merged jars id "io.github.pacifistmc.forgix" version "1.2.6" - // Manifold preprocessor -// id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" - -// // Provides mc libraries to core -// id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false - - // Use unimined which is our one in all solution to minecraft loaders + // Unimined is our all in one solution to minecraft loaders id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false } + +// Transfers the values set in settings.gradle to the rest of the project +project.gradle.ext.getProperties().each { prop -> + rootProject.ext.set(prop.key, prop.value) +// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]" +} + + /** * Creates the list of preprocessors to use. * * @param mcVers array of all MC versions * @param mcIndex array index of the currently active MC version */ -def writeBuildGradlePredefine(List mcVers, int mcIndex) +def writeBuildGradlePredefine(List mcVers, int mcIndex) { // Build the list of preprocessors to use StringBuilder sb = new StringBuilder(); @@ -31,7 +33,7 @@ def writeBuildGradlePredefine(List mcVers, int mcIndex) sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n"); - for (int i = 0; i < mcVers.size(); i++) + for (int i = 0; i < mcVers.size(); i++) { String verStr = mcVers[i].replace(".", "_"); sb.append("MC_" + verStr + "=" + i.toString() + "\n"); @@ -42,23 +44,15 @@ def writeBuildGradlePredefine(List mcVers, int mcIndex) // Check if this is a development build - if (mod_version.toLowerCase().contains("dev")) + if (mod_version.toLowerCase().contains("dev")) { // WARNING: only use this for logging, we don't want to have confusion // when a method doesn't work correctly in the release build. sb.append("DEV_BUILD=\n"); } - + new File(projectDir, "build.properties").text = sb.toString() } - - -// Transfers the values set in settings.gradle to the rest of the project -project.gradle.ext.getProperties().each { prop -> - rootProject.ext.set(prop.key, prop.value) -// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]" -} -// Sets up manifold stuff writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex) @@ -66,6 +60,7 @@ writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex) // Sets up the version string (the name we use for our jar) rootProject.versionStr = rootProject.mod_version + "-" + rootProject.minecraft_version // + "-" + new Date().format("yyyy_MM_dd_HH_mm") + // Forgix settings (used for merging jars) forgix { group = "com.seibel.distanthorizons" @@ -96,7 +91,7 @@ forgix { } subprojects { p -> - // Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverWeAddLaterOn")" + // Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverLoaderWeAddLaterOn")" // Useful later on so we dont have duplicated code def isMinecraftSubProject = p != project(":core") && p != project(":api") @@ -104,19 +99,17 @@ subprojects { p -> // Apply plugins apply plugin: "java" apply plugin: "com.github.johnrengelman.shadow" -// if (isMinecraftSubProject) -// apply plugin: "systems.manifold.manifold-gradle-plugin" - if (p == project(":core")) + if (p == project(":core")) { apply plugin: "application" -// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries + } if (p != project(":common") && isMinecraftSubProject) { apply plugin: "xyz.wagyourtail.unimined" unimined.minecraft(sourceSets.main, true) { - version minecraft_version - - def parchmentVersionParts = parchment_version.split(":") + version = rootProject.minecraft_version + + def parchmentVersionParts = rootProject.parchment_version.split(":") mappings { mojmap() parchment(parchmentVersionParts[0], parchmentVersionParts[1]) @@ -135,7 +128,8 @@ subprojects { p -> enabled = false } - // Disable testing for projects that isn't the core or api project + // Disable testing for projects that aren't the core or api project. + // If not done compiling will fail due to an issue with Manifold if (isMinecraftSubProject) { test { enabled = false @@ -144,13 +138,7 @@ subprojects { p -> enabled = false } } - - - // Set the manifold version (may not be required tough) -// manifold { -// manifoldVersion = rootProject.manifold_version -// } - + // set up custom configurations (configurations are a way to handle dependencies) configurations { @@ -211,7 +199,7 @@ subprojects { p -> implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}") implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}") - // JOML + // JOML (doesn't have to be shaded in because NightConfig already includes it) implementation("org.joml:joml:${rootProject.joml_version}") // JUnit tests @@ -230,7 +218,7 @@ subprojects { p -> shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}") // SVG (not needed atm) -// shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") + //shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") // Netty // Breaks 1.16.5 @@ -255,6 +243,7 @@ subprojects { p -> exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" exclude group: "junit", module: "junit" + // Removed dependencies transitive false } @@ -267,6 +256,7 @@ subprojects { p -> exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" exclude group: "junit", module: "junit" + // Removed dependencies transitive false } @@ -289,6 +279,7 @@ subprojects { p -> shadowJar { configurations = [project.configurations.shadowMe, project.configurations.shade] + if (isMinecraftSubProject && p != project(":common")) { configurations.push(project.configurations.shadowCommon) // Shadow the common subproject relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location @@ -298,6 +289,8 @@ subprojects { p -> relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location } } + + def librariesLocation = "distanthorizons.libraries" // LWJGL @@ -341,7 +334,7 @@ subprojects { p -> // The mixins for each of the loaders "DistantHorizons."+ p.name +".fabricLike.mixins.json" ] - def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def buildResourceTargets = ["$buildDir/resources/main/"] // Location of the built resources folder // Fix forge version numbering system as it is weird // For whatever reason forge uses [1.18, 1.18.1, 1.18.2) instead of the standard ["1.18", "1.18.1", "1.18.2"] @@ -349,7 +342,7 @@ subprojects { p -> // println compatible_forgemc_versions // Quilt's custom contributors system - // This has to be like + // has to be in the format: // "Person": "Developer", "Another person": "Developer" def quilt_contributors = [] def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",") @@ -357,9 +350,9 @@ subprojects { p -> quilt_contributors.push("\"${dev.strip()}\": \"Developer\"") } quilt_contributors.reverse() -// println quilt_contributors.join(", ") + //println quilt_contributors.join(", ") - // TODOI: Find something we can use so we can basically re-map only when the jar is shadowed and relocated + // TODO: Find something we can use so we can basically re-map only when the jar is shadowed and relocated // println p.tasks.findByName('shadowJar') @@ -374,6 +367,7 @@ subprojects { p -> println "Git or Git project not found" } + // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties def replaceProperties = [ version : mod_version, mod_name : mod_readable_name, @@ -397,15 +391,17 @@ subprojects { p -> fabric_incompatibility_list : fabric_incompatibility_list, fabric_recommend_list : fabric_recommend_list, ] - // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties - + + // replace any properties in the sub-projects with the values defined here inputs.properties replaceProperties - replaceProperties.put "project", project + replaceProperties.put("project", project) filesMatching(resourceTargets) { expand replaceProperties } - - intoTargets.each { target -> + + + // copy all our resources into the loader specific resource directory + buildResourceTargets.each { target -> if (file(target).exists()) { copy { from(sourceSets.main.resources) { @@ -462,13 +458,6 @@ subprojects { p -> } } */ - - // Run mergeJars when running build - // TODO: Fix later -// if (isMinecraftSubProject) { -// build.finalizedBy(mergeJars) -// assemble.finalizedBy(mergeJars) -// } } allprojects { p -> @@ -489,7 +478,7 @@ allprojects { p -> javadoc.title = rootProject.mod_name + "-" + project.name // Some annotations arent "technically" part of the official java standard, - // so we define it ourself here + // so we define it ourself here javadoc { configure( options ) { tags( diff --git a/settings.gradle b/settings.gradle index 983b96002..9c9cbd392 100644 --- a/settings.gradle +++ b/settings.gradle @@ -44,12 +44,13 @@ pluginManagement { } plugins { + // handles JVM and toolchain downloading id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' } -// Loads the version.properties +/** Loads the VersionProperties fiel for the currently selected Minecraft version. */ def loadProperties() { def defaultMcVersion = "1.20.1" // 1.20.1 is our current most stable version so we use that if no version was defined @@ -86,7 +87,6 @@ def loadProperties() { gradle.ext.mcVers = mcVers gradle.ext.mcIndex = mcIndex } - loadProperties() @@ -102,9 +102,9 @@ project(":api").projectDir = file('coreSubProjects/api') include("common") // Enables or disables the subprojects depending on whats in the versionProperties/mcVer.properties for (loader in ((String) gradle.builds_for).split(",")) { - def l = loader.strip() // Strip it in case a space is added before or after the comma - println "Adding loader " + l - include(l) + def loaderName = loader.strip() // Strip it in case a space is added before or after the comma + println "Adding loader " + loaderName + include(loaderName) } //if (gradle.builds_for.contains("fabric") || gradle.builds_for.contains("quilt")) // include("fabricLike") From b62af66f4b4fa6ed2e8b08fefdb418dbe4c6ec8c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 4 Feb 2024 16:30:25 -0600 Subject: [PATCH 07/23] rename shadowMe ->shadowCore and shade ->shadowMc --- build.gradle | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index da1fd718a..96c30a3b3 100644 --- a/build.gradle +++ b/build.gradle @@ -143,19 +143,19 @@ subprojects { p -> // set up custom configurations (configurations are a way to handle dependencies) configurations { // extends the shadowJar configuration - shadowMe // Configuration that contains coreProjects - shade // Configuration that doesn't contain coreProjects + shadowCore // Configuration that contains coreProjects + shadowMc // Configuration that doesn't contain coreProjects // have implemented dependencies automatically embedded in the final jar - implementation.extendsFrom(shadowMe) - implementation.extendsFrom(shade) + implementation.extendsFrom(shadowCore) + implementation.extendsFrom(shadowMc) // Add shaded libraries very early in the classpath (excluding coreProjects as that's added in a different way) - minecraftLibraries.extendsFrom(shade) + minecraftLibraries.extendsFrom(shadowMc) // Configuration fpr core & api coreProjects - shadowMe.extendsFrom(coreProjects) + shadowCore.extendsFrom(coreProjects) if (isMinecraftSubProject && p != project(":common")) { @@ -194,7 +194,7 @@ subprojects { p -> } // Log4j - // TODO: Change to shadowMe later to work in the standalone jar + // TODO: Change to shadowCore later to work in the standalone jar // We cannot do this now as it would break Quilt implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}") implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}") @@ -208,24 +208,24 @@ subprojects { p -> implementation("junit:junit:4.13") // Compression - shade("org.lz4:lz4-java:${rootProject.lz4_version}") + shadowMc("org.lz4:lz4-java:${rootProject.lz4_version}") // Sqlite Database - shade("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}") + shadowMc("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}") // NightConfig (includes Toml & Json) - shade("com.electronwill.night-config:toml:${rootProject.nightconfig_version}") - shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}") + shadowMc("com.electronwill.night-config:toml:${rootProject.nightconfig_version}") + shadowMc("com.electronwill.night-config:json:${rootProject.nightconfig_version}") // SVG (not needed atm) - //shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") + //shadowMc("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") // Netty // Breaks 1.16.5 - //shade("io.netty:netty-all:${rootProject.netty_version}") + //shadowMc("io.netty:netty-all:${rootProject.netty_version}") // Remember, for lwjgl dependencies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing - shade("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") { + shadowMc("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") { exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it } @@ -278,7 +278,7 @@ subprojects { p -> shadowJar { - configurations = [project.configurations.shadowMe, project.configurations.shade] + configurations = [project.configurations.shadowCore, project.configurations.shadowMc] if (isMinecraftSubProject && p != project(":common")) { configurations.push(project.configurations.shadowCommon) // Shadow the common subproject From 838d82589be00bdadd72ea4b51d09b8820ca06ba Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 4 Feb 2024 21:27:22 -0600 Subject: [PATCH 08/23] Fix Forge 1.20.4 compiling, but not gradle running --- forge/build.gradle | 19 ++++++++++++++++++- .../{pack.mcmeta.ignored => pack.mcmeta} | 0 versionProperties/1.20.4.properties | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) rename forge/src/main/resources/{pack.mcmeta.ignored => pack.mcmeta} (100%) diff --git a/forge/build.gradle b/forge/build.gradle index 660022115..5ed383e22 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -73,4 +73,21 @@ sourcesJar { // withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { // skip() // } -//} \ No newline at end of file +//} + + + +// TODO this was specifically added for MC 1.20.4 should it be enabled for anything below MC 1.20.4? +// source: https://github.com/MinecraftForge/MinecraftForge/blob/5d0047753dfac0caaf5d97cc3f5c9a8b0990cb44/mdk/build.gradle#L209-L217 +// +// Merge the resources and classes into the same directory. +// This is done because java expects modules to be in a single directory. +// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem +// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later. +sourceSets.each { + def dir = layout.buildDirectory.dir("sourcesSets/$it.name") + //println "source name " + it.name // as of 2024-2-4 "it.name" only returned "main" and "test" + it.output.resourcesDir = dir + it.java.destinationDirectory = dir +} + diff --git a/forge/src/main/resources/pack.mcmeta.ignored b/forge/src/main/resources/pack.mcmeta similarity index 100% rename from forge/src/main/resources/pack.mcmeta.ignored rename to forge/src/main/resources/pack.mcmeta diff --git a/versionProperties/1.20.4.properties b/versionProperties/1.20.4.properties index 315f01d8d..3efdf77f9 100644 --- a/versionProperties/1.20.4.properties +++ b/versionProperties/1.20.4.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.4 parchment_version=1.20.2:2023.12.10 compatible_minecraft_versions=["1.20.3", "1.20.4"] accessWidenerVersion=1_20_2 -builds_for=fabric,neoforge +builds_for=fabric,neoforge,forge # Fabric loader fabric_loader_version=0.15.1 From c84aac7e45ad88ed4385f9805bbdad06e5b5983c Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 11:59:02 +1030 Subject: [PATCH 09/23] Fixed resources in forge --- .gitlab-ci.yml | 4 ++++ build.gradle | 34 +++++++--------------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef07d29c4..79afe1193 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,12 +47,16 @@ build: exclude: # TODO: There is a lot of duplicate stuff here, try to maybe make it smaller - fabric/build/libs/*-all.jar + - fabric/build/libs/*-dev.jar - fabric/build/libs/*-sources.jar - quilt/build/libs/*-all.jar + - quilt/build/libs/*-dev.jar - quilt/build/libs/*-sources.jar - forge/build/libs/*-all.jar + - forge/build/libs/*-dev.jar - forge/build/libs/*-sources.jar - neoforge/build/libs/*-all.jar + - neoforge/build/libs/*-dev.jar - neoforge/build/libs/*-sources.jar expire_in: 14 days when: always diff --git a/build.gradle b/build.gradle index ac073fc65..8a319feb2 100644 --- a/build.gradle +++ b/build.gradle @@ -164,13 +164,6 @@ subprojects { p -> shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. implementation.extendsFrom common implementation.extendsFrom coreProjects - - if (findProject(":fabricLike") && p != project(":fabricLike")) { - // Shadow fabricLike - fabricLike - shadowFabricLike - implementation.extendsFrom fabricLike - } } } @@ -267,12 +260,6 @@ subprojects { p -> // Common common(project(":common")) { transitive false } shadowCommon(project(":common")) { transitive false } - - // FabricLike - if (findProject(":fabricLike") && p != project(":fabricLike")) { - fabricLike(project(path: ":fabricLike")) { transitive false } - shadowFabricLike(project(path: ":fabricLike")) { transitive false } - } } } @@ -283,11 +270,6 @@ subprojects { p -> if (isMinecraftSubProject && p != project(":common")) { configurations.push(project.configurations.shadowCommon) // Shadow the common subproject relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location - - if (findProject(":fabricLike") && p != project(":fabricLike")) { - configurations.push(project.configurations.shadowFabricLike) // Shadow the fabricLike subproject - relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location - } } @@ -324,7 +306,13 @@ subprojects { p -> // Put stuff from gradle.properties into the mod info processResources { - def resourceTargets = [ // Location of where to inject the properties + // Include all the resources + from project(":common").sourceSets.main.resources + from project(":core").sourceSets.main.resources + from project(":api").sourceSets.main.resources + + // Location of where to inject the properties + def resourceTargets = [ // Holds info like git commit // TODO: For some reason this script doesnt work with the core project "build_info.json", @@ -604,14 +592,6 @@ allprojects { p -> from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") into(file(p.file("build/resources/main"))) rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener" - - - // Move the fabricLike mixin to its different places for each subproject - if (findProject(":fabricLike")) { - from project(":fabricLike").file("src/main/resources/DistantHorizons.fabricLike.mixins.json") - into(file(p.file("build/resources/main"))) - rename "DistantHorizons.fabricLike.mixins.json", "DistantHorizons." + p.name + ".fabricLike.mixins.json" - } } task copyCoreResources(type: Copy) { From f93e648f6963666a16452ceafcd2310f5c00a302 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 12:19:34 +1030 Subject: [PATCH 10/23] Added a small error if the user forgot to clone the sub-project, and some extra comments --- build.gradle | 10 +++++++++- settings.gradle | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4ef2058ef..5cda8f19a 100644 --- a/build.gradle +++ b/build.gradle @@ -313,10 +313,17 @@ subprojects { p -> // Put stuff from gradle.properties into the mod info processResources { + duplicatesStrategy = DuplicatesStrategy.WARN // Include all the resources from project(":common").sourceSets.main.resources from project(":core").sourceSets.main.resources from project(":api").sourceSets.main.resources + + // Copy accessWideners + // FIXME: remove copyCommonLoaderResources and use this instead (and if you are removing that task, also remove copyCoreResources while your at it) +// from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") +// into(file(p.file("build/resources/main"))) +// rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener" // Location of where to inject the properties def resourceTargets = [ @@ -476,7 +483,7 @@ allprojects { p -> javadoc.title = rootProject.mod_name + "-" + project.name // Some annotations arent "technically" part of the official java standard, - // so we define it ourself here + // so we define it ourself here javadoc { configure( options ) { tags( @@ -563,6 +570,7 @@ allprojects { p -> // Set the OS lwjgl is using to the current os project.ext.lwjglNatives = "natives-" + os.toFamilyName() + // TODO: Include Minecraft in core-projects but dont include MC code stuff dependencies { // All of these dependencies are in Vanilla Minecraft, but we need to depend on it as we arent importing Minecraft in the core // Imports most of lwjgl's libraries (well, only the ones that we need) implementation platform("org.lwjgl:lwjgl-bom:${rootProject.lwjgl_version}") // TODO: Use Minecraft's version for lwjgl_version (which changes in nearly every version) instead of a hard defined version for all versions diff --git a/settings.gradle b/settings.gradle index 9c9cbd392..8579a3916 100644 --- a/settings.gradle +++ b/settings.gradle @@ -50,6 +50,21 @@ plugins { +// Throw an error and a little help message if the user forgot to clone the core sub-project +if (!file("./coreSubProjects/LICENSE.txt").exists()) { // the LICENCE.txt file should always, and only exist if the core-sub-project was cloned + println(''' +It seems that the core sub project was not included... + please make sure that when you were cloning the repo, you were using the `--recurse-submodules` flag on git. + and if its too late now to re-clone the project, please grab the core sub project in whatever way you can from https://gitlab.com/jeseibel/distant-horizons-core.git + +If you still need help with compiling, please read the Readme.md + ''') + throw new GradleException("coreSubProject not found") +} + + + + /** Loads the VersionProperties fiel for the currently selected Minecraft version. */ def loadProperties() { def defaultMcVersion = "1.20.1" // 1.20.1 is our current most stable version so we use that if no version was defined From 32a256619f5df55bcf6e7dfc4ee0dc4f328dd304 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 14:00:34 +1030 Subject: [PATCH 11/23] Fixed using wrong implementation for joml --- build.gradle | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 5cda8f19a..dc29939fd 100644 --- a/build.gradle +++ b/build.gradle @@ -192,19 +192,17 @@ subprojects { p -> implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}") implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}") - // JOML - if (project.hasProperty("embed_joml") && embed_joml == "true") - forgeShadowMe("org.joml:joml:${rootProject.joml_version}") - else - implementation("org.joml:joml:${rootProject.joml_version}") // JUnit tests implementation("org.junit.jupiter:junit-jupiter:5.8.2") implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2") implementation("junit:junit:4.13") - + // JOML - shadowMc("org.joml:joml:${rootProject.joml_version}") + if (project.hasProperty("embed_joml") && embed_joml == "true") + shadowMc("org.joml:joml:${rootProject.joml_version}") + else + implementation("org.joml:joml:${rootProject.joml_version}") // Compression shadowMc("org.lz4:lz4-java:${rootProject.lz4_version}") From 5cc7bebbe5ac22d752d89b260dfd802905102b80 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 17 Feb 2024 22:34:06 -0600 Subject: [PATCH 12/23] Update forge 1.20.4 49.0.16 -> 49.0.30 --- versionProperties/1.20.4.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versionProperties/1.20.4.properties b/versionProperties/1.20.4.properties index 3efdf77f9..0d0b115c2 100644 --- a/versionProperties/1.20.4.properties +++ b/versionProperties/1.20.4.properties @@ -37,7 +37,7 @@ fabric_api_version=0.91.2+1.20.4 enable_canvas=0 # (Neo)Forge loader -forge_version=49.0.16 +forge_version=49.0.30 neoforge_version=118-beta # (Neo)Forge mod versions starlight_version_forge= From a0935249390ddd1ae0f749cfe5babafe55304069 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 17 Feb 2024 22:34:18 -0600 Subject: [PATCH 13/23] Fix Forge 1.20.4 gradle run --- coreSubProjects | 2 +- forge/build.gradle | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index 7826d756d..045c9f46d 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 7826d756d0a882eedfb033882ade06aaf4cbf7ab +Subproject commit 045c9f46d2cb623612428ca7e9e76f0e428cf188 diff --git a/forge/build.gradle b/forge/build.gradle index 5ed383e22..2aee85b34 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -36,15 +36,25 @@ dependencies { // } } -task deleteResources(type: Delete) { - delete file("build/resources/main") -} - tasks.register('copyAllResources') { dependsOn(copyCoreResources) dependsOn(copyCommonLoaderResources) } +tasks.build.doLast { + copy { + from file("build/resources/main") + into file("build/sourcesSets/main") + } + + // TODO may not be necessary since we also do this before runClient + delete file("../common/build/libs") + delete file("../coreSubProjects/core/build/libs") + delete file("../coreSubProjects/api/build/libs") +} + + + processResources { dependsOn(tasks.named('copyAllResources')) } @@ -52,7 +62,22 @@ processResources { afterEvaluate { runClient { dependsOn(tasks.named('copyAllResources')) - finalizedBy(deleteResources) + } + + // TODO this isn't a great place for these, but `tasks.build.doLast` doesn't always work and I'm not sure of a better place right now + tasks.runClient.doFirst { + // copy the resources into the sourceSets folder so Forge can access them + copy { + from file("build/resources/main") + into file("build/sourcesSets/main") + } + + // TODO can we just ignore these folders instead? + // deleting them may cause issues if the OS locks the files + // and it feels hacky + delete file("../common/build/libs") + delete file("../coreSubProjects/core/build/libs") + delete file("../coreSubProjects/api/build/libs") } } @@ -77,7 +102,7 @@ sourcesJar { -// TODO this was specifically added for MC 1.20.4 should it be enabled for anything below MC 1.20.4? +// TODO this was specifically added for MC 1.20.4 and should probably be disabled for all MC versions below // source: https://github.com/MinecraftForge/MinecraftForge/blob/5d0047753dfac0caaf5d97cc3f5c9a8b0990cb44/mdk/build.gradle#L209-L217 // // Merge the resources and classes into the same directory. @@ -85,8 +110,9 @@ sourcesJar { // And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem // This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later. sourceSets.each { + // all of our code and resources should be in the sourceSets/main/ folder for Forge 1.20.4+ def dir = layout.buildDirectory.dir("sourcesSets/$it.name") - //println "source name " + it.name // as of 2024-2-4 "it.name" only returned "main" and "test" + println "source name: [" + it.name + "]"// as of 2024-2-4 "it.name" only returned "main" and "test" it.output.resourcesDir = dir it.java.destinationDirectory = dir } From 0c5f38a00bd739c7b160e7d3cd3fcdd2669f6685 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 16:07:51 +1030 Subject: [PATCH 14/23] Removed un-needed stuff --- build.gradle | 12 +++--------- forge/build.gradle | 39 +++++++++++++++------------------------ 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index 95947703b..748a747fd 100644 --- a/build.gradle +++ b/build.gradle @@ -118,9 +118,9 @@ subprojects { p -> } tasks.withType(JavaCompile).configureEach { - source(project(":common").sourceSets.main.allSource) - source(project(":api").sourceSets.main.allSource) - source(project(":core").sourceSets.main.allSource) + source(project(":common").sourceSets.main.java) + source(project(":api").sourceSets.main.java) + source(project(":core").sourceSets.main.java) } } @@ -192,12 +192,6 @@ subprojects { p -> implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}") implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}") - // JOML - if (project.hasProperty("embed_joml") && embed_joml == "true") - forgeShadowMe("org.joml:joml:${rootProject.joml_version}") - else - implementation("org.joml:joml:${rootProject.joml_version}") - // JUnit tests implementation("org.junit.jupiter:junit-jupiter:5.8.2") implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2") diff --git a/forge/build.gradle b/forge/build.gradle index 2aee85b34..3c79ac947 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -41,18 +41,6 @@ tasks.register('copyAllResources') { dependsOn(copyCommonLoaderResources) } -tasks.build.doLast { - copy { - from file("build/resources/main") - into file("build/sourcesSets/main") - } - - // TODO may not be necessary since we also do this before runClient - delete file("../common/build/libs") - delete file("../coreSubProjects/core/build/libs") - delete file("../coreSubProjects/api/build/libs") -} - processResources { @@ -66,12 +54,6 @@ afterEvaluate { // TODO this isn't a great place for these, but `tasks.build.doLast` doesn't always work and I'm not sure of a better place right now tasks.runClient.doFirst { - // copy the resources into the sourceSets folder so Forge can access them - copy { - from file("build/resources/main") - into file("build/sourcesSets/main") - } - // TODO can we just ignore these folders instead? // deleting them may cause issues if the OS locks the files // and it feels hacky @@ -102,7 +84,7 @@ sourcesJar { -// TODO this was specifically added for MC 1.20.4 and should probably be disabled for all MC versions below +// TODO this was specifically added for MC 1.20.4 and should not be used on MC versions prior to it // source: https://github.com/MinecraftForge/MinecraftForge/blob/5d0047753dfac0caaf5d97cc3f5c9a8b0990cb44/mdk/build.gradle#L209-L217 // // Merge the resources and classes into the same directory. @@ -110,10 +92,19 @@ sourcesJar { // And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem // This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later. sourceSets.each { - // all of our code and resources should be in the sourceSets/main/ folder for Forge 1.20.4+ - def dir = layout.buildDirectory.dir("sourcesSets/$it.name") - println "source name: [" + it.name + "]"// as of 2024-2-4 "it.name" only returned "main" and "test" - it.output.resourcesDir = dir - it.java.destinationDirectory = dir + if ( // Only run on MC 1.20.4 or later + // FIXME: Add an environment variable for the Major, Minor, and Patch version number of Minecraft + minecraft_version.split("\\.")[1].toInteger() >= 20 && + ( + minecraft_version.split("\\.").length > 1 && // Incase there isn't a minor version + minecraft_version.split("\\.")[2].toInteger() >= 4 + ) + ) { + // all of our code and resources should be in the sourceSets/main/ folder for Forge 1.20.4+ + def dir = layout.buildDirectory.dir("sourcesSets/$it.name") + println "source name: [" + it.name + "]"// as of 2024-2-4 "it.name" only returned "main" and "test" + it.output.resourcesDir = dir + it.java.destinationDirectory = dir + } } From a14748ac7547985b99659a4890263c7d3599d310 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 18:42:44 +1030 Subject: [PATCH 15/23] Fixed most of the remaining issues --- build.gradle | 29 ++++++----------------------- forge/build.gradle | 10 ---------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index 748a747fd..e72a95fb5 100644 --- a/build.gradle +++ b/build.gradle @@ -143,28 +143,13 @@ subprojects { p -> // set up custom configurations (configurations are a way to handle dependencies) configurations { // extends the shadowJar configuration - shadowCore // Configuration that contains coreProjects shadowMc // Configuration that doesn't contain coreProjects // have implemented dependencies automatically embedded in the final jar - implementation.extendsFrom(shadowCore) implementation.extendsFrom(shadowMc) // Add shaded libraries very early in the classpath (excluding coreProjects as that's added in a different way) minecraftLibraries.extendsFrom(shadowMc) - - // Configuration fpr core & api - coreProjects - shadowCore.extendsFrom(coreProjects) - - - if (isMinecraftSubProject && p != project(":common")) { - // Shadow common - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - implementation.extendsFrom common - implementation.extendsFrom coreProjects - } } @@ -234,12 +219,12 @@ subprojects { p -> // Add core if (isMinecraftSubProject) { - coreProjects(project(":core")) { + compileOnly(project(":core")) { // Remove Junit test libraries exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" exclude group: "junit", module: "junit" - + // Removed dependencies transitive false } @@ -247,12 +232,12 @@ subprojects { p -> // Add the api if (p != project(":api")) { - coreProjects(project(":api")) { + implementation(project(":api")) { // Remove Junit test libraries exclude group: "org.junit.jupiter", module: "junit-jupiter" exclude group: "org.junit.jupiter", module: "junit-jupiter-engine" exclude group: "junit", module: "junit" - + // Removed dependencies transitive false } @@ -261,17 +246,15 @@ subprojects { p -> // Add common if (isMinecraftSubProject && p != project(":common")) { // Common - common(project(":common")) { transitive false } - shadowCommon(project(":common")) { transitive false } + compileOnly(project(":common")) { transitive false } } } shadowJar { - configurations = [project.configurations.shadowCore, project.configurations.shadowMc] + configurations = [project.configurations.shadowMc] if (isMinecraftSubProject && p != project(":common")) { - configurations.push(project.configurations.shadowCommon) // Shadow the common subproject relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location } diff --git a/forge/build.gradle b/forge/build.gradle index 3c79ac947..f3b1af41d 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,16 +51,6 @@ afterEvaluate { runClient { dependsOn(tasks.named('copyAllResources')) } - - // TODO this isn't a great place for these, but `tasks.build.doLast` doesn't always work and I'm not sure of a better place right now - tasks.runClient.doFirst { - // TODO can we just ignore these folders instead? - // deleting them may cause issues if the OS locks the files - // and it feels hacky - delete file("../common/build/libs") - delete file("../coreSubProjects/core/build/libs") - delete file("../coreSubProjects/api/build/libs") - } } remapJar { From ee922236a0f15b87057e9ebc3e90582c58f861c7 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 19:12:49 +1030 Subject: [PATCH 16/23] Fixed forge version in readme for this branch --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 187478a33..e0bd02a50 100644 --- a/Readme.md +++ b/Readme.md @@ -23,8 +23,8 @@ If you want to see a quick demo, check out a video covering the mod here: #### 1.20.4, 1.20.3 (Default) Fabric: 0.15.1\ Fabric API: 0.91.2+1.20.4\ -Forge: 49.0.16\ -NeoForge: 20.4.83-beta\ +Forge: 49.0.30\ +NeoForge: 118-beta\ Parchment: 1.20.2:2023.12.10\ Modmenu: 9.0.0-pre.1 From d0dc3ec9bcda5624bb0c7b77fef699271dc47eff Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 20:11:15 +1030 Subject: [PATCH 17/23] Added the new unimined flag to fix fabric's access wideners --- build.gradle | 2 +- fabric/build.gradle | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e72a95fb5..c2a3a898b 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { id "io.github.pacifistmc.forgix" version "1.2.6" // Unimined is our all in one solution to minecraft loaders - id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false + id "xyz.wagyourtail.unimined" version "1.1.2-SNAPSHOT" apply false } diff --git a/fabric/build.gradle b/fabric/build.gradle index 342f7704c..1e0a557bb 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -2,6 +2,8 @@ unimined.minecraft { fabric { loader rootProject.fabric_loader_version accessWidener(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")) + + skipInsertAw = true } } From 4d73c3ecb89df49b8b8b1725286214d2d011b275 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 21:09:00 +1030 Subject: [PATCH 18/23] Moved common to Unimined --- build.gradle | 17 +++++++++-------- common/build.gradle | 40 ++++++++++++---------------------------- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index c2a3a898b..56f3e0443 100644 --- a/build.gradle +++ b/build.gradle @@ -91,7 +91,7 @@ forgix { } subprojects { p -> - // Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverLoaderWeAddLaterOn")" + // Does the same as "p == project(":common") || p == project(":fabric") || p == project(":forge") || p == project("WhateverLoaderWeAddLaterOn")" // Useful later on so we dont have duplicated code def isMinecraftSubProject = p != project(":core") && p != project(":api") @@ -99,11 +99,10 @@ subprojects { p -> // Apply plugins apply plugin: "java" apply plugin: "com.github.johnrengelman.shadow" - if (p == project(":core")) { + if (p == project(":core")) apply plugin: "application" - } - if (p != project(":common") && isMinecraftSubProject) { + if (isMinecraftSubProject) { apply plugin: "xyz.wagyourtail.unimined" unimined.minecraft(sourceSets.main, true) { @@ -117,10 +116,12 @@ subprojects { p -> } } - tasks.withType(JavaCompile).configureEach { - source(project(":common").sourceSets.main.java) - source(project(":api").sourceSets.main.java) - source(project(":core").sourceSets.main.java) + if (p != project(":common")) { + tasks.withType(JavaCompile).configureEach { + source(project(":common").sourceSets.main.java) + source(project(":api").sourceSets.main.java) + source(project(":core").sourceSets.main.java) + } } } diff --git a/common/build.gradle b/common/build.gradle index b61221fda..d4bf54ebe 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,32 +1,16 @@ -plugins { - id "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT" -} +// Use Unimined's implimentation for MC as we can use Parchment mappings in common now! :tada: +// With Sponge's vanilla gradle, we cannot change the mappings to anything out of mojmaps +unimined.minecraft { + fabric { // TODO: Find a way to only include the mc stuff, not fabric's loader + loader rootProject.fabric_loader_version + accessWidener(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")) -minecraft { - accessWideners(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")) - version(rootProject.minecraft_version) + skipInsertAw = true + } + + defaultRemapJar = false } dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader -// modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - - // So mixins can be written in common - compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5' -} - - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.mod_readable_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} + +} \ No newline at end of file From 4e6255dc2b72ed1f952b32966442a44353a1a4e1 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Feb 2024 21:38:20 +1030 Subject: [PATCH 19/23] Re-added jank file deleting again for now --- forge/build.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/forge/build.gradle b/forge/build.gradle index f3b1af41d..3c79ac947 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,6 +51,16 @@ afterEvaluate { runClient { dependsOn(tasks.named('copyAllResources')) } + + // TODO this isn't a great place for these, but `tasks.build.doLast` doesn't always work and I'm not sure of a better place right now + tasks.runClient.doFirst { + // TODO can we just ignore these folders instead? + // deleting them may cause issues if the OS locks the files + // and it feels hacky + delete file("../common/build/libs") + delete file("../coreSubProjects/core/build/libs") + delete file("../coreSubProjects/api/build/libs") + } } remapJar { From 0146d62c2a53554b59b51800be3540ca0f2fb17b Mon Sep 17 00:00:00 2001 From: coolGi Date: Mon, 19 Feb 2024 23:19:53 +1030 Subject: [PATCH 20/23] Moved AT to only appear in final build, not in the source code --- build.gradle | 4 ++++ forge/build.gradle | 5 ++++- neoforge/build.gradle | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 56f3e0443..1a80a4fae 100644 --- a/build.gradle +++ b/build.gradle @@ -584,12 +584,16 @@ allprojects { p -> } + // TODO: Remove this as no loader needs this + // - Fabric can rename which aw they use + // - (Neo)Forge converts the aw to their own at, which is stored at a different place task copyCommonLoaderResources(type: Copy) { from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") into(file(p.file("build/resources/main"))) rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener" } + // TODO: Remove this later as we no longer need this. We are now including the resources in the processResources section task copyCoreResources(type: Copy) { from fileTree(project(":core").file("src/main/resources")) into p.file("build/resources/main") diff --git a/forge/build.gradle b/forge/build.gradle index 3c79ac947..16bfa5045 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -2,7 +2,10 @@ unimined.minecraft { minecraftForge { loader forge_version mixinConfig("DistantHorizons.forge.mixins.json") - accessTransformer(aw2at(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))) + accessTransformer(aw2at( + project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), + file("build/sourcesSets/main/META-INF/accesstransformer.cfg") // We'd wanna output the access transformer to somewhere where it'll only appear in the final jar + )) } } diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 31700a31b..d7f64e826 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -2,7 +2,10 @@ unimined.minecraft { neoForged { loader neoforge_version mixinConfig("DistantHorizons.neoforge.mixins.json") - accessTransformer(aw2at(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))) + accessTransformer(aw2at( + project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), + file("build/sourcesSets/main/META-INF/accesstransformer.cfg") // We'd wanna output the access transformer to somewhere where it'll only appear in the final jar + )) } } From 4d038fc5e615fc3e5c3901fd74ce09642d6acd4b Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 20 Feb 2024 00:51:25 +1030 Subject: [PATCH 21/23] Fixed up AT --- build.gradle | 2 +- forge/build.gradle | 2 ++ neoforge/build.gradle | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 1a80a4fae..0a371783c 100644 --- a/build.gradle +++ b/build.gradle @@ -304,7 +304,7 @@ subprojects { p -> // FIXME: remove copyCommonLoaderResources and use this instead (and if you are removing that task, also remove copyCoreResources while your at it) // from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") // into(file(p.file("build/resources/main"))) -// rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener" + rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener" // Location of where to inject the properties def resourceTargets = [ diff --git a/forge/build.gradle b/forge/build.gradle index 16bfa5045..18ae90bde 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -2,6 +2,8 @@ unimined.minecraft { minecraftForge { loader forge_version mixinConfig("DistantHorizons.forge.mixins.json") + + file("build/sourcesSets/main/META-INF/").mkdirs() accessTransformer(aw2at( project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), file("build/sourcesSets/main/META-INF/accesstransformer.cfg") // We'd wanna output the access transformer to somewhere where it'll only appear in the final jar diff --git a/neoforge/build.gradle b/neoforge/build.gradle index d7f64e826..5703ea19f 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -2,8 +2,10 @@ unimined.minecraft { neoForged { loader neoforge_version mixinConfig("DistantHorizons.neoforge.mixins.json") + + file("build/sourcesSets/main/META-INF/").mkdirs() accessTransformer(aw2at( - project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), + project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"), file("build/sourcesSets/main/META-INF/accesstransformer.cfg") // We'd wanna output the access transformer to somewhere where it'll only appear in the final jar )) } From 4290cdf8c6cd3b0fec4e375048caccd9c77cf025 Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 20 Feb 2024 00:51:41 +1030 Subject: [PATCH 22/23] Changed run dir to the root of the project --- build.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle b/build.gradle index 0a371783c..ee19ae497 100644 --- a/build.gradle +++ b/build.gradle @@ -114,6 +114,16 @@ subprojects { p -> parchment(parchmentVersionParts[0], parchmentVersionParts[1]) devNamespace "mojmap" } + + runs { + config("client") { + workingDir = rootProject.file("run") + } + config("server") { + workingDir = rootProject.file("run") // TODO: When running the server, would it be a better idea to change this to a different dir? + disabled = true // TODO: Once server-side support is added, remove this + } + } } if (p != project(":common")) { From 004059dd9fffac7d322db2f71a1c38867a725f9d Mon Sep 17 00:00:00 2001 From: coolGi Date: Thu, 22 Feb 2024 22:10:34 +1030 Subject: [PATCH 23/23] Removed mixins from neoforge's mods.toml --- build.gradle | 3 ++- neoforge/src/main/resources/META-INF/mods.toml | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ee19ae497..9cfcb809c 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,8 @@ plugins { id "io.github.pacifistmc.forgix" version "1.2.6" // Unimined is our all in one solution to minecraft loaders - id "xyz.wagyourtail.unimined" version "1.1.2-SNAPSHOT" apply false +// id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false // Unstable Release (TODO: Check back to see when the unstable branch fixes forge run without the jank) + id "xyz.wagyourtail.unimined" version "1.1.2-SNAPSHOT" apply false // LTS Release } diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index dd5a9fa74..2a295c5ad 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -23,10 +23,9 @@ issueTrackerURL = "${issues}" #// Allow any version to be present (or not) on the server acceptableRemoteVersions = "*" -# TODO: Once there is a way to move this to the `META-INF/MANIFEST.MF` with architectury, DO SO! -# (currently, this only works cus neoforge's mods.toml is added to the jar after forge's mods.toml, so this can work -[[mixins]] - config = "DistantHorizons.neoforge.mixins.json" +# We may need this to make forge (lexforge) & neoforge work together +#[[mixins]] +# config = "DistantHorizons.neoforge.mixins.json" [[dependencies.distanthorizons]] modId = "minecraft"