Skip to content

Commit 5017c3b

Browse files
committed
Trash from last night.
0 parents  commit 5017c3b

21 files changed

+678
-0
lines changed

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# eclipse
2+
bin
3+
*.launch
4+
.settings
5+
.metadata
6+
.classpath
7+
.project
8+
9+
# idea
10+
# out is custom output folder too
11+
out
12+
*.ipr
13+
*.iws
14+
*.iml
15+
.idea
16+
17+
# gradle
18+
build
19+
.gradle
20+
21+
# other
22+
eclipse
23+
24+
# custom
25+
run
26+
runClient
27+
runServer
28+
archive
29+
logs

build.gradle

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
// Sqaaakoi's Fabric Mod Build Script
2+
// Version 1.0
3+
4+
plugins {
5+
id 'fabric-loom' version '0.8-SNAPSHOT'
6+
id 'maven-publish'
7+
}
8+
9+
sourceCompatibility = JavaVersion.VERSION_16
10+
targetCompatibility = JavaVersion.VERSION_16
11+
12+
import groovy.json.JsonSlurper
13+
14+
// Build time
15+
def date = new Date()
16+
def time = date.format("yyyy-MM-dd'T'HH:mm:ssZ")
17+
def version_time = date.format("dd-MM-yyyy'_'HH-mm-ss")
18+
def folder_time = date.format("dd-MM-yyyy'/'HH-mm-ss")
19+
20+
// Configuration
21+
22+
def config = new JsonSlurper().parseText(new File("./config.json"))
23+
24+
// Mod metadata
25+
def mod = [
26+
id: config.get("mod").get("id"),
27+
name: config.get("mod").get("name"),
28+
version: config.get("mod").get("version"),
29+
version: config.get("mod").get("authors")
30+
]
31+
32+
// Package name
33+
def packageGroup = config.get("package")
34+
35+
// Versions
36+
def dep_versions = [
37+
minecraft: config.get("dependencies").get("minecraft"),
38+
mappings: config.get("dependencies").get("mappings"),
39+
fabric_loader: config.get("dependencies").get("fabric_loader"),
40+
fabric_api: config.get("dependencies").get("fabric_api"),
41+
]
42+
43+
// Fuck all this shit code below.
44+
45+
// Minecraft user login
46+
// Warning: By enabling the boolean below or using the argument -Pl=; you understand that this script will access your minecraft launcher_settings.json file.
47+
// This script does not have any way to prevent your user token from being printed so be careful to not leak it.
48+
boolean autoLogin = true
49+
// Override for launcher_settings.json file.
50+
def loginFile = null
51+
52+
def loginArg = project.getProperties().get("l")
53+
def profile = [
54+
use: true,
55+
login: false,
56+
name: "",
57+
id: "",
58+
token: "",
59+
type: ""
60+
]
61+
62+
// What the fuck is this shit.
63+
if ((loginArg == null && autoLogin) || loginArg == ";") {
64+
File accountFile = null;
65+
if (loginFile == null) {
66+
def home = System.getProperty("user.home", ".")
67+
def os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH)
68+
def gameDir = home + "/.minecraft"
69+
if (os.contains("win") && System.getenv("appdata") != null) {
70+
gameDir = System.getenv("appdata") + "/.minecraft"
71+
} else if (osType.contains("mac")) {
72+
gameDir = home + "/Library/Application Support/minecraft"
73+
}
74+
accountFile = new File(gameDir, "launcher_accounts.json")
75+
} else {
76+
accountFile = new File(loginFile);
77+
}
78+
if (!accountFile.exists()) {
79+
profile.use = false
80+
} else {
81+
def json = new JsonSlurper()
82+
def accounts = json.parseText(accountFile.text)
83+
def account = accounts.get("accounts").get(accounts.get("activeAccountLocalId"))
84+
profile.name = account.get("minecraftProfile").get("name")
85+
profile.id = account.get("minecraftProfile").get("id")
86+
// WARNING: This value may be an empty string, as the value is now stored in the credential manager as MCL|id
87+
profile.token = account.get("accessToken")
88+
profile.type = account.get("type").toLowerCase()
89+
profile.login = true
90+
}
91+
} else if ((loginArg == null && !autoLogin) || loginArg == "/") {
92+
profile.use = false
93+
} else {
94+
profile.name = loginArg
95+
}
96+
97+
// Setup run folder from template
98+
if (!file('runClient').exists()) {
99+
copy {
100+
from("run_template")
101+
into("runClient")
102+
}
103+
}
104+
105+
def release = project.getProperties().get("release") != null
106+
107+
version = mod.version + (release ? "" : "+" + version_time)
108+
group = packageGroup
109+
archivesBaseName = mod.id
110+
libsDirName = "../out/${folder_time}"
111+
112+
compileJava {
113+
options.compilerArgs << "-Xlint"
114+
options.compilerArgs << "-Xlint:-processing"
115+
}
116+
117+
repositories {
118+
// Add repositories to retrieve artifacts from in here.
119+
// You should only use this when depending on other mods because
120+
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
121+
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
122+
// for more information about repositories.
123+
flatDir {
124+
dirs 'libs'
125+
}
126+
}
127+
128+
dependencies {
129+
// Nullable annotations
130+
implementation 'com.google.code.findbugs:jsr305:3.0.2'
131+
// To change the versions see the dep_versions object
132+
minecraft "com.mojang:minecraft:${dep_versions.minecraft}"
133+
mappings "net.fabricmc:yarn:" + dep_versions.map + ":v2"
134+
modImplementation "net.fabricmc:fabric-loader:${dep_versions.fabric_loader}"
135+
136+
// Fabric API. This is technically optional, but you probably want it anyway.
137+
modImplementation "net.fabricmc.fabric-api:fabric-api:${dep_versions.fabric_api}"
138+
139+
for (libfile in config.get("mod").get("libraries")) {
140+
modImplementation name: libfile
141+
}
142+
143+
144+
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
145+
// You may need to force-disable transitiveness on them.
146+
}
147+
148+
loom {
149+
def awf = file("src/main/resources/${mod.id}.accesswidener")
150+
if (awf.exists()) {
151+
if (!awf.text.replace("\n", "").replace("\r", "").replace(" ", "").isEmpty()) {
152+
accessWidener = awf
153+
}
154+
}
155+
runs {
156+
client {
157+
inherit client
158+
name = "Run Client"
159+
runDir "runClient"
160+
remapMod = true
161+
if (profile.use) {
162+
programArgs "--username", profile.name
163+
if (profile.login) {
164+
programArgs "--uuid", profile.id
165+
programArgs "--accessToken", profile.token
166+
programArgs "--userType", profile.type
167+
}
168+
}
169+
}
170+
server {
171+
inherit server
172+
name = "Run Server"
173+
runDir "runServer"
174+
remapMod = true
175+
}
176+
}
177+
}
178+
179+
processResources {
180+
inputs.property "version", project.version
181+
182+
filesMatching("fabric.mod.json") {
183+
expand "version": project.version
184+
}
185+
}
186+
187+
tasks.withType(JavaCompile).configureEach {
188+
// ensure that the encoding is set to UTF-8, no matter what the system default is
189+
// this fixes some edge cases with special characters not displaying correctly
190+
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
191+
// If Javadoc is generated, this must be specified in that task too.
192+
it.options.encoding = "UTF-8"
193+
194+
it.options.release = 16
195+
}
196+
197+
java {
198+
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
199+
// if it is present.
200+
// If you remove this line, sources will not be generated.
201+
withSourcesJar()
202+
}
203+
204+
jar {
205+
from("LICENSE") {
206+
rename { "${it}_${project.archivesBaseName}"}
207+
}
208+
}
209+
210+
// configure the maven publication
211+
publishing {
212+
publications {
213+
mavenJava(MavenPublication) {
214+
// add all the jars that should be included when publishing to maven
215+
artifact(remapJar) {
216+
builtBy remapJar
217+
}
218+
artifact(sourcesJar) {
219+
builtBy remapSourcesJar
220+
}
221+
}
222+
}
223+
224+
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
225+
repositories {
226+
// Add repositories to publish to here.
227+
// Notice: This block does NOT have the same function as the block in the top level.
228+
// The repositories here will be used for publishing your artifact, not for
229+
// retrieving dependencies.
230+
}
231+
}

config.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"package": "example.minecraft_mods"
3+
"mod": {
4+
"id": "template",
5+
"name": "Template Mod",
6+
"version": "0.0",
7+
"authors": ["Developer"]
8+
},
9+
"dependencies": {
10+
"minecraft": "1.17.1",
11+
"mappings": "1.17.1+build.39",
12+
"fabric_loader": "0.11.6",
13+
"fabric_api": "0.39.2+1.17",
14+
"libraries": []
15+
}
16+
}

gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.jvmargs=-Xmx4G
2+
org.gradle.daemon=true
3+
# 30 minute idle timeout for Gradle Daemon
4+
org.gradle.daemon.idletimeout=18000000

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)