Skip to content

Commit 42940a8

Browse files
committed
Start 1.8/1.12 branch
Signed-off-by: Florian Reuth <git@florianreuth.de>
1 parent 6d3c861 commit 42940a8

File tree

191 files changed

+1077
-8708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+1077
-8708
lines changed

build.gradle

Lines changed: 78 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,18 @@ allprojects {
9494
library "com.viaversion:viabackwards-common:5.8.0"
9595
library "com.viaversion:viarewind-common:4.0.15"
9696
library "com.viaversion:viaaprilfools-common:4.1.0"
97-
library ("net.raphimc:ViaLegacy:3.0.14") {
97+
library("net.raphimc:ViaLegacy:3.0.14") {
9898
exclude group: "com.google.code.gson", module: "gson"
9999
}
100100
}
101101
}
102102

103103
subprojects {
104-
apply plugin: "net.minecraftforge.gradle"
105-
apply plugin: "org.spongepowered.mixin"
104+
def applyFg = project.hasProperty("applyFg") ? Boolean.parseBoolean(project.applyFg) : true
105+
if (applyFg) {
106+
apply plugin: "net.minecraftforge.gradle"
107+
apply plugin: "org.spongepowered.mixin"
108+
}
106109
apply plugin: "me.modmuss50.mod-publish-plugin"
107110

108111
// Define the jar output attributes for all platforms
@@ -120,79 +123,56 @@ subprojects {
120123
// Used to execute code only for specific submodules
121124
def versionId = Integer.parseInt(mcVersion.replace(".", ""))
122125

123-
// Java 17 is default, set newer versions here
124-
if (versionId >= 1_20_6) {
125-
compileJava.setSourceCompatibility("21")
126-
compileJava.setTargetCompatibility("21")
127-
}
128126
compileJava.options.encoding = "UTF-8"
129127

130128
dependencies {
131129
library project(":") // Include the base project
132130
}
133131

134-
minecraft {
135-
// Unify to mojang mappings for 1.14+, MCP for below
136-
if (versionId >= 1_16_5) {
137-
mappings channel: "official", version: mcVersion
138-
}
139-
140-
// Official mappings at runtime for 1.20.5+
141-
if (versionId >= 1_20_5) {
142-
reobf = false
143-
}
144-
145-
runs {
146-
client {
147-
workingDirectory project.file("run")
148-
149-
property "forge.logging.markers", "REGISTRIES"
150-
property "forge.logging.console.level", "debug"
151-
152-
// mixin
153-
property "mixin.debug.export", "true"
154-
property "mixin.hotSwap", "true"
155-
property "fml.coreMods.load", "com.viaversion.viaforge.mixin.MixinLoader"
156-
// Only required for MC 1.12, but modern Forges skips this anyway
157-
args "-mixin.config=" + "mixins.viaforge.json"
158-
159-
// source set
160-
mods {
161-
"${project.name}" {
162-
source sourceSets.main
132+
if (applyFg) {
133+
minecraft {
134+
runs {
135+
client {
136+
workingDirectory project.file("run")
137+
138+
property "forge.logging.markers", "REGISTRIES"
139+
property "forge.logging.console.level", "debug"
140+
141+
// mixin
142+
property "mixin.debug.export", "true"
143+
property "mixin.hotSwap", "true"
144+
property "fml.coreMods.load", "com.viaversion.viaforge.mixin.MixinLoader"
145+
// Only required for MC 1.12, but modern Forges skips this anyway
146+
args "-mixin.config=" + "mixins.viaforge.json"
147+
148+
// source set
149+
mods {
150+
"${project.name}" {
151+
source sourceSets.main
152+
}
163153
}
164154
}
165155
}
166156
}
167-
}
168157

169-
sourceSets.main.resources {
170-
srcDir "src/generated/resources"
171-
}
172-
173-
dependencies {
174-
minecraft "net.minecraftforge:forge:${forge_version}"
175-
library "org.slf4j:slf4j-api:2.0.17"
176-
177-
if (versionId >= 1_16_5 && versionId < 1_20_6) {
178-
// Always include for refmap in versions that don't have official mappings at runtime,
179-
// later exclude classes to prevent loading conflicts...
180-
library "org.spongepowered:mixin:${mixin_version}"
181-
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
158+
sourceSets.main.resources {
159+
srcDir "src/generated/resources"
182160
}
183161

184-
if (versionId >= 1_20_6) {
185-
// NeoForge, only to compile against
186-
compileOnly("net.neoforged.fancymodloader:loader:2.0.20") { transitive = false }
187-
compileOnly("net.neoforged:bus:8.0.5") { transitive = false }
162+
dependencies {
163+
minecraft "net.minecraftforge:forge:${forge_version}"
164+
165+
if (versionId > 1_8_9) {
166+
library "org.slf4j:slf4j-api:2.0.17"
167+
library "org.spongepowered:mixin:${mixin_version}"
168+
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
169+
}
188170
}
189-
}
190171

191-
mixin {
192-
add sourceSets.main, "mixins.viaforge.refmap.json"
193-
}
172+
mixin {
173+
add sourceSets.main, "mixins.viaforge.refmap.json"
174+
}
194175

195-
if (versionId < 1_20_6) { // Use official mappings at runtime, otherwise re-obfuscate output
196176
reobf {
197177
shadowJar {}
198178
}
@@ -239,25 +219,12 @@ subprojects {
239219
}
240220

241221
shadowJar {
242-
if (versionId >= 1_17_1) {
243-
archiveFileName = jar.archiveFileName
244-
} else {
245-
destinationDirectory = temporaryDir
246-
}
222+
destinationDirectory = temporaryDir
247223
configurations = [project.configurations.library] // Include the dependencies from the include configuration
248224
duplicatesStrategy DuplicatesStrategy.EXCLUDE
249225

250226
// Prevent conflicts with Forge's weird service loading
251227
exclude("META-INF/maven/**")
252-
if (versionId >= 1_13_2) {
253-
// We don't need to package mixins into Forge 1.13+ jars, since Forge already has it
254-
exclude("org/spongepowered/**")
255-
}
256-
if (versionId >= 1_16_5) {
257-
// Get rid of the services folder, since Forge 1.16+ would conflict with some of the ForgeDev Environment's services
258-
// And since we don't need them for Mixins anyway, we can just exclude them from the shadowJar
259-
exclude("META-INF/services/**")
260-
}
261228

262229
// Workaround GH-94
263230
relocate("org.slf4j", "com.viaversion.viaforge.libs.slf4j")
@@ -269,23 +236,49 @@ subprojects {
269236
logLevel = "FATAL"
270237
}
271238

239+
if (!applyFg) {
240+
afterEvaluate {
241+
// Unimined creates remap tasks later; pick the remapped archive task dynamically.
242+
def remapArchiveTask = tasks.findAll {
243+
it.name.toLowerCase().contains("remap") && it.hasProperty("archiveFile")
244+
}.sort { it.name }.find { it.name.toLowerCase().contains("shadow") } ?: tasks.findAll {
245+
it.name.toLowerCase().contains("remap") && it.hasProperty("archiveFile")
246+
}.sort { it.name }.find()
247+
248+
if (remapArchiveTask == null) {
249+
throw new GradleException("No remap archive task found for ${project.path}")
250+
}
251+
252+
tasks.named("downgradeJar") {
253+
dependsOn(remapArchiveTask)
254+
inputFile = remapArchiveTask.archiveFile
255+
}
256+
257+
// remapJar (from the dev jar) can overwrite the release artifact path in build/libs.
258+
def remapDevJarTask = tasks.findByName("remapJar")
259+
if (remapDevJarTask != null) {
260+
remapDevJarTask.enabled = false
261+
}
262+
263+
tasks.matching { it.name == "publishCurseforge" || it.name == "publishModrinth" || it.name == "publishMods" }.configureEach {
264+
dependsOn(remapArchiveTask)
265+
dependsOn(tasks.named("shadeDowngradedApi"))
266+
}
267+
}
268+
}
269+
272270
shadeDowngradedApi {
273-
archiveFileName = jar.archiveFileName
271+
// Keep publish artifact stable across toolchains; Unimined jar names can carry a -dev classifier.
272+
archiveFileName = "${project.name}-${project.version}.jar"
274273
logLevel = "FATAL"
275274
}
276275

277276
jar.dependsOn("shadowJar")
278-
if (versionId < 1_17_1) {
279-
// Downgrade the jar to Java 8 for Minecraft 1.16.5 and below
280-
jar.dependsOn("shadeDowngradedApi")
281-
}
277+
// Downgrade the jar to Java 8 for Minecraft 1.16.5 and below
278+
jar.dependsOn("shadeDowngradedApi")
282279

283280
publishMods {
284-
if (versionId < 1_17_1) { // FG's reobfuscation will rename the jar in place, so use the one *before* finalizing the jar
285-
file = tasks.shadeDowngradedApi.archiveFile
286-
} else {
287-
file = tasks.shadowJar.archiveFile
288-
}
281+
file = tasks.shadeDowngradedApi.archiveFile
289282
def commitHash = latestCommitHash(rootProject)
290283
def commitMessage = latestCommitMessage(rootProject).replaceAll("\\s+", " ").trim()
291284
if (commitHash == "unknown" || commitMessage == "unknown") {
@@ -296,22 +289,13 @@ subprojects {
296289
version = project.version.toString() + "+" + mcVersion
297290
displayName = version
298291
modLoaders.add("forge")
299-
if (versionId == 1_20_1 || versionId >= 1_20_6) {
300-
modLoaders.add("neoforge")
301-
}
302292
type = ReleaseType.ALPHA
303293

304294
curseforge {
305295
accessToken = System.getenv("CURSEFORGE_TOKEN")
306296
projectId = "418933"
307297

308-
if (versionId < 1_17_1) {
309-
javaVersions.add(JavaVersion.VERSION_1_8)
310-
} else if (versionId < 1_20_6) {
311-
javaVersions.add(JavaVersion.VERSION_17)
312-
} else {
313-
javaVersions.add(JavaVersion.VERSION_21)
314-
}
298+
javaVersions.add(JavaVersion.VERSION_1_8)
315299
minecraftVersions.add(mcVersion.toString())
316300

317301
clientRequired = true

settings.gradle

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,5 @@ plugins {
1717

1818
rootProject.name = "ViaForge"
1919

20-
include "viaforge-mc1165"
21-
include "viaforge-mc1171"
22-
include "viaforge-mc1182"
23-
include "viaforge-mc1192"
24-
include "viaforge-mc1194"
25-
include "viaforge-mc1201"
26-
include "viaforge-mc1204"
27-
include "viaforge-mc1206"
28-
include "viaforge-mc12111"
20+
include "viaforge-mc189"
21+
include "viaforge-mc1122"

viaforge-mc1122/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
minecraft {
2+
mappings channel: "stable", version: "39-1.12"
3+
}

viaforge-mc1122/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
forge_version=1.12.2-14.23.5.2859

viaforge-mc1165/src/main/java/com/viaversion/viaforge/ViaForge.java renamed to viaforge-mc1122/src/main/java/com/viaversion/viaforge/ViaForge.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,40 @@
2525
import com.viaversion.viaforge.platform.ViaForgeProtocol;
2626
import java.io.File;
2727
import net.minecraft.client.Minecraft;
28+
import net.minecraft.realms.RealmsSharedConstants;
2829
import net.minecraft.util.Session;
29-
import net.minecraft.util.SharedConstants;
3030
import net.minecraftforge.fml.common.Mod;
31-
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
32-
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
31+
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
3332
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.provider.GameProfileFetcher;
3433

35-
@Mod("viaforge")
34+
@Mod(modid = "viaforge", name = "ViaForge", acceptableRemoteVersions = "*", clientSideOnly = true, useMetadata = true)
3635
public class ViaForge implements ViaForgePlatform {
3736

38-
public ViaForge() {
39-
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onInit);
40-
}
41-
42-
public void onInit(FMLCommonSetupEvent event) {
37+
@Mod.EventHandler
38+
public void onInit(FMLInitializationEvent event) {
4339
ViaForgeCommon.init(this);
4440
}
4541

4642
@Override
4743
public int getGameVersion() {
48-
return SharedConstants.getProtocolVersion();
44+
return RealmsSharedConstants.NETWORK_PROTOCOL_VERSION;
4945
}
5046

5147
@Override
5248
public boolean isSingleplayer() {
53-
return Minecraft.getInstance().hasSingleplayerServer();
49+
return Minecraft.getMinecraft().isSingleplayer();
5450
}
5551

5652
@Override
5753
public File getLeadingDirectory() {
58-
return Minecraft.getInstance().gameDirectory;
54+
return Minecraft.getMinecraft().gameDir;
5955
}
6056

6157
@Override
6258
public void joinServer(String serverId) throws Throwable {
63-
final Session session = Minecraft.getInstance().getUser();
59+
final Session session = Minecraft.getMinecraft().getSession();
6460

65-
Minecraft.getInstance().getMinecraftSessionService().joinServer(session.getGameProfile(), session.getAccessToken(), serverId);
61+
Minecraft.getMinecraft().getSessionService().joinServer(session.getProfile(), session.getToken(), serverId);
6662
}
6763

6864
@Override

0 commit comments

Comments
 (0)