-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 39f9f5c
Showing
59 changed files
with
1,321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
plugins { | ||
id 'fabric-loom' | ||
id 'maven-publish' | ||
id "org.jetbrains.kotlin.jvm" | ||
} | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
archivesBaseName = project.archives_base_name | ||
version = project.mod_version | ||
group = project.maven_group | ||
|
||
repositories { | ||
// Add repositories to retrieve artifacts from in here. | ||
// You should only use this when depending on other mods because | ||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically. | ||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html | ||
// for more information about repositories. | ||
} | ||
|
||
dependencies { | ||
//to change the versions see the gradle.properties file | ||
minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" | ||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||
|
||
// Fabric API. This is technically optional, but you probably want it anyway. | ||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||
|
||
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" | ||
|
||
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. | ||
// You may need to force-disable transitiveness on them. | ||
} | ||
|
||
processResources { | ||
inputs.property "version", project.version | ||
|
||
from(sourceSets.main.resources.srcDirs) { | ||
include "fabric.mod.json" | ||
expand "version": project.version | ||
} | ||
|
||
from(sourceSets.main.resources.srcDirs) { | ||
exclude "fabric.mod.json" | ||
} | ||
} | ||
|
||
// ensure that the encoding is set to UTF-8, no matter what the system default is | ||
// this fixes some edge cases with special characters not displaying correctly | ||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html | ||
tasks.withType(JavaCompile) { | ||
it.options.encoding = "UTF-8" | ||
|
||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too | ||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. | ||
// We'll use that if it's available, but otherwise we'll use the older option. | ||
def targetVersion = 8 | ||
if (JavaVersion.current().isJava9Compatible()) { | ||
it.options.release = targetVersion | ||
} | ||
} | ||
|
||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task | ||
// if it is present. | ||
// If you remove this task, sources will not be generated. | ||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
classifier = "sources" | ||
from sourceSets.main.allSource | ||
} | ||
|
||
jar { | ||
from ("LICENSE") { | ||
rename { "${it}_${project.archivesBaseName}"} | ||
} | ||
} | ||
|
||
// configure the maven publication | ||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
// add all the jars that should be included when publishing to maven | ||
artifact(remapJar) { | ||
builtBy remapJar | ||
} | ||
artifact(sourcesJar) { | ||
builtBy remapSourcesJar | ||
} | ||
} | ||
} | ||
|
||
// select the repositories you want to publish to | ||
repositories { | ||
// uncomment to publish to the local maven | ||
// mavenLocal() | ||
} | ||
} | ||
|
||
compileKotlin.kotlinOptions.jvmTarget = "1.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
kotlin.code.style=official | ||
org.gradle.jvmargs=-Xmx1G | ||
|
||
# Fabric Properties | ||
# Check these on https://modmuss50.me/fabric.html | ||
minecraft_version=1.16.5 | ||
yarn_mappings=1.16.5+build.6 | ||
loader_version=0.11.3 | ||
|
||
#Fabric api | ||
fabric_version=0.32.9+1.16 | ||
|
||
loom_version=0.6-SNAPSHOT | ||
|
||
# Mod Properties | ||
mod_version = 1.0.0 | ||
maven_group = club.someoneice.ovo | ||
archives_base_name = ovo | ||
|
||
# Kotlin | ||
kotlin_version=1.4.31 | ||
fabric_kotlin_version=1.5.0+kotlin.1.4.31 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"ovotest" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"name": "test_block", | ||
"hard": 1.0, | ||
"drop_item": "null", | ||
"group": "testgroup" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"name": "testgroup", | ||
"icon": "minecraft:apple" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
{ | ||
"name": "test_item", | ||
"max_size": 64, | ||
"group": "testgroup" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"name": "test_food", | ||
"max_size": 64, | ||
"hunger": 5, | ||
"saturation": 0.2, | ||
"wolf": false, | ||
"always_eat": true, | ||
"fast_food": false, | ||
"isDrink": false, | ||
"return_item": "null", | ||
"group": "testgroup" | ||
} | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"name": "test_axe", | ||
"attackDamage": 0, | ||
"toolkit": "axe", | ||
"tool_meta": "iron", | ||
"group": "testgroup" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"name": "pineapple_knife", | ||
"attackDamage": 0, | ||
"tool_meta": "iron", | ||
"group": "testgroup" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"modid": "ovotest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package club.someoneice.ovo | ||
|
||
import club.someoneice.ovo.core.CoreRunner | ||
import org.apache.logging.log4j.Logger | ||
import org.apache.logging.log4j.LogManager | ||
|
||
object OVOMain { | ||
const val modid: String = "ovo" | ||
val Logger: Logger = LogManager.getLogger(modid) | ||
} | ||
|
||
fun init() { | ||
CoreRunner() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
package club.someoneice.ovo.core | ||
|
||
import club.someoneice.ovo.OVOMain | ||
import club.someoneice.ovo.json.Sandman | ||
import club.someoneice.ovo.json.helper.JsonProcessor | ||
import club.someoneice.ovo.json.reader.Group | ||
import club.someoneice.ovo.json.reader.Item | ||
import club.someoneice.ovo.json.reader.* | ||
import com.google.common.reflect.TypeToken | ||
import com.google.gson.Gson | ||
import java.io.BufferedReader | ||
import java.io.File | ||
import java.io.FileNotFoundException | ||
import java.io.FileReader | ||
import java.util.* | ||
import kotlin.collections.List | ||
|
||
class CoreRunner { | ||
private val gson: Gson = Gson() | ||
private val basePath: String = "${System.getProperty("user.dir")}\\ovo" | ||
private val packageInfoFilePath: File = File("$basePath\\ovo_package.json") | ||
private var packagePathList = ArrayList<String>() | ||
|
||
private val group = Group() | ||
private val item = Item() | ||
private val food = ItemFoods() | ||
private val gift = ItemGifts() | ||
private val tool = ItemTools() | ||
private val swords = ItemSwords() | ||
private val block = ItemBlocks() | ||
|
||
private val JsonProcessor = JsonProcessor(group, item, block, food, gift, swords, tool) | ||
|
||
init { | ||
try { | ||
if (!packageInfoFilePath.isFile) { | ||
OVOMain.Logger.info("ovo_package.json is not find!") | ||
Sandman.nullSandman() | ||
} else { | ||
readerPackage() | ||
init() | ||
} | ||
} catch (_: FileNotFoundException) { | ||
throw FileNotFoundException("package.json is not find!") | ||
Sandman.nullSandman() | ||
} | ||
} | ||
|
||
private fun init() { | ||
if (packagePathList.size < 1) return | ||
for (i in packagePathList){ | ||
if (!File("${basePath}\\${i}").isDirectory || !File("${basePath}\\${i}\\info.json").isFile) { | ||
continue | ||
} else { | ||
OVOMain.Logger.info("Such package: ${basePath}\\${i}") | ||
val modid: String? = readInfo(File("${basePath}\\${i}\\info.json")) | ||
getFile("${basePath}\\${i}") | ||
|
||
DataProcessor(modid) | ||
|
||
// Finish read this package, and now clear the DataList. | ||
DataClearer() | ||
} | ||
} | ||
} | ||
|
||
private fun getFile(baseFile: String) { | ||
if (File("${baseFile}\\Group.json").isFile) { | ||
OVOMain.Logger.info("Such File: ${baseFile}\\Group.json") | ||
// group.getToolType(JsonProcessor, File("${baseFile}\\Group.json")) | ||
group.init(File("${baseFile}\\Group.json")) | ||
} | ||
|
||
|
||
if (File("${baseFile}\\Item.json").isFile) { | ||
item.getToolType(JsonProcessor, File("${baseFile}\\Item.json")) | ||
} else if (File("${baseFile}\\Item").isDirectory) { | ||
val fileList: Array<File> = File("${baseFile}\\Item").listFiles() as Array<File> | ||
for (i in fileList) { | ||
item.getToolType(JsonProcessor, i) | ||
} | ||
} | ||
|
||
if (File("${baseFile}\\ItemFood.json").isFile) { | ||
food.getToolType(JsonProcessor, File("${baseFile}\\ItemFood.json")) | ||
} else if (File("${baseFile}\\ItemFood").isDirectory) { | ||
val fileList: Array<File> = File("${baseFile}\\ItemFood").listFiles() as Array<File> | ||
for (i in fileList) { | ||
food.getToolType(JsonProcessor, i) | ||
} | ||
} | ||
|
||
if (File("${baseFile}\\ItemGift.json").isFile) { | ||
gift.getToolType(JsonProcessor, File("${baseFile}\\ItemGift.json")) | ||
} else if (File("${baseFile}\\ItemGift").isDirectory) { | ||
val fileList: Array<File> = File("${baseFile}\\ItemGift").listFiles() as Array<File> | ||
for (i in fileList) { | ||
gift.getToolType(JsonProcessor, i) | ||
} | ||
} | ||
|
||
if (File("${baseFile}\\ItemTool.json").isFile) { | ||
tool.getToolType(JsonProcessor, File("${baseFile}\\ItemTool.json")) | ||
} else if (File("${baseFile}\\ItemTool").isDirectory) { | ||
val fileList: Array<File> = File("${baseFile}\\ItemTool").listFiles() as Array<File> | ||
for (i in fileList) { | ||
tool.getToolType(JsonProcessor, i) | ||
} | ||
} | ||
|
||
if (File("${baseFile}\\ItemWeapons.json").isFile) { | ||
swords.getToolType(JsonProcessor, File("${baseFile}\\ItemWeapons.json")) | ||
} else if (File("${baseFile}\\ItemWeapons").isDirectory) { | ||
val fileList: Array<File> = File("${baseFile}\\ItemWeapons").listFiles() as Array<File> | ||
for (i in fileList) { | ||
swords.getToolType(JsonProcessor, i) | ||
} | ||
} | ||
|
||
if (File("${baseFile}\\Block.json").isFile) { | ||
block.getToolType(JsonProcessor, File("${baseFile}\\Block.json")) | ||
} else if (File("${baseFile}\\Block").isDirectory) { | ||
val fileList: Array<File> = File("${baseFile}\\Block").listFiles() as Array<File> | ||
for (i in fileList) { | ||
block.getToolType(JsonProcessor, i) | ||
} | ||
} | ||
} | ||
|
||
private fun readerPackage() { | ||
val text = StringBuffer() | ||
val buffreader = BufferedReader(FileReader(packageInfoFilePath)) | ||
|
||
try { | ||
while (true) { | ||
val str = buffreader.readLine() | ||
if (str == null) break else text.append(str.toString()) | ||
} | ||
|
||
buffreader.close() | ||
val output: String = text.toString() | ||
packagePathList = gson.fromJson(output, (object: TypeToken<List<String>> () {} .type) ) | ||
|
||
} catch (_: Exception) { | ||
Sandman.nullSandman() | ||
} | ||
} | ||
|
||
private fun readInfo(infoPath: File): String? { | ||
val text = StringBuffer() | ||
val buffreader = BufferedReader(FileReader(infoPath)) | ||
|
||
try { | ||
while (true) { | ||
val str = buffreader.readLine() | ||
if (str == null) break else text.append(str.toString()) | ||
} | ||
|
||
buffreader.close() | ||
val output: String = text.toString() | ||
val infoList: HashMap<String, String> = gson.fromJson(output, (object: TypeToken<HashMap<String, String>> () {} .type) ) | ||
if (infoList.containsKey("modid")) { | ||
OVOMain.Logger.info("Find modid ${infoList["modid"]}") | ||
return infoList["modid"] | ||
} | ||
|
||
} catch (_: Exception) { | ||
Sandman.nullSandman() | ||
} | ||
|
||
return Sandman.missingNo() as String? | ||
} | ||
} |
Oops, something went wrong.