Skip to content

Commit

Permalink
Bug fixes and updates
Browse files Browse the repository at this point in the history
- Updated to new Mossy build system
- Changed mod ID from `my_totem_doll` to `my-totem-doll`
- Fixed totem activation rendering
- Little fixes
  • Loading branch information
LopyMine committed Jul 22, 2024
1 parent a742edb commit 194c723
Show file tree
Hide file tree
Showing 78 changed files with 616 additions and 533 deletions.
292 changes: 173 additions & 119 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "fabric-loom" version "1.7-SNAPSHOT"
id "dev.kikugie.j52j" version "1.0.2"
id "fabric-loom" version "1.6-SNAPSHOT"
id "dev.kikugie.j52j" version "1.0.2"
}

def modId = project.mod_id
Expand All @@ -15,136 +15,151 @@ def modLicense = project.mod_license
def minecraftVersion = stonecutter.current.version.toString() // Current MC version from "./versions/" folder
def lombokVersion = project.lombok_version
def fabricLoader = findProperty("build.fabric_loader")
def javaVersion = findProperty("build.java")

def javaVersionAsInt = getJavaVersionAsInteger(minecraftVersion)
def javaVersion = JavaVersion.toVersion(javaVersionAsInt)
println "Using ${javaVersion.toString()} Java"
def fabricAPI = findProperty("build.fabric_api")

version = "${modVersion}+${stonecutter.current.version}"
group = modMavenGroup

j52j {
sources(sourceSets["main"])
sources(sourceSets["main"])
}

base {
archivesName = modName
archivesName = modName
}

repositories {
maven { url "https://maven.quiltmc.org/repository/release/" } // Stil for YACL
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } // Stil for YACL
maven {
name "Terraformers" // ModMenu
url "https://maven.terraformersmc.com/"
}
maven {
name 'Xander Maven' // YACL
url 'https://maven.isxander.dev/releases'
}
maven { url "https://maven.quiltmc.org/repository/release/" } // Stil for YACL
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } // Stil for YACL
maven {
name "Terraformers" // ModMenu
url "https://maven.terraformersmc.com/"
}
maven {
name 'Xander Maven' // YACL
url 'https://maven.isxander.dev/releases'
}
maven {
url "https://maven.nucleoid.xyz/"
name "Nucleoid"
} // For Mod Menu, because at 1.20.4 it needs PlaceHolder API, see https://github.com/TerraformersMC/ModMenu/issues/752
}
// For Mod Menu, because at 1.20.4 it needs PlaceHolder API, see https://github.com/TerraformersMC/ModMenu/issues/752
}

dependencies {
minecraft "com.mojang:minecraft:${minecraftVersion}"
mappings "net.fabricmc:yarn:${findProperty("build.yarn")}:v2"
modImplementation "net.fabricmc:fabric-loader:${fabricLoader}"
minecraft "com.mojang:minecraft:${minecraftVersion}"
mappings "net.fabricmc:yarn:${findProperty("build.yarn")}:v2"
modImplementation "net.fabricmc:fabric-loader:${fabricLoader}"

// Lombok
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
// Lombok
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"

// Fabric API
// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabricAPI}"

// Mod Menu
modImplementation "com.terraformersmc:modmenu:${findProperty("dep.modmenu")}"
if (stonecutter.compare(minecraftVersion, "1.20.4") == 0) {
modImplementation "eu.pb4:placeholder-api:2.4.0-pre.1+1.20.4"
} // For Mod Menu, because at 1.20.4 it needs PlaceHolder API, see https://github.com/TerraformersMC/ModMenu/issues/752

// YACL
def minecraftVersionsWithOldYACLMaven = Set.of("1.19.4", "1.20", "1.20.2", "1.20.3")
if (minecraftVersionsWithOldYACLMaven.contains(minecraftVersion)) {
def property = findProperty("dep.yacl").toString()
def i = property.lastIndexOf("-")
if (i != -1) {
property = property.substring(0, i)
}
modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${property}"
} else {
modImplementation "dev.isxander:yet-another-config-lib:${findProperty("dep.yacl")}"
}
// Mod Menu
modImplementation "com.terraformersmc:modmenu:${findProperty("dep.modmenu")}"

// YACL
def minecraftVersionsWithOldYACLMaven = Set.of("1.19.4", "1.20", "1.20.2", "1.20.3")
if (minecraftVersionsWithOldYACLMaven.contains(minecraftVersion)) {
def property = findProperty("dep.yacl").toString()
def i = property.lastIndexOf("-")
if (i != -1) {
property = property.substring(0, i)
}
modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${property}"
} else {
modImplementation "dev.isxander:yet-another-config-lib:${findProperty("dep.yacl")}"
}
}

loom {
mixin {
defaultRefmapName.set("${modId}.refmap.json")
}

def accessWidenerFile = project.rootProject.file("src/main/resources/aws/${minecraftVersion}.accesswidener")
if (accessWidenerFile.exists()) {
accessWidenerPath = accessWidenerFile
}

def playerProperties = getPlayerProperties()
def playerNickname = playerProperties.get("player_nickname") // Your in-game nickname
def playerUuid = playerProperties.get("player_uuid") // Your in-game uuid

runConfigs.configureEach { config ->
config.setIdeConfigGenerated(true) // generate IDE tasks for running client, server and testmod, datagen if those are present
config.setRunDir("../../runs/${config.environment}") // use a global run directory for all versions

if (config.getEnvironment() == "client") { // setting player properties from "./players/player.properties" file
if (playerNickname != null) {
config.programArgs("--username", playerNickname.toString())
}
if (playerUuid != null) {
config.programArgs("--uuid", playerUuid.toString())
}
}
}
mixin {
defaultRefmapName.set("${modId}.refmap.json")
}

def accessWidenerFile = project.rootProject.file("src/main/resources/aws/${minecraftVersion}.accesswidener")
if (accessWidenerFile.exists()) {
accessWidenerPath = accessWidenerFile
}

def playerProperties = getPlayerProperties()

def playerNicknameProperty = playerProperties.get("player_nickname").toString() // Your in-game nickname
def playerNickname = getNickname(playerNicknameProperty)

def playerUuidProperty = playerProperties.get("player_uuid").toString() // Your in-game uuid
def playerUuid = getUUID(playerUuidProperty, playerUuidProperty.indexOf("-") == -1)

runConfigs.configureEach { config ->
config.setIdeConfigGenerated(true) // generate IDE tasks for running client, server and testmod, datagen if those are present
config.setRunDir("../../runs/${config.environment}") // use a global run directory for all versions

if (config.getEnvironment() == "client") { // setting player properties from "./players/player.properties" file
if (playerNickname != null) {
config.programArgs("--username", playerNickname.toString())
}
if (playerUuid != null) {
config.programArgs("--uuid", playerUuid.toString())
}
}
}
}

processResources {
def props = [:]
props.put("mod_id", modId.toString())
def props = [:]
props.put("mod_id", modId.toString())
props.put("mod_authors", modAuthors.toString())
props.put("mod_group", modMavenGroup)
props.put("mod_description", modDescription.toString())
props.put("mod_name", modName.toString())
props.put("mod_license", modLicense .toString())
props.put("version", version.toString())
props.put("fabric_loader", fabricLoader.toString())
props.put("minecraft", minecraftVersion.toString())
props.put("java", javaVersion.toString())
props.put("fabric_api", fabricAPI.toString())

props.each { key, value ->
inputs.property key, value
}

filesMatching(["fabric.mod.json"]) {
expand(props)
}

filesMatching("aws/*.accesswidener") {
if (!it.getName().startsWith(minecraftVersion)) {
it.exclude()
}
}

filesMatching("mixins/*.mixins.json5") {
if (!it.getName().startsWith(minecraftVersion)) {
it.exclude()
}
}
props.put("mod_license", modLicense.toString())
props.put("version", version.toString())
props.put("fabric_loader", fabricLoader.toString())
props.put("minecraft", minecraftVersion.toString())
props.put("java", javaVersionAsInt.toString())
props.put("fabric_api", fabricAPI.toString())
props.put("fabric_api_id", stonecutter.compare("1.19.1", minecraftVersion) >= 0 ? "fabric" : "fabric-api")

props.each { key, value ->
inputs.property key, value
}

filesMatching("mixins/yacl/*.mixins.json5") {
filesMatching(["fabric.mod.json"]) {
expand(props)
}

filesMatching("aws/*.accesswidener") {
if (!it.getName().startsWith(minecraftVersion)) {
it.exclude()
}
}

filesMatching("mixins/yacl/*.mixins.json5") {
def fileName = it.getName().toString()
def index = fileName.indexOf('-')
if (index != -1 && fileName.substring(0, index) == minecraftVersion) {
expand(props)
} else {
it.exclude()
}
}

filesMatching("mixins/*.mixins.json5") {
def fileName = it.getName().toString()
def index = fileName.indexOf('-')
if (index != -1 && fileName.substring(0, index) == minecraftVersion) {
expand(props)
} else {
it.exclude()
}
}
}

stonecutter {
Expand All @@ -157,7 +172,7 @@ stonecutter {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = (javaVersion as int)
it.options.release = (javaVersionAsInt as int)
}

tasks.register('buildAndCollect', Copy) {
Expand All @@ -168,32 +183,71 @@ tasks.register('buildAndCollect', Copy) {
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

def java = javaVersion as int
def ver = java > 17 ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
sourceCompatibility = ver
targetCompatibility = ver
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
}

String getNickname(String nickname) {
if (nickname == null) {
return null
}
if (!nickname.matches('^[a-zA-Z0-9_]{2,16}$')) {
println "WARNING — Your nickname is wrong, using default nickname 'Player'"
return "Player"
}
return nickname
}

UUID getUUID(String uuid, boolean undashed) {
if (uuid == null) {
return null
}
try {
if (undashed) {
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", '$1-$2-$3-$4-$5'))
}
return UUID.fromString(uuid)
} catch (Exception e) {
e.printStackTrace()
}
println "WARNING — Your UUID is wrong, failed to parse it"
return null
}

// Cannot be static!
int getJavaVersionAsInteger(String minecraftVersion) {
return stonecutter.compare("1.20.5", minecraftVersion) == 1 ?
stonecutter.compare("1.18", minecraftVersion) == 1 ?
stonecutter.compare("1.17", minecraftVersion) == 1 ?
8
:
16
:
17
:
21
}

Properties getPlayerProperties() {
def playerProperties = new Properties()
def playerPropertiesFile = project.rootProject.file("player/player.properties")
if (playerPropertiesFile.exists()) {
playerPropertiesFile.withInputStream { stream ->
playerProperties.load(stream)
}
} else {
println("Failed to find player properties at ${playerPropertiesFile}")
}
return playerProperties
}
def properties = new Properties()
def playerPropertiesFile = project.rootProject.file("player/player.properties")
if (playerPropertiesFile.exists()) {
playerPropertiesFile.withInputStream { stream ->
properties.load(stream)
}
} else {
println("Failed to find player properties at ${playerPropertiesFile}")
}
return properties
}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx5G
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=false

# Mod Properties
mod_id = my_totem_doll
mod_id = my-totem-doll
mod_name = My Totem Doll
mod_version = 1.0.0
mod_version = 1.0.1
mod_group = net.lopymine.mtd

mod_description = Simple Fabric mod which replaces all totems with player dolls.
Expand Down
Binary file added img/banner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/discord_banner.png
Binary file not shown.
Loading

0 comments on commit 194c723

Please sign in to comment.