Skip to content

Commit b31c375

Browse files
authored
Merge pull request #25 from CSSUoB/add-neoforge
Add NeoForge support
2 parents ac6e262 + 9159a38 commit b31c375

File tree

16 files changed

+744
-6
lines changed

16 files changed

+744
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
target: [ bukkit, fabric, forge ]
14+
target: [ bukkit, fabric, forge, neoforge ]
1515

1616
name: Build ${{ matrix.target }}
1717
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ target/
33
.idea
44
.gradle
55
**/build/
6+
**/run
67
!src/**/build/
78
gradle-app.setting
89
!gradle-wrapper.jar

common/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
plugins {
22
id "java"
33
id "java-library"
4+
id "maven-publish"
5+
}
6+
7+
compileJava {
8+
options.compilerArgs += "-g"
49
}
510

611
dependencies {
@@ -34,3 +39,15 @@ shadowJar {
3439

3540
minimize()
3641
}
42+
43+
publishing {
44+
publications {
45+
maven(MavenPublication) {
46+
groupId = 'com.cssbham'
47+
artifactId = 'common'
48+
version = '1.0.0'
49+
50+
from components.java
51+
}
52+
}
53+
}

common/src/main/java/com/cssbham/cssminecraft/common/command/handler/MakeGreenCommandHandler.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@ public void handle(CommandSender sender, CommandContext context) {
4545
if (discordClientService.getDiscordClient().isMember(arg)) {
4646
sender.sendMessage(Component.text("Making you green...").color(NamedTextColor.GRAY));
4747
try {
48-
permissionPluginService.grantMemberRole(sender.getUuid()).get();
49-
} catch (InterruptedException | ExecutionException e) {
48+
permissionPluginService.grantMemberRole(sender.getUuid()).whenComplete((v, err) -> {
49+
if (err != null) {
50+
sender.sendMessage(Component.text("There was a problem making you green. Try again later.")
51+
.color(NamedTextColor.RED));
52+
throw new RuntimeException(err);
53+
}
54+
55+
sender.sendMessage(Component.text("Congratulations, you are now green!").color(NamedTextColor.GREEN));
56+
});
57+
} catch (Exception e) {
5058
sender.sendMessage(Component.text("There was a problem making you green. Try again later.")
5159
.color(NamedTextColor.RED));
5260
throw new RuntimeException(e);
5361
}
54-
sender.sendMessage(Component.text("Congratulations, you are now green!").color(NamedTextColor.GREEN));
5562
} else {
5663
sender.sendMessage(Component.text("You don't appear to be a ").color(NamedTextColor.RED).append(
5764
Component.text("Member").color(NamedTextColor.GREEN)

common/src/main/java/com/cssbham/cssminecraft/common/permission/LuckPermsPermissionPluginService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ public CompletableFuture<Void> grantMemberRole(UUID player) {
2020
user.data().add(Node.builder("group.member").build());
2121
user.data().remove(Node.builder("group.guest").build());
2222
}
23-
);
23+
).whenCompleteAsync((v, err) -> {
24+
if (err != null) {
25+
err.printStackTrace();
26+
return;
27+
}
28+
29+
System.out.println("Success");
30+
});
2431
}
2532

2633
@Override

neoforge/build.gradle

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'idea'
5+
id 'net.neoforged.moddev' version '2.0.92'
6+
}
7+
8+
version = mod_version
9+
group = mod_group_id
10+
11+
repositories {
12+
mavenLocal()
13+
}
14+
15+
base {
16+
archivesName = mod_id + "-neoforge"
17+
}
18+
19+
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
20+
21+
jarJar.enabled = true
22+
23+
neoForge {
24+
// Specify the version of NeoForge to use.
25+
version = project.neo_version
26+
27+
parchment {
28+
mappingsVersion = project.parchment_mappings_version
29+
minecraftVersion = project.parchment_minecraft_version
30+
}
31+
32+
// This line is optional. Access Transformers are automatically detected
33+
// accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg')
34+
35+
// Default run configurations.
36+
// These can be tweaked, removed, or duplicated as needed.
37+
runs {
38+
client {
39+
client()
40+
41+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
42+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
43+
}
44+
45+
server {
46+
server()
47+
programArgument '--nogui'
48+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
49+
}
50+
51+
// This run config launches GameTestServer and runs all registered gametests, then exits.
52+
// By default, the server will crash when no gametests are provided.
53+
// The gametest system is also enabled by default for other run configs under the /test command.
54+
gameTestServer {
55+
type = "gameTestServer"
56+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
57+
}
58+
59+
data {
60+
data()
61+
62+
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
63+
// gameDirectory = project.file('run-data')
64+
65+
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
66+
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
67+
}
68+
69+
// applies to all the run configs above
70+
configureEach {
71+
// Recommended logging data for a userdev environment
72+
// The markers can be added/remove as needed separated by commas.
73+
// "SCAN": For mods scan.
74+
// "REGISTRIES": For firing of registry events.
75+
// "REGISTRYDUMP": For getting the contents of all registries.
76+
systemProperty 'forge.logging.markers', 'REGISTRIES'
77+
78+
// Recommended logging level for the console
79+
// You can set various levels here.
80+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
81+
logLevel = org.slf4j.event.Level.DEBUG
82+
}
83+
}
84+
85+
mods {
86+
// define mod <-> source bindings
87+
// these are used to tell the game which sources are for which mod
88+
// mostly optional in a single mod project
89+
// but multi mod projects should define one per mod
90+
"${mod_id}" {
91+
sourceSet(sourceSets.main)
92+
sourceSet(project(":common").sourceSets.main)
93+
}
94+
}
95+
}
96+
97+
// Include resources generated by data generators.
98+
sourceSets.main.resources { srcDir 'src/generated/resources' }
99+
100+
compileJava {
101+
options.compilerArgs += "-g"
102+
}
103+
104+
dependencies {
105+
// Example mod dependency with JEI
106+
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
107+
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
108+
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
109+
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
110+
111+
// Example mod dependency using a mod jar from ./libs with a flat dir repository
112+
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
113+
// The group id is ignored when searching -- in this case, it is "blank"
114+
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
115+
116+
// Example mod dependency using a file as dependency
117+
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
118+
119+
// Example project dependency using a sister or child project:
120+
// implementation project(":myproject")
121+
122+
// For more info:
123+
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
124+
// http://www.gradle.org/docs/current/userguide/dependency_management.html
125+
126+
// implementation "net.neoforged:neoforge:${neo_version}"
127+
128+
/* compileOnly(jarJar("net.kyori:adventure-api:4.17.0")) {
129+
exclude(module: "adventure-bom")
130+
exclude(module: "annotations")
131+
}
132+
compileOnly(jarJar("net.kyori:adventure-text-serializer-gson:4.17.0")) {
133+
exclude(module: "adventure-bom")
134+
exclude(module: "adventure-api")
135+
exclude(module: "annotations")
136+
exclude(module: "auto-service-annotations")
137+
exclude(module: "gson")
138+
} */
139+
140+
jarJar(implementation(group: "net.kyori", name: "adventure-platform-neoforge", version: "6.0.0") {
141+
exclude(module: "annotations")
142+
exclude(module: "auto-service-annotations")
143+
exclude(module: "gson")
144+
})
145+
jarJar(implementation ("net.dv8tion:JDA:5.0.2") {
146+
exclude(module: "opus-java")
147+
exclude(module: "annotations")
148+
exclude(module: "slf4j-api")
149+
})
150+
jarJar(implementation ("club.minnced:discord-webhooks:0.8.4") {
151+
exclude(module: "slf4j-api")
152+
})
153+
jarJar(implementation("org.yaml:snakeyaml:2.2"))
154+
jarJar(implementation("com.neovisionaries:nv-websocket-client:2.14"))
155+
jarJar(implementation("com.squareup.okhttp3:okhttp:4.12.0"))
156+
jarJar(implementation("org.apache.commons:commons-collections4:4.4"))
157+
jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10"))
158+
jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10"))
159+
jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10"))
160+
jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10"))
161+
jarJar(implementation("com.squareup.okio:okio:3.6.0"))
162+
jarJar(implementation("net.sf.trove4j:core:3.1.0"))
163+
jarJar(implementation("com.fasterxml.jackson.core:jackson-core:2.17.2"))
164+
jarJar(implementation("com.fasterxml.jackson:jackson-bom:2.17.2"))
165+
jarJar(implementation("com.fasterxml.jackson.core:jackson-annotations:2.17.2"))
166+
jarJar(implementation("com.fasterxml.jackson.core:jackson-databind:2.17.2"))
167+
jarJar(implementation("org.json:json:20230618"))
168+
169+
shadow(compileOnly(project(path: ":common"))) {
170+
transitive(false)
171+
}
172+
// additionalRuntimeClasspath("org.yaml:snakeyaml:2.2")
173+
// additionalRuntimeClasspath("net.dv8tion:JDA:5.0.2")
174+
// additionalRuntimeClasspath("club.minnced:discord-webhooks:0.8.4")
175+
// additionalRuntimeClasspath("com.cssbham:common:1.0.0")
176+
// additionalRuntimeClasspath("net.kyori:adventure-api:4.17.0")
177+
// additionalRuntimeClasspath("net.kyori:adventure-platform-neoforge:6.0.0")
178+
// additionalRuntimeClasspath("net.kyori:adventure-text-serializer-gson:4.17.0")
179+
}
180+
181+
// tasks.shadowJar.enabled = false
182+
183+
// This block of code expands all declared replace properties in the specified resource targets.
184+
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
185+
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
186+
var replaceProperties = [
187+
minecraft_version : minecraft_version,
188+
minecraft_version_range: minecraft_version_range,
189+
neo_version : neo_version,
190+
neo_version_range : neo_version_range,
191+
loader_version_range : loader_version_range,
192+
mod_id : mod_id,
193+
mod_name : mod_name,
194+
mod_license : mod_license,
195+
mod_version : mod_version,
196+
mod_authors : mod_authors,
197+
mod_description : mod_description
198+
]
199+
inputs.properties replaceProperties
200+
expand replaceProperties
201+
from "src/main/templates"
202+
into "build/generated/sources/modMetadata"
203+
}
204+
205+
// Include the output of "generateModMetadata" as an input directory for the build
206+
// this works with both building through Gradle and the IDE.
207+
sourceSets.main.resources.srcDir generateModMetadata
208+
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
209+
neoForge.ideSyncTask generateModMetadata
210+
211+
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
212+
idea {
213+
module {
214+
downloadSources = true
215+
downloadJavadoc = true
216+
}
217+
}
218+
/*
219+
tasks.shadowJar {
220+
configurations = [project.configurations.shadow]
221+
222+
dependencies {
223+
exclude(dependency("net.kyori:adventure-platform-neoforge:6.0.0"))
224+
}
225+
226+
doLast {
227+
copy {
228+
from("build/generated/jarjar/META-INF/jarjar")
229+
into("META-INF/jarjar")
230+
}
231+
}
232+
233+
// exclude("net/**")
234+
// exclude("META-INF/services/*")
235+
// minimize()
236+
237+
archiveFileName = "cssminecraft-neoforge-${project.version}.jar"
238+
}
239+
240+
*/
241+
242+
tasks.shadowJar.enabled = false
243+
/*
244+
tasks.register("shadeCommon") {
245+
copy {
246+
from("../common/build/classes/main/com/cssbham/cssminecraft/common")
247+
into("build/classes/")
248+
}
249+
} */
250+
251+
tasks.jar {
252+
from("../common/build/classes/java/main/com/cssbham/cssminecraft/common") {
253+
into("com/cssbham/cssminecraft/common")
254+
}
255+
}
256+
/*
257+
tasks.register("copyJarJar") {
258+
copy {
259+
from ("build/generated/jarjar/META-INF/jarjar")
260+
into("META-INF/jarjar")
261+
}
262+
}
263+
264+
tasks.copyJarJar.dependsOn(jarJar)
265+
*/
266+

neoforge/gradle.properties

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
2+
org.gradle.jvmargs=-Xmx2G
3+
org.gradle.daemon=true
4+
org.gradle.parallel=true
5+
org.gradle.caching=true
6+
org.gradle.configuration-cache=true
7+
8+
## Environment Properties
9+
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
10+
# The Minecraft version must agree with the Neo version to get a valid artifact
11+
minecraft_version=1.21.1
12+
# The Minecraft version range can use any release version of Minecraft as bounds.
13+
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
14+
# as they do not follow standard versioning conventions.
15+
minecraft_version_range=[1.21.1,1.22)
16+
# The Neo version must agree with the Minecraft version to get a valid artifact
17+
neo_version=21.1.176
18+
# The Neo version range can use any version of Neo as bounds
19+
neo_version_range=[21,)
20+
# The loader version range can only use the major version of FML as bounds
21+
loader_version_range=[4,)
22+
23+
parchment_minecraft_version=1.21.4
24+
parchment_mappings_version=2025.03.23
25+
26+
## Mod Properties
27+
28+
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
29+
# Must match the String constant located in the main mod class annotated with @Mod.
30+
mod_id=cssminecraft
31+
# The human-readable display name for the mod.
32+
mod_name=CSS-Minecraft
33+
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
34+
mod_license=todo
35+
# The mod version. See https://semver.org/
36+
mod_version=1.0.0
37+
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
38+
# This should match the base package used for the mod sources.
39+
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
40+
mod_group_id=com.cssbham.cssminecraft.neoforge
41+
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
42+
mod_authors=
43+
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
44+
mod_description=

0 commit comments

Comments
 (0)