Skip to content

Commit 0084061

Browse files
committed
Updated for 1.21.4
Deprecated Pair (Alternatives exist in other libraries) Deprecated UUID CODEC (One in neoforge now) Massive Cleanup Javadoc Improvements Removed `DatTeleport` (Teleporting has changed)
1 parent 600235d commit 0084061

File tree

22 files changed

+593
-451
lines changed

22 files changed

+593
-451
lines changed

build.gradle

Lines changed: 90 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import net.darkhax.curseforgegradle.TaskPublishCurseForge
22

33
plugins {
4-
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
5-
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
4+
id 'net.neoforged.moddev' version '1.0.23'
65

76
id 'idea'
87

@@ -21,91 +20,129 @@ base {
2120
}
2221

2322
java {
24-
toolchain.languageVersion = JavaLanguageVersion.of(17)
23+
toolchain.languageVersion = JavaLanguageVersion.of(21)
2524

2625
withJavadocJar()
2726
withSourcesJar()
2827
}
2928

30-
minecraft {
31-
mappings channel: mapping_channel, version: "${parchment_version}-${minecraft_version}"
29+
neoForge {
30+
// Specify the version of NeoForge to use.
31+
version = project.neo_version
3232

33-
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
33+
parchment {
34+
mappingsVersion = project.parchment_version
35+
minecraftVersion = project.minecraft_version
36+
}
3437

35-
copyIdeResources = true
38+
// This line is optional. Access Transformers are automatically detected
39+
// accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
3640

3741
// Default run configurations.
38-
// These can be tweaked, removed, or duplicated as needed.
3942
runs {
40-
// applies to all the run configs below
41-
configureEach {
42-
workingDirectory project.file('run')
43-
44-
// Recommended logging data for a userdev environment
45-
// The markers can be added/remove as needed separated by commas.
46-
// "SCAN": For mods scan.
47-
// "REGISTRIES": For firing of registry events.
48-
// "REGISTRYDUMP": For getting the contents of all registries.
49-
property 'forge.logging.markers', 'REGISTRIES'
50-
51-
property 'forge.logging.console.level', 'debug'
52-
53-
mods {
54-
"${mod_id}" {
55-
source sourceSets.main
56-
}
57-
}
58-
}
59-
6043
client {
61-
property 'forge.enabledGameTestNamespaces', mod_id
62-
property 'mixin.env.remapRefMap', 'true'
63-
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
44+
client()
45+
46+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
47+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
6448
}
6549

6650
server {
67-
property 'forge.enabledGameTestNamespaces', mod_id
68-
property 'mixin.env.remapRefMap', 'true'
69-
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
70-
args '--nogui'
51+
server()
52+
programArgument '--nogui'
53+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
7154
}
7255

56+
// This run config launches GameTestServer and runs all registered gametests, then exits.
57+
// By default, the server will crash when no gametests are provided.
58+
// The gametest system is also enabled by default for other run configs under the /test command.
7359
gameTestServer {
74-
property 'forge.enabledGameTestNamespaces', mod_id
60+
type = "gameTestServer"
61+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
7562
}
7663

77-
data {
78-
// example of overriding the workingDirectory set in configureEach above
79-
workingDirectory project.file('run-data')
64+
clientData {
65+
clientData()
66+
67+
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
68+
// gameDirectory = project.file('run-data')
8069

8170
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
82-
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
71+
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
72+
}
73+
74+
// applies to all the run configs above
75+
configureEach {
76+
// Recommended logging data for a userdev environment
77+
// The markers can be added/remove as needed separated by commas.
78+
// "SCAN": For mods scan.
79+
// "REGISTRIES": For firing of registry events.
80+
// "REGISTRYDUMP": For getting the contents of all registries.
81+
systemProperty 'forge.logging.markers', 'REGISTRIES'
82+
83+
// Recommended logging level for the console
84+
// You can set various levels here.
85+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
86+
logLevel = org.slf4j.event.Level.DEBUG
8387
}
8488
}
89+
90+
mods {
91+
// define mod <-> source bindings
92+
// these are used to tell the game which sources are for which mod
93+
// mostly optional in a single mod project
94+
// but multi mod projects should define one per mod
95+
"${mod_id}" {
96+
sourceSet(sourceSets.main)
97+
}
98+
}
99+
100+
unitTest {
101+
// Enable JUnit support in the moddev plugin
102+
enable()
103+
// Configure which mod is being tested.
104+
// This allows NeoForge to load the test/ classes and resources as belonging to the mod.
105+
testedMod = mods."${mod_id}"
106+
}
85107
}
86108

87109
// Include resources generated by data generators.
88110
sourceSets.main.resources { srcDir 'src/generated/resources' }
89111

112+
// Sets up a dependency configuration called 'localRuntime'.
113+
// This configuration should be used instead of 'runtimeOnly' to declare
114+
// a dependency that will be present for runtime testing but that is
115+
// "optional", meaning it will not be pulled by dependents of this mod.
116+
configurations {
117+
runtimeClasspath.extendsFrom localRuntime
118+
}
119+
90120
/* -------------------------------------------- */
91121
/* Dependencies */
92122
/* -------------------------------------------- */
93123

94-
repositories {}
124+
repositories {
125+
mavenLocal()
126+
}
95127

96128
dependencies {
97-
minecraft "net.neoforged:forge:${minecraft_version}-${neo_version}"
98-
99129
// Testing
100130
testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}"
101131
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_version}"
132+
testImplementation "net.neoforged:testframework:${neo_version}"}
133+
134+
idea {
135+
module {
136+
downloadSources = true
137+
downloadJavadoc = true
138+
}
102139
}
103140

104141
/* -------------------------------------------- */
105142
/* Tasks */
106143
/* -------------------------------------------- */
107144

108-
tasks.named('processResources', ProcessResources).configure {
145+
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
109146
var replaceProperties = [
110147
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
111148
neo_version: neo_version, neo_version_range: neo_version_range,
@@ -115,12 +152,17 @@ tasks.named('processResources', ProcessResources).configure {
115152
]
116153

117154
inputs.properties replaceProperties
118-
119-
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
120-
expand replaceProperties + [project: project]
121-
}
155+
expand replaceProperties
156+
from "src/main/templates"
157+
into "build/generated/sources/modMetadata"
122158
}
123159

160+
// Include the output of "generateModMetadata" as an input directory for the build
161+
// this works with both building through Gradle and the IDE.
162+
sourceSets.main.resources.srcDir generateModMetadata
163+
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
164+
neoForge.ideSyncTask generateModMetadata
165+
124166
tasks.named('jar', Jar).configure {
125167
manifest {
126168
attributes([
@@ -133,8 +175,6 @@ tasks.named('jar', Jar).configure {
133175
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
134176
])
135177
}
136-
137-
finalizedBy 'reobfJar'
138178
}
139179

140180
tasks.register('printVersion') {

checkstyle.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<!--No Tabs-->
6060
<module name="FileTabCharacter"/>
6161

62+
<module name="LineLength">
63+
<property name="max" value="120"/>
64+
</module>
6265

6366
<module name="NewlineAtEndOfFile"/>
6467

gradle.properties

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
org.gradle.jvmargs=-Xmx3G
2-
org.gradle.daemon=false
1+
org.gradle.jvmargs=-Xmx1G
2+
org.gradle.daemon=true
3+
org.gradle.parallel=true
4+
org.gradle.caching=true
5+
org.gradle.configuration-cache=true
36

47
release_postfix=
58

6-
minecraft_version=1.20.1
7-
minecraft_version_range=[1.20.1,1.21)
8-
neo_version=47.1.65
9-
neo_version_range=[47.1,)
10-
loader_version_range=[47,)
9+
minecraft_version=1.21.4
10+
minecraft_version_range=[1.21.4,1.22)
11+
neo_version=21.4.11-beta
12+
neo_version_range=[21.4.0-beta,)
13+
loader_version_range=[4,)
1114

1215
mapping_channel=parchment
13-
parchment_version=2023.08.20
16+
parchment_version=2024.12.07
1417

1518
junit_version=5.10+
19+
neogradle.subsystems.conventions.ide.idea.reconfigure-unit-test-templates=true
20+
1621

1722
mod_id=datmoddingapi
1823
mod_name=Dat Modding API
1924
mod_license=MIT
20-
mod_version=1.8.0
25+
mod_version=1.9.0
2126
mod_group_id=com.datdeveloper
2227
mod_authors=jtljac
2328
mod_description=A modding library for DatDeveloper
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pluginManagement {
22
repositories {
3+
mavenLocal()
34
gradlePluginPortal()
45
maven { url = 'https://maven.neoforged.net/releases' }
56
maven { url = 'https://maven.parchmentmc.org' }
@@ -8,7 +9,7 @@ pluginManagement {
89
}
910

1011
plugins {
11-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
12+
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
1213
}
1314

1415
rootProject.name = 'datmoddingapi'
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
package com.datdeveloper.datmoddingapi;
22

3-
import net.minecraftforge.common.ForgeConfigSpec;
4-
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
3+
import net.neoforged.neoforge.common.ModConfigSpec;
54

65
/**
76
* The config for DatModdingAPI
87
*/
9-
@SuppressWarnings("HideUtilityClassConstructor")
108
public class DatConfig {
11-
private static ConfigValue<Integer> delayedEventsPerTick;
12-
private static ConfigValue<Integer> maxConcurrentThreadCount;
13-
DatConfig(final ForgeConfigSpec.Builder builder) {
14-
delayedEventsPerTick = builder
15-
.comment("The amount of delayed events that are processed a tick, less is quicker")
16-
.defineInRange("DelayedEventsPerTick", 1, 0, Integer.MAX_VALUE);
17-
18-
maxConcurrentThreadCount = builder
19-
.worldRestart()
20-
.comment("The maximum number of threads to use for executing concurrent tasks")
21-
.comment("More threads means more concurrent tasks can be executed at the same time")
22-
.comment("Too many threads can hog resources, and lots of threads only helps when there are many concurrent tasks")
23-
.comment("You probably don't want to change this if you don't know it is")
24-
.defineInRange("MaxAsyncThreadCount", 2, 1, Integer.MAX_VALUE);
25-
}
26-
279
private DatConfig() {
10+
2811
}
2912

13+
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
14+
15+
private static final ModConfigSpec.IntValue DELAYED_EVENTS_PER_TICK = BUILDER
16+
.comment("The amount of delayed events that are processed a tick, less is quicker")
17+
.defineInRange("DelayedEventsPerTick", 1, 0, Integer.MAX_VALUE);
18+
19+
private static final ModConfigSpec.ConfigValue<Integer> MAX_CONCURRENT_THREAD_COUNT = BUILDER
20+
.worldRestart()
21+
.comment("The maximum number of threads to use for executing concurrent tasks")
22+
.comment("More threads means more concurrent tasks can be executed at the same time")
23+
.comment("Too many threads can hog resources, and lots of threads only helps when there are many concurrent"
24+
+ " tasks")
25+
.comment("You probably don't want to change this if you don't know it is")
26+
.defineInRange("MaxAsyncThreadCount", 2, 1, Integer.MAX_VALUE);
27+
28+
static final ModConfigSpec SPEC = BUILDER.build();
29+
3030
public static int getDelayedEventsPerTick() {
31-
return delayedEventsPerTick.get();
31+
return DELAYED_EVENTS_PER_TICK.get();
3232
}
3333

3434
public static int getMaxConcurrentThreadCount() {
35-
return maxConcurrentThreadCount.get();
35+
return MAX_CONCURRENT_THREAD_COUNT.get();
3636
}
3737
}

0 commit comments

Comments
 (0)