Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Taskeren committed Aug 19, 2024
0 parents commit 250502b
Show file tree
Hide file tree
Showing 58 changed files with 4,671 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This is the universal Text Editor Configuration
# for all GTNewHorizons projects
# See: https://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.kt]
indent_style = tab

[*.{bat,ini}]
end_of_line = crlf

[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
indent_size = 2

[*.lang]
trim_trailing_whitespace = false
44 changes: 44 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
* text eol=lf

*.[jJ][aA][rR] binary

*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary

*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary

*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary

*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary

*.[pP][aA][tT][cC][hH] -text

*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf

*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
13 changes: 13 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

name: Build and test

on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]

jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

name: Release tagged build

on:
push:
tags: [ '*' ]

permissions:
contents: write

jobs:
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.gradle
.settings
/.idea/
/.vscode/
/run/
/build/
/eclipse/
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
*.ipr
*.iws
src/main/resources/mixins.*([!.]).json
*.bat
*.DS_Store
!gradlew.bat
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Taskeren

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Overpowered

Yes, they are Overpowered as intended.

This mod is designed for GTNH the modpack.

### Dev Tips

Since I love Kotlin so much, so this project is mainly based on Kotlin.
And you may wonder, what's wrong with my IDEA, which the vanilla classes are not accessible?

So it is something wrong with RetroFuturaGradle (RFG). But somehow the K2 Mode fixes it!

Check out [here](https://github.com/GTNewHorizons/RetroFuturaGradle/issues/51#issuecomment-2067429880).
127 changes: 127 additions & 0 deletions addon.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
apply plugin: "org.jetbrains.kotlin.jvm"

private static String trimStart(String str) {
def i = 0
for (; i < str.length(); i++) {
if (str[i] != ' ' && str[i] != '\t') {
break
}
}
return str.substring(i)
}

String.metaClass.trimStart = { -> trimStart((String) delegate) }

private static String applyColorFormatting(String str, String symbol = '&') {
def validFormatCode = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
'k', 'l', 'm', 'n', 'o', 'r'
]

validFormatCode.forEach { code ->
str = str.replace("${symbol}${code}", "§${code}")
}

return str
}

String.metaClass.applyColorFormat = { String symbol = '&' -> applyColorFormatting((String) delegate, symbol) }

tasks.build {
// make sure the language file is up-to-date when building.
// but you still need to self-update it when running dev clients (e.g. `runClient21`).
dependsOn "generatedLanguageFiles"
}

tasks.register("generateLanguageFiles") {
group = "overpowered"

doLast {
def sources = [sourceSets.main.allSource]
// the locales to be recognized
def languages = ["en", "zh", "tw"]

Map<String, StringBuilder> languageFileBuilders = [:]
// init all string builders
languages.forEach {
languageFileBuilders[it] = new StringBuilder("# This file is auto-generated. Don't modify!\n\n")
}

// iterate source sets like main/java or main/kotlin
for (final def src in sources) {
// iterate the files in the source set
src.each { file ->
// filter non code files
if(!(file.name.endsWith(".java") || file.name.endsWith(".kt"))) return

// 0 - IDLE, looking for key
// 1 - Keyed, looking for any value, or next key
def state = 0

def key = null
// [key, [locale, text]]
Map<String, Map<String, String>> value = [:]

// iterate all the text lines
file.text.eachLine { line, index ->
// `rawLine` is used for debugging
def rawLine = line

// remove whitespaces before the first non-ws character
line = line.trimStart()

// find the keyword
if (line.startsWith("// #tr ")) {
key = line.substring("// #tr ".length())
value[key] = [:]
state = 1
}
if (line.startsWith("// #")) {
line = line.substring("// #".length())
languages.forEach { lang ->
if (line.startsWith(lang)) {
if (state == 1) {
def v = line.substring(lang.length()).trim().applyColorFormat()
if (v.endsWith("\\")) {
v.substring(0, v.length() - 1)
}
value[key][lang] = v
} else {
// print error message
println "Dangling TranslatedCode found"
println "${file}:${index + 1}: ${rawLine.trim()}"
}
}
}
} else {
state = 0
}
}

// put file name
languages.forEach { String lang ->
languageFileBuilders[lang].append("# ${rootDir.relativePath(file)}").append("\n")
}
// put kv pairs
value.forEach { k, localizedValues ->
localizedValues.forEach { lang, v ->
languageFileBuilders[lang].append("${k}=${v}").append("\n")
}
}
}
}

/*
languageFileBuilders.forEach { locale, sb ->
println "${locale}\n${sb.toString()}"
}
*/

// you need to create these files manually!

file("${rootDir}/src/main/resources/assets/Overpowered/lang/en_US.lang").write(languageFileBuilders["en"].toString(), "UTF-8")
file("${rootDir}/src/main/resources/assets/Overpowered/lang/zh_CN.lang").write(languageFileBuilders["zh"].toString(), "UTF-8")
file("${rootDir}/src/main/resources/assets/Overpowered/lang/zh_TW.lang").write(languageFileBuilders["tw"].toString(), "UTF-8")
}
}
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'com.gtnewhorizons.gtnhconvention'
}
47 changes: 47 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
/* tip: find dependencies at https://nexus.gtnewhorizons.com/ */

runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Forgelin:1.10.0-GTNH:dev")

implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.48.66:dev")
implementation("com.github.GTNewHorizons:NewHorizonsCoreMod:2.5.16:dev")

// FIXME: publish TST to somewhere else
implementation("com.github.GTNewHorizons:Twist-Space-Technology-Mod:0.5.8-publish.11+344150b931-dirty")
}
Loading

0 comments on commit 250502b

Please sign in to comment.