Skip to content

Commit

Permalink
Add Forge implementation of Forge Config API Port
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Nov 26, 2023
1 parent cac6559 commit bf94a0a
Show file tree
Hide file tree
Showing 16 changed files with 1,103 additions and 11 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ A Forge port of the Fabric [Amecs API](https://github.com/Siphalor/amecs-api)
library, implemented alongside Forge's key modifier system. Allows for compatiblity with Fabric mods that require it,
but wouldn't otherwise be compatible due to the heavy forge mixin conflicts of the original version.

### Forge Config API Port - Forge bridge

A clean implementation of [Forge Config API Port](https://www.curseforge.com/minecraft/mc-mods/forge-config-api-port-fabric)
on Forge, allowing Fabric mods to easily access the Forge config system and register their own configs.
Includes the [Forge Config API Port API](https://github.com/Fuzss/forgeconfigapiport/tree/8dbbc0d49afb46928a1dfc0c7f828af06da1638d/Fabric/src/main/java/fuzs/forgeconfigapiport/api/config/v2),
licensed under the MPL-2.0 license.

## Get help

If you're having trouble using Connector Extras or believe it is not functioning correctly, ask us
Expand Down
23 changes: 14 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.gradle.jvm.tasks.Jar
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import kotlin.io.path.deleteExisting
import kotlin.io.path.exists

plugins {
java
Expand Down Expand Up @@ -93,6 +95,7 @@ dependencies {
includeProject("modmenu-bridge")
includeProject("continuity-compat")
includeProject("amecs-api")
includeProject("forgeconfigapiport")

// Misc
modImplementation("curse.maven:mcpitanlibarch-682213:4723157")
Expand Down Expand Up @@ -129,16 +132,18 @@ val relocateNestedJars by tasks.registering {
doLast {
FileSystemUtil.getJarFileSystem(archiveFile.get().asFile.toPath(), false).use { fs ->
val sourceDirectory = fs.getPath("META-INF", "jars")
val destinationDirectory = fs.getPath("META-INF", "jarjar")
Files.newDirectoryStream(sourceDirectory).forEach { path ->
Files.move(path, destinationDirectory.resolve(path.fileName), StandardCopyOption.COPY_ATTRIBUTES)
if (sourceDirectory.exists()) {
val destinationDirectory = fs.getPath("META-INF", "jarjar")
Files.newDirectoryStream(sourceDirectory).forEach { path ->
Files.move(path, destinationDirectory.resolve(path.fileName), StandardCopyOption.COPY_ATTRIBUTES)
}
sourceDirectory.deleteExisting()

val metadata = fs.getPath("META-INF", "jarjar", "metadata.json")
val text = Files.readString(metadata, StandardCharsets.UTF_8)
val replaced = text.replace("META-INF/jars/", "META-INF/jarjar/")
Files.writeString(metadata, replaced, StandardCharsets.UTF_8)
}
Files.delete(sourceDirectory)

val metadata = fs.getPath("META-INF", "jarjar", "metadata.json")
val text = Files.readString(metadata, StandardCharsets.UTF_8)
val replaced = text.replace("META-INF/jars/", "META-INF/jarjar/")
Files.writeString(metadata, replaced, StandardCharsets.UTF_8)
}
}
}
Expand Down
Loading

0 comments on commit bf94a0a

Please sign in to comment.