Skip to content

Commit 595795a

Browse files
committed
Updated everything except packets, or so I think!
1 parent 7edae79 commit 595795a

File tree

64 files changed

+1359
-1308
lines changed

Some content is hidden

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

64 files changed

+1359
-1308
lines changed

build.gradle

Lines changed: 146 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,137 @@
1-
import groovy.json.JsonSlurper
2-
import groovy.json.JsonOutput
3-
41
plugins {
2+
id 'java-library'
53
id 'eclipse'
4+
id 'idea'
65
id 'maven-publish'
7-
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
8-
id "me.modmuss50.mod-publish-plugin" version "0.3.5"
9-
}
10-
11-
apply {
12-
// Fixes m1 macs having build time errors (#forgeplzfix)
13-
// from "https://raw.githubusercontent.com/mezz/JustEnoughItems/1.18/Forge/buildtools/AppleSiliconSupport.gradle"
6+
id 'net.neoforged.gradle.userdev' version '7.0.80'
147
}
158

169
version = "${mod_version}"
17-
group = 'com.direwolf20.mininggadgets' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
18-
archivesBaseName = 'mininggadgets'
10+
group = mod_group_id
1911

20-
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
12+
// All jar files from this folder will be added automatically as runtime mod dependencies
13+
def extraModsDir = "extra-mods"
14+
def extraAPIDir = "extra-api"
2115

22-
minecraft {
23-
mappings channel: 'official', version: "${mc_version}"
24-
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
25-
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
16+
repositories {
17+
mavenLocal()
2618

27-
runs {
28-
client {
29-
workingDirectory project.file('run')
19+
flatDir {
20+
name "extra-mods"
21+
dir file(extraModsDir)
22+
}
3023

31-
property 'forge.logging.markers', 'SCAN,REGISTRIES'
32-
property 'forge.logging.console.level', 'debug'
24+
flatDir {
25+
name "extra-api"
26+
dir file(extraAPIDir)
27+
}
3328

34-
mods {
35-
mininggadgets {
36-
source sourceSets.main
37-
}
38-
}
29+
maven { //Patchouli && JEI
30+
url 'https://maven.blamejared.com'
31+
content {
32+
includeGroup "vazkii.patchouli"
33+
includeGroup "mezz.jei"
3934
}
35+
}
4036

41-
server {
42-
workingDirectory project.file('run')
43-
44-
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
45-
property 'forge.logging.console.level', 'debug'
46-
47-
mods {
48-
mininggadgets {
49-
source sourceSets.main
50-
}
51-
}
37+
maven { //Curios
38+
url = "https://maven.theillusivec4.top/"
39+
content {
40+
includeGroup "top.theillusivec4.curios"
5241
}
42+
}
5343

54-
data {
55-
workingDirectory project.file('run')
56-
57-
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
58-
property 'forge.logging.console.level', 'debug'
59-
60-
args '--mod', 'mininggadgets', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
61-
mods {
62-
mininggadgets {
63-
source sourceSets.main
64-
}
65-
}
44+
maven { // mek
45+
url = 'https://modmaven.dev/'
46+
content {
47+
includeGroup "mekanism"
48+
includeGroup "appeng"
6649
}
6750
}
51+
52+
maven { url = "https://www.cursemaven.com" } // curse mods
6853
}
6954

70-
sourceSets.main.resources { srcDir 'src/generated/resources' }
55+
base {
56+
archivesName = mod_id
57+
}
7158

72-
// All jar files from this folder will be added automatically as runtime mod dependencies
73-
def extraModsDir = "extra-mods"
59+
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
60+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
7461

75-
repositories {
76-
flatDir {
77-
name "extra-mods"
78-
dir file(extraModsDir)
62+
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
63+
64+
// Default run configurations.
65+
// These can be tweaked, removed, or duplicated as needed.
66+
runs {
67+
// applies to all the run configs below
68+
configureEach {
69+
// Recommended logging data for a userdev environment
70+
// The markers can be added/remove as needed separated by commas.
71+
// "SCAN": For mods scan.
72+
// "REGISTRIES": For firing of registry events.
73+
// "REGISTRYDUMP": For getting the contents of all registries.
74+
systemProperty 'forge.logging.markers', 'REGISTRIES'
75+
76+
// Recommended logging level for the console
77+
// You can set various levels here.
78+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
79+
systemProperty 'forge.logging.console.level', 'debug'
80+
81+
modSource project.sourceSets.main
7982
}
8083

81-
maven {
82-
name "ModMaven"
83-
url "https://modmaven.k-4u.nl"
84-
content {
85-
includeGroup("mezz.jei")
86-
}
84+
client {
85+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
86+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
8787
}
8888

89-
maven { url = "https://maven.architectury.dev" }
89+
server {
90+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
91+
programArgument '--nogui'
92+
}
9093

91-
maven {
92-
url "https://www.cursemaven.com"
93-
content {
94-
includeGroup "curse.maven"
95-
}
94+
// This run config launches GameTestServer and runs all registered gametests, then exits.
95+
// By default, the server will crash when no gametests are provided.
96+
// The gametest system is also enabled by default for other run configs under the /test command.
97+
gameTestServer {
98+
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
99+
}
100+
101+
data {
102+
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
103+
// workingDirectory project.file('run-data')
104+
105+
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
106+
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
96107
}
97108
}
98109

110+
// Include resources generated by data generators.
111+
sourceSets.main.resources { srcDir 'src/generated/resources' }
112+
99113
dependencies {
100-
minecraft "net.neoforged:forge:${mc_version}-${forge_version}"
114+
// Specify the version of Minecraft to use.
115+
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
116+
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
117+
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
118+
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
119+
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
120+
implementation "net.neoforged:neoforge:${neo_version}"
121+
122+
//AE2
123+
//compileOnly "appeng:appliedenergistics2-neoforge:${ae2_version}:api"
124+
//runtimeOnly "appeng:appliedenergistics2-neoforge:${ae2_version}"
125+
126+
//Curios
127+
//runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
128+
//compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
129+
130+
// Example mod dependency with JEI
131+
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
132+
compileOnly "mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"
133+
compileOnly "mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}"
134+
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
101135

102136
// Locally sourced extra mods for runtime (i.e. testing)
103137
for (extraModJar in fileTree(dir: extraModsDir, include: '*.jar')) {
@@ -106,139 +140,66 @@ dependencies {
106140
assert versionSep != -1
107141
def artifactId = basename.substring(0, versionSep)
108142
def version = basename.substring(versionSep + 1)
109-
runtimeOnly fg.deobf("extra-mods:$artifactId:$version")
143+
runtimeOnly "extra-mods:$artifactId:$version"
110144
}
111145

112-
//JEI
113-
// compile against the JEI API but do not include it at runtime
114-
compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
115-
compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
116-
// at runtime, use the full JEI jar
117-
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
118-
119-
// runtimeOnly fg.deobf("curse.maven:inventory-tweaks-renewed:3102237")
120-
// runtimeOnly fg.deobf("curse.maven:lollipop-347954:3232534")
121-
// runtimeOnly fg.deobf("curse.maven:mekanism-268560:268560")
122-
123-
runtimeOnly fg.deobf("curse.maven:charging-gadgets-399757:4617304")
124-
}
146+
// Locally sourced extra mods for compiling (i.e. API)
147+
for (extraModJar in fileTree(dir: extraAPIDir, include: '*.jar')) {
148+
def basename = extraModJar.name.substring(0, extraModJar.name.length() - ".jar".length())
149+
def versionSep = basename.lastIndexOf('-')
150+
assert versionSep != -1
151+
def artifactId = basename.substring(0, versionSep)
152+
def version = basename.substring(versionSep + 1)
153+
compileOnly "extra-api:$artifactId:$version"
154+
}
125155

126-
processResources {
127-
duplicatesStrategy = DuplicatesStrategy.INHERIT
156+
// Example mod dependency using a mod jar from ./libs with a flat dir repository
157+
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
158+
// The group id is ignored when searching -- in this case, it is "blank"
159+
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
128160

129-
inputs.property "version", project.version
161+
// Example mod dependency using a file as dependency
162+
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
130163

131-
filesMatching("META-INF/mods.toml") {
132-
expand "version": project.version,
133-
"mcversion": project.mc_version,
134-
"forgeversion": project.forge_version,
135-
"forgeshortversion": project.forge_version.split('\\.')[0],
136-
"forge_acceptable_range": project.forge_acceptable_range
137-
}
164+
// Example project dependency using a sister or child project:
165+
// implementation project(":myproject")
138166

139-
doLast {
140-
def jsonMinifyStart = System.currentTimeMillis()
141-
def jsonMinified = 0
142-
def jsonBytesSaved = 0
143-
144-
fileTree(dir: outputs.files.asPath, include: '**/*.json').each {
145-
File file = it
146-
jsonMinified++
147-
def oldLength = file.length()
148-
try {
149-
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
150-
jsonBytesSaved += oldLength - file.length()
151-
} catch (Exception e) {
152-
println('Failed to minify ' + it + ' ' + e)
153-
}
154-
}
155-
156-
println('Minified ' + jsonMinified + ' json files. Saved ' + jsonBytesSaved + ' bytes. Took ' + (System.currentTimeMillis() - jsonMinifyStart) + 'ms.')
157-
}
167+
// For more info:
168+
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
169+
// http://www.gradle.org/docs/current/userguide/dependency_management.html
158170
}
159171

160-
jar {
161-
manifest {
162-
attributes([
163-
"Specification-Title": "mininggadgets",
164-
"Specification-Vendor": "direwolf20",
165-
"Specification-Version": "1", // We are version 1 of ourselves
166-
"Implementation-Title": project.name,
167-
"Implementation-Version": "${version}",
168-
"Implementation-Vendor" :"direwolf20",
169-
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
170-
])
172+
// This block of code expands all declared replace properties in the specified resource targets.
173+
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
174+
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
175+
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
176+
tasks.withType(ProcessResources).configureEach {
177+
var replaceProperties = [
178+
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
179+
neo_version : neo_version, neo_version_range: neo_version_range,
180+
loader_version_range: loader_version_range,
181+
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
182+
mod_authors : mod_authors, mod_description: mod_description,
183+
]
184+
inputs.properties replaceProperties
185+
186+
filesMatching(['META-INF/mods.toml']) {
187+
expand replaceProperties + [project: project]
171188
}
172189
}
173190

174-
jar.finalizedBy('reobfJar')
175-
191+
// Example configuration to allow publishing using the maven-publish plugin
176192
publishing {
177193
publications {
178-
maven(MavenPublication) {
194+
register('mavenJava', MavenPublication) {
179195
from components.java
180-
artifactId = project.archivesBaseName.toLowerCase()
181-
}
182-
}
183-
}
184-
185-
def makeChangelog() {
186-
def changelogText = file("./CHANGELOG.md").text;
187-
188-
def output = "";
189-
def readLines = false
190-
for (line in changelogText.lines()) {
191-
if (line.startsWith("### ") || line.startsWith("## ")) {
192-
if (readLines) {
193-
break;
194-
}
195-
196-
if (line.contains("${mod_version}") && line.startsWith("### ")) {
197-
readLines = true;
198-
}
199-
}
200-
if (readLines) {
201-
output += line + "\n";
202196
}
203197
}
204-
205-
return output.trim();
206-
}
207-
208-
209-
tasks.register("testChangelog") {
210-
group = "tests"
211-
212-
doLast {
213-
println makeChangelog()
214-
}
215-
}
216-
217-
publishMods {
218-
dryRun = providers.environmentVariable("CURSE_TOKEN").getOrNull() == null
219-
file = jar.archiveFile
220-
changelog = makeChangelog()
221-
type = STABLE
222-
223-
modLoaders.add("neoforge")
224-
modLoaders.add("forge")
225-
226-
curseforge {
227-
projectId = "351748"
228-
accessToken = providers.environmentVariable("CURSE_TOKEN")
229-
minecraftVersions.add(project.mc_version)
230-
231-
optional {
232-
slug = "charging-gadgets"
198+
repositories {
199+
maven {
200+
url "file://${project.projectDir}/repo"
233201
}
234202
}
235-
236-
github {
237-
repository = "direwolf20-mc/MiningGadgets"
238-
accessToken = providers.environmentVariable("GITHUB_TOKEN")
239-
commitish = providers.environmentVariable("GITHUB_SHA").orElse("dryRun")
240-
tagName = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryRun")
241-
}
242203
}
243204

244205
tasks.withType(JavaCompile).configureEach {

0 commit comments

Comments
 (0)