Skip to content

Commit

Permalink
Fabric support #9. New asset index handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Lassebq committed Aug 23, 2024
1 parent 041c59d commit f8867ea
Show file tree
Hide file tree
Showing 33 changed files with 1,549 additions and 241 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ nbproject
.*.sw[a-p]

# various other potential build files
/build/
/out
build/
out

# Mac filesystem dust
.DS_Store
Expand All @@ -28,5 +28,5 @@ nbproject
.idea/

# generated
/repo/
/bin/
repo/
bin/
117 changes: 60 additions & 57 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,35 +1,76 @@
plugins {
id 'java'
id 'maven-publish'
}
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'

version = '1.0-SNAPSHOT'

repositories {
flatDir {
dirs "libs"
}
maven {
url "https://mcphackers.github.io/libraries/"
}
maven {
url "https://libraries.minecraft.net/"
}
mavenCentral()
}

repositories {
flatDir {
dirs "libs"
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
maven {
url "https://mcphackers.github.io/libraries/"

artifacts {
archives jar
archives sourcesJar
}
maven {
url "https://libraries.minecraft.net/"

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = archivesBaseName

artifact jar
artifact sourcesJar
}
}

repositories {
mavenLocal()

def ENV = System.getenv()
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
if (ENV.MAVEN_USERNAME) {
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
}
}
}
mavenCentral()

}

group = 'org.mcphackers'
archivesBaseName = 'launchwrapper'
version = '1.0-SNAPSHOT'
sourceCompatibility = 1.5
targetCompatibility = 1.5
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

project.ext.asm_version = 9.6

dependencies {
implementation 'org.mcphackers.rdi:rdi:1.0'
implementation 'org.ow2.asm:asm:9.3'
implementation 'org.ow2.asm:asm-tree:9.3'
implementation "org.ow2.asm:asm:${project.asm_version}"
implementation "org.ow2.asm:asm-tree:${project.asm_version}"
implementation 'org.json:json:20230311'
// I'll bring discord RPC support later, when I have an environment to compile natives

// testImplementation 'junit:junit:4.12'
testRuntimeOnly('org.junit.platform:junit-platform-launcher:1.5.2')
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.0'
}
Expand All @@ -41,42 +82,4 @@ test {
events = ["passed", "failed", "skipped"]
showStandardStreams = true
}
}

task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives jar
archives sourcesJar
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = archivesBaseName

artifact jar
artifact sourcesJar
}
}

repositories {
mavenLocal()

def ENV = System.getenv()
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
if (ENV.MAVEN_USERNAME) {
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
}
}
}
}
25 changes: 25 additions & 0 deletions launchwrapper-fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'java'
apply plugin: 'maven-publish'

repositories {
maven {
url "https://maven.fabricmc.net/"
}
maven {
url "https://maven.glass-launcher.net/babric/"
}
mavenCentral()
}

archivesBaseName = 'launchwrapper-fabric'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
implementation rootProject
implementation "babric:fabric-loader:0.14.24-babric.1"
implementation 'org.mcphackers.rdi:rdi:1.0'
implementation "org.ow2.asm:asm:${project.asm_version}"
implementation "org.ow2.asm:asm-tree:${project.asm_version}"
implementation "org.ow2.asm:asm-util:${project.asm_version}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.mcphackers.launchwrapper.fabric;

import java.security.CodeSource;

import org.mcphackers.launchwrapper.Launch;
import org.mcphackers.launchwrapper.LaunchConfig;

public class FabricBridge extends Launch {
private static final String FABRIC_KNOT_CLIENT = "net/fabricmc/loader/impl/launch/knot/KnotClient";
private static final String FABRIC_KNOT = "net/fabricmc/loader/impl/launch/knot/Knot";

private static FabricBridge INSTANCE;

protected FabricBridge(LaunchConfig config) {
super(config);
INSTANCE = this;
}

private static String gameProdiverSource() {
// Location of META-INF/services/net.fabricmc.loader.impl.game.GameProvider
CodeSource resource = FabricBridge.class.getProtectionDomain().getCodeSource();
if(resource == null) {
return null;
}
System.out.println("[LaunchWrapper] Fabric compat jar: " + resource.getLocation().getPath());
return resource.getLocation().getPath();
}

public static void main(String[] args) {
LaunchConfig config = new LaunchConfig(args);
create(config).launch();
}

public void launch() {
CLASS_LOADER.overrideClassSource(FABRIC_KNOT, gameProdiverSource());
CLASS_LOADER.overrideClassSource(FABRIC_KNOT_CLIENT, gameProdiverSource());
CLASS_LOADER.invokeMain(FABRIC_KNOT_CLIENT, config.getArgs());
}

public static FabricBridge getInstance() {
return INSTANCE;
}

public static FabricBridge create(LaunchConfig config) {
return new FabricBridge(config);
}

}
Loading

0 comments on commit f8867ea

Please sign in to comment.