Skip to content

Commit 2c329d1

Browse files
committed
feat: Shadowable deploader
1 parent 1adafe5 commit 2c329d1

File tree

23 files changed

+2171
-1137
lines changed

23 files changed

+2171
-1137
lines changed

build.gradle.kts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,88 @@ minecraft_fp {
4747
}
4848
}
4949

50+
val java8Compiler = javaToolchains.compilerFor {
51+
languageVersion = JavaLanguageVersion.of(8)
52+
vendor = JvmVendorSpec.ADOPTIUM
53+
}
54+
55+
fun createSourceSet(name: String, shareDeps: Boolean): SourceSet {
56+
val set = sourceSets.create(name) {
57+
if (shareDeps) {
58+
compileClasspath += sourceSets["patchedMc"].output
59+
}
60+
}
61+
tasks.named<JavaCompile>(set.compileJavaTaskName).configure {
62+
javaCompiler = java8Compiler
63+
}
64+
afterEvaluate {
65+
tasks.named<JavaCompile>(set.compileJavaTaskName).configure {
66+
this.sourceCompatibility = "8"
67+
this.targetCompatibility = "8"
68+
this.options.release = null
69+
}
70+
}
71+
if (shareDeps) {
72+
73+
configurations.named(set.compileClasspathConfigurationName) {
74+
extendsFrom(configurations.getByName("compileClasspath"))
75+
exclude("com.falsepattern", "falsepatternlib-mc1.7.10")
76+
}
77+
configurations.named(set.runtimeClasspathConfigurationName) {
78+
extendsFrom(configurations.getByName("runtimeClasspath"))
79+
exclude("com.falsepattern", "falsepatternlib-mc1.7.10")
80+
}
81+
configurations.named(set.annotationProcessorConfigurationName) {
82+
extendsFrom(configurations.getByName("annotationProcessor"))
83+
exclude("com.falsepattern", "falsepatternlib-mc1.7.10")
84+
}
85+
}
86+
87+
return set
88+
}
89+
90+
val depLoader = createSourceSet("deploader", true)
91+
92+
val depLoaderJar = tasks.register<Jar>(depLoader.jarTaskName) {
93+
from(depLoader.output)
94+
archiveBaseName = "falsepatternlib-mc1.7.10"
95+
archiveVersion = minecraft_fp.mod.version
96+
archiveClassifier = "deploader"
97+
manifest {
98+
attributes("FPLib-Deploader-Version" to "1")
99+
}
100+
}
101+
102+
val depLoaderStub = createSourceSet("deploaderStub", true)
103+
104+
val depLoaderStubJar = tasks.register<Jar>(depLoaderStub.jarTaskName) {
105+
from(depLoaderStub.output)
106+
archiveBaseName = "falsepatternlib-mc1.7.10"
107+
archiveVersion = minecraft_fp.mod.version
108+
archiveClassifier = "deploader_stub"
109+
}
110+
111+
sourceSets["main"].compileClasspath += depLoader.output
112+
sourceSets["main"].compileClasspath += depLoaderStub.output
113+
114+
afterEvaluate {
115+
for (outgoingConfig in listOf("runtimeElements", "apiElements")) {
116+
val outgoing = configurations.getByName(outgoingConfig)
117+
outgoing.outgoing.artifact(depLoaderStubJar)
118+
outgoing.outgoing.artifact(depLoaderJar)
119+
}
120+
}
121+
122+
tasks.jar {
123+
dependsOn(depLoaderJar, depLoaderStubJar)
124+
from(depLoaderJar.map { it.archiveFile }) {
125+
rename { "fplib_deploader.jar" }
126+
}
127+
from(zipTree(depLoaderStubJar.map { it.archiveFile })) {
128+
exclude("META-INF/MANIFEST.MF")
129+
}
130+
}
131+
50132
repositories {
51133
exclusive(maven("horizon", "https://mvn.falsepattern.com/horizon/"), "com.gtnewhorizons.retrofuturabootstrap")
52134
exclusive(horizon()) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* This file is part of FalsePatternLib.
3+
*
4+
* Copyright (C) 2022-2025 FalsePattern
5+
* All Rights Reserved
6+
*
7+
* The above copyright notice and this permission notice shall be included
8+
* in all copies or substantial portions of the Software.
9+
*
10+
* FalsePatternLib is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Lesser General Public License as published by
12+
* the Free Software Foundation, only version 3 of the License.
13+
*
14+
* FalsePatternLib is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public License
20+
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
21+
*/
22+
23+
package com.falsepattern.deploader;
24+
25+
import com.gtnewhorizons.retrofuturabootstrap.RfbApiImpl;
26+
import lombok.val;
27+
28+
import net.minecraft.launchwrapper.Launch;
29+
import cpw.mods.fml.relauncher.FMLLaunchHandler;
30+
import cpw.mods.fml.relauncher.Side;
31+
32+
import java.net.URLClassLoader;
33+
import java.nio.file.Path;
34+
35+
public class Bootstrap {
36+
public static Path MINECRAFT_HOME_PATH;
37+
38+
public static void bootstrap(boolean rfb, Path homePath) {
39+
MINECRAFT_HOME_PATH = homePath;
40+
if (rfb) {
41+
val loader = RfbApiImpl.INSTANCE.launchClassLoader();
42+
PreShare.initDevState(((URLClassLoader)loader).findResource("net/minecraft/world/World.class") != null);
43+
PreShare.initClientState(((URLClassLoader)loader).findResource("net/minecraft/client/Minecraft.class") != null ||
44+
((URLClassLoader)loader).findResource("bao.class") != null);
45+
LowLevelCallMultiplexer.rfbDetected();
46+
} else {
47+
PreShare.initDevState(Launch.classLoader.findResource("net/minecraft/world/World.class") != null);
48+
PreShare.initClientState(FMLLaunchHandler.side() == Side.CLIENT);
49+
}
50+
LetsEncryptHelper.replaceSSLContext();
51+
}
52+
53+
public static void runDepLoader() {
54+
DependencyLoaderImpl.executeDependencyLoading();
55+
}
56+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
2121
*/
2222

23-
package com.falsepattern.lib.internal.impl.dependencies;
23+
package com.falsepattern.deploader;
2424

2525
import com.google.gson.annotations.Expose;
2626
import lombok.Data;

0 commit comments

Comments
 (0)