Skip to content

Commit 3006c7c

Browse files
Add NeoForge support
1 parent 1b7d0df commit 3006c7c

File tree

8 files changed

+82
-14
lines changed

8 files changed

+82
-14
lines changed

build.gradle.kts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dependencies {
6161
platform.isFabric -> "fabric"
6262
platform.isLegacyForge -> "forge-legacy"
6363
platform.isForge -> "forge-latest"
64+
platform.isNeoForge -> "neoforge"
6465
else -> error("Unable to determine DevAuth platform")
6566
}
6667

@@ -69,15 +70,7 @@ dependencies {
6970

7071
val downloadContainer by tasks.registering(DownloadContainerTask::class) {
7172
containerFile = layout.buildDirectory.file("essential-container.jar")
72-
version = when (project.platform.mcVersion) {
73-
12105 -> "1.4.2+fabric-1.21.5"
74-
12104 -> "1.4.2+fabric-1.21.4"
75-
12103 -> "1.4.2+fabric-1.21.3"
76-
12102 -> "1.4.2+fabric-1.21.2"
77-
12101 -> "1.4.2+fabric-1.21.1"
78-
12100 -> "1.4.2+fabric-1.21"
79-
else -> "1.4.2"
80-
}
73+
version = "1.4.3"
8174
platform = "${project.platform.loaderStr}_${project.platform.mcVersionStr}"
8275
}
8376

@@ -90,6 +83,16 @@ tasks.processResources {
9083
filesMatching("gg/essential/partnermod/loader/version.txt") {
9184
filter { _ -> project.version.toString() }
9285
}
86+
87+
if (platform.isNeoForge) {
88+
if (platform.mcVersion < 12005) {
89+
// NeoForge still uses the old mods.toml name until 1.20.5
90+
filesMatching("META-INF/neoforge.mods.toml") {
91+
name = "mods.toml"
92+
}
93+
}
94+
exclude("META-INF/mods.toml")
95+
}
9396
}
9497

9598
tasks.jar {

buildSrc/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ repositories {
1212

1313
dependencies {
1414
implementation("com.google.code.gson:gson:2.11.0")
15-
implementation("gg.essential:essential-gradle-toolkit:0.6.5")
15+
implementation("gg.essential:essential-gradle-toolkit:0.6.7")
1616
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
17-
implementation("gg.essential:architectury-loom:1.7.27")
17+
implementation("gg.essential:architectury-loom:1.7.30")
1818
}
1919

2020
kotlin {

root.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ plugins {
55
preprocess {
66
strictExtraMappings.set(true)
77

8+
val neoForge12105 = createNode("1.21.5-neoforge", 12105, "srg")
9+
val forge12105 = createNode("1.21.5-forge", 12105, "srg")
810
val fabric12105 = createNode("1.21.5-fabric", 12105, "yarn")
11+
val neoForge12104 = createNode("1.21.4-neoforge", 12104, "srg")
12+
val forge12104 = createNode("1.21.4-forge", 12104, "srg")
913
val fabric12104 = createNode("1.21.4-fabric", 12104, "yarn")
14+
val neoForge12103 = createNode("1.21.3-neoforge", 12103, "srg")
15+
val forge12103 = createNode("1.21.3-forge", 12103, "srg")
1016
val fabric12103 = createNode("1.21.3-fabric", 12103, "yarn")
17+
val neoForge12101 = createNode("1.21.1-neoforge", 12101, "srg")
18+
val forge12101 = createNode("1.21.1-forge", 12101, "srg")
1119
val fabric12101 = createNode("1.21.1-fabric", 12101, "yarn")
20+
val neoForge12006 = createNode("1.20.6-neoforge", 12006, "srg")
21+
val forge12006 = createNode("1.20.6-forge", 12006, "srg")
1222
val fabric12006 = createNode("1.20.6-fabric", 12006, "yarn")
23+
val neoForge12004 = createNode("1.20.4-neoforge", 12004, "srg")
1324
val forge12004 = createNode("1.20.4-forge", 12004, "srg")
1425
val fabric12004 = createNode("1.20.4-fabric", 12004, "yarn")
1526
val forge12002 = createNode("1.20.2-forge", 12002, "srg")
@@ -34,11 +45,22 @@ preprocess {
3445
val forge11202 = createNode("1.12.2-forge", 11202, "srg")
3546
val forge10809 = createNode("1.8.9-forge", 10809, "srg")
3647

48+
neoForge12105.link(fabric12105)
49+
forge12105.link(fabric12105)
3750
fabric12105.link(fabric12104)
51+
neoForge12104.link(fabric12104)
52+
forge12104.link(fabric12104)
3853
fabric12104.link(fabric12103)
54+
neoForge12103.link(fabric12103)
55+
forge12103.link(fabric12103)
3956
fabric12103.link(fabric12101)
57+
neoForge12101.link(fabric12101)
58+
forge12101.link(fabric12101)
4059
fabric12101.link(fabric12006)
60+
neoForge12006.link(fabric12006)
61+
forge12006.link(fabric12006)
4162
fabric12006.link(fabric12004)
63+
neoForge12004.link(fabric12004)
4264
forge12004.link(fabric12004)
4365
fabric12004.link(fabric12002)
4466
forge12002.link(fabric12002)

settings.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,22 @@ listOf(
4040
"1.20.2-forge",
4141
"1.20.4-fabric",
4242
"1.20.4-forge",
43+
"1.20.4-neoforge",
4344
"1.20.6-fabric",
45+
"1.20.6-forge",
46+
"1.20.6-neoforge",
4447
"1.21.1-fabric",
48+
"1.21.1-forge",
49+
"1.21.1-neoforge",
4550
"1.21.3-fabric",
51+
"1.21.3-forge",
52+
"1.21.3-neoforge",
4653
"1.21.4-fabric",
54+
"1.21.4-forge",
55+
"1.21.4-neoforge",
4756
"1.21.5-fabric",
57+
"1.21.5-forge",
58+
"1.21.5-neoforge",
4859
).forEach { version ->
4960
include(":$version")
5061
project(":$version").apply {

src/main/java/gg/essential/partnermod/EssentialPartner.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
//$$ import net.minecraft.util.SharedConstants;
4242
//#endif
4343

44+
//#if NEOFORGE
45+
//$$ import net.neoforged.neoforge.common.NeoForge;
46+
//$$ import net.neoforged.bus.api.SubscribeEvent;
47+
//$$ import net.neoforged.neoforge.client.event.ScreenEvent;
48+
//#endif
49+
4450
//#if FORGE
4551
import net.minecraftforge.common.MinecraftForge;
4652
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -77,14 +83,20 @@ public class EssentialPartner {
7783
"1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4", "1.21.5"
7884
));
7985

86+
private static final Set<String> NEOFORGE_SUPPORTED_VERSIONS = new HashSet<>(Arrays.asList(
87+
"1.20.4", "1.20.6",
88+
"1.21.1", "1.21.3", "1.21.4", "1.21.5"
89+
));
90+
8091
private static final Set<String> FORGE_SUPPORTED_VERSIONS = new HashSet<>(Arrays.asList(
8192
"1.8.9",
8293
"1.12.2",
8394
"1.16.5",
8495
"1.17.1",
8596
"1.18.2",
8697
"1.19.2", "1.19.3", "1.19.4",
87-
"1.20.1", "1.20.2", "1.20.4"
98+
"1.20.1", "1.20.2", "1.20.4", "1.20.6",
99+
"1.21.1", "1.21.3", "1.21.4", "1.21.5"
88100
));
89101

90102
private static final Set<String> MAIN_MENU_BUTTONS = new HashSet<>(Collections.singletonList("menu.multiplayer"));
@@ -121,14 +133,19 @@ public EssentialPartner() {
121133

122134
//#if FABRIC
123135
//$$ if (!FABRIC_SUPPORTED_VERSIONS.contains(version)) {
136+
//#elseif NEOFORGE
137+
//$$ if (!NEOFORGE_SUPPORTED_VERSIONS.contains(version)) {
124138
//#else
125139
if (!FORGE_SUPPORTED_VERSIONS.contains(version)) {
126140
//#endif
127141
LOGGER.info("Minecraft version {} is not supported by Essential, disabling Partner Mod", version);
128142
return;
129143
}
130144

131-
//#if FORGE
145+
//#if NEOFORGE
146+
//$$ NeoForge.EVENT_BUS.register(this);
147+
//$$ NeoForge.EVENT_BUS.register(ModalManager.INSTANCE);
148+
//#elseif FORGE
132149
MinecraftForge.EVENT_BUS.register(this);
133150
MinecraftForge.EVENT_BUS.register(ModalManager.INSTANCE);
134151
//#else
@@ -268,7 +285,7 @@ private boolean overlaps(int x1, int y1, int w1, int h1, GuiButton button) {
268285
return x1 < x2 + w2 && x2 < x1 + w1 && y1 < y2 + h2 && y2 < y1 + h1;
269286
}
270287

271-
//#if FORGE
288+
//#if FORGELIKE
272289
@SubscribeEvent
273290
public void screenInitEvent(
274291
//#if MC>=11900

src/main/java/gg/essential/partnermod/ModLoaderUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
//#if FABRIC
1515
//$$ import net.fabricmc.loader.api.FabricLoader;
16+
//#elseif NEOFORGE
17+
//$$ import net.neoforged.fml.loading.LoadingModList;
1618
//#else
1719
//#if MC>=11400
1820
//$$ import net.minecraftforge.fml.loading.LoadingModList;

src/main/java/gg/essential/partnermod/modal/ModalManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
//$$ import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
2121
//$$ import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
2222
//$$ import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
23+
//#elseif NEOFORGE
24+
//$$ import net.neoforged.bus.api.SubscribeEvent;
25+
//$$ import net.neoforged.neoforge.client.event.ScreenEvent;
2326
//#else
2427
//#if MC>=11800
2528
//$$ import net.minecraftforge.client.event.ScreenEvent;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
modLoader="javafml"
2+
loaderVersion="[1,)"
3+
license="All rights reserved"
4+
5+
[[mods]]
6+
modId="essential_partner_mod"
7+
version="${file.jarVersion}"
8+
displayName="Essential Partner Mod Integrations"
9+
displayURL="https://essential.gg/"
10+
description="Enhance your Minecraft with one simple mod. Host worlds for free, chat with friends, and so much more!"

0 commit comments

Comments
 (0)