diff --git a/.gitignore b/.gitignore index 461017f..e23bd4c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,7 @@ out *.ipr *.iws *.iml -.idea/* -!.idea/scopes +.idea # gradle build diff --git a/.idea/scopes/Fabric_sources.xml b/.idea/scopes/Fabric_sources.xml deleted file mode 100644 index 0448412..0000000 --- a/.idea/scopes/Fabric_sources.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/scopes/Forge_sources.xml b/.idea/scopes/Forge_sources.xml deleted file mode 100644 index 7b5f24d..0000000 --- a/.idea/scopes/Forge_sources.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3446c53..85ac657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,22 @@ and this project adheres to [Crystal Nest Semantic Versioning](https://crystalne - Nothing new. -## [4.0.0] - 2024/07/04 +## [v5.0.0] - 2024/07/14 + +- Ported to 1.21. +- Officially dropped support for Forge. +- Cobweb minimum version is now `v1.1.2`. +- Renamed data folder from plural to singular to comply with the new Minecraft standard. +- Added Soft Step as a data driven enchantment. +- Added every leathered boots registered via the API to Minecraft `dyeable` and `foot_armor` item tags too (before they were only in `trimmable_armor` and `freeze_immune_wearables`). +- `BiomesCheck` and `BiomesPredicate` are now both `record`s rather than a final classes. +- `LeatheredArmorMaterial` has been removed due to changes in Minecraft `ArmorMaterial`. +- `LeatheredBootsItem` now take in a `Holder` for the `ArmorMaterial` and a durability factor multiplier. +- `LeatheredBootsItem` now extend `ArmorItem`. +- Changed how `LeatheredBootsItem` are registered: first an instance of `BootsRegister` must be created with `LeatheredBootsManager#register(String)` passing a mod ID, then register each pair of boots one at a time with it. +- A `ResourceLocation` is now required to get a `LeatheredBootsItem` from the `LeatheredBootsManager` instead of a `LeatheredArmorMaterial`. + +## [v4.0.0] - 2024/07/04 - Update to the newest standards. - Add more language translations. @@ -100,7 +115,8 @@ and this project adheres to [Crystal Nest Semantic Versioning](https://crystalne [Unreleased]: https://github.com/crystal-nest/leathered-boots [README]: https://github.com/crystal-nest/leathered-boots#readme -[4.0.0]: https://github.com/crystal-nest/leathered-boots/releases?q=4.0.0 +[v5.0.0]: https://github.com/crystal-nest/leathered-boots/releases?q=5.0.0 +[v4.0.0]: https://github.com/crystal-nest/leathered-boots/releases?q=4.0.0 [1.20.4-3.0.0.0]: https://github.com/crystal-nest/leathered-boots/releases/tag/v1.20.4-3.0.0.0 diff --git a/README.md b/README.md index 6d17c51..7732063 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Leathered Boots banner](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/leathered-boots/banner.gif) --- -![Minecraft](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/minecraft.svg)[![1.20.4](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-4.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.20.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-2.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.20.2)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.1](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-1.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.20.1)![Separator](https://raw.githubusercontent.com/Nyphet/mod-fancy-assets/main/separator.svg)[![1.19.4](https://raw.githubusercontent.com/Nyphet/mod-fancy-assets/main/minecraft/1-19-4.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.19.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.19.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-19-2.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.19.2)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.18.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-18-2.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.18.2) +![Minecraft](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/minecraft.svg)[![1.21](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-21.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.21)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.4](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-4.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.20.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-2.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.20.2)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.20.1](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-20-1.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.20.1)![Separator](https://raw.githubusercontent.com/Nyphet/mod-fancy-assets/main/separator.svg)[![1.19.4](https://raw.githubusercontent.com/Nyphet/mod-fancy-assets/main/minecraft/1-19-4.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.19.4)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.19.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-19-2.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.19.2)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![1.18.2](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/minecraft/1-18-2.svg)](https://modrinth.com/mod/leathered-boots/versions?g=1.18.2) ![Loader](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/loader.svg)[![NeoForge](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/neoforge.svg)](https://modrinth.com/mod/leathered-boots/versions?l=neoforge)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![Forge](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/forge.svg)](https://modrinth.com/mod/leathered-boots/versions?l=forge)![Separator](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/separator.svg)[![Fabric](https://raw.githubusercontent.com/crystal-nest/mod-fancy-assets/main/loader/fabric.svg)](https://modrinth.com/mod/leathered-boots/versions?l=fabric) diff --git a/build.gradle b/build.gradle index f5d450d..006c00d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ plugins { id "org.sonarqube" version "4.4.1.3373" - id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" id "com.hypherionmc.modutils.modpublisher" version "2.1.4" apply false - id "fabric-loom" version "1.5-SNAPSHOT" apply false + id "net.neoforged.moddev" version "0.1.110" apply false + id "fabric-loom" version "1.7-SNAPSHOT" apply false } sonar { properties { - property "sonar.projectKey", "Crystal-Nest_${mod_id_kebab}" + property "sonar.projectKey", "Crystal-Nest_$mod_id_kebab" property "sonar.organization", "crystal-nest" property "sonar.projectVersion", mod_version property "sonar.host.url", "https://sonarcloud.io" @@ -15,239 +15,6 @@ sonar { } } -subprojects { subproject -> - def noPublish = subproject.name === "common" - def isFabric = subproject.name == "fabric" - - apply plugin: "java" - apply plugin: "idea" - apply plugin: "java-library" - apply plugin: "com.hypherionmc.modutils.modpublisher" - apply plugin: "maven-publish" - if (isFabric) { - apply plugin: "fabric-loom" - } - - java.toolchain.languageVersion = JavaLanguageVersion.of(17) - java.withSourcesJar() - java.withJavadocJar() - - archivesBaseName = "${mod_id_kebab}-${subproject.name}" - version = "${minecraft_version}-${mod_version}" - - jar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_title}" } - } - manifest { - attributes([ - "Specification-Title" : mod_title, - "Specification-Vendor" : mod_authors, - "Specification-Version" : project.version, - "Implementation-Title" : mod_title, - "Implementation-Vendor" : mod_authors, - "Implementation-Version" : project.version, - "Implementation-URL" : "https://github.com/${github_user}/${mod_id_kebab}/tree/${minecraft_version}", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - "Timestamp" : System.currentTimeMillis(), - "Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", - "Built-On-Minecraft" : minecraft_version - ]) - } - } - - sourcesJar { - from(rootProject.file("LICENSE")) { - rename { "${it}_${mod_title}" } - } - } - - repositories { - mavenCentral() - maven { - name = "Sponge / Mixin" - url = "https://repo.spongepowered.org/repository/maven-public/" - } - maven { - name = "Crystal Nest" - url = "https://maven.crystalnest.it" - } - exclusiveContent { - forRepository { - maven { - url "https://cursemaven.com" - } - } - filter { - includeGroup "curse.maven" - } - } - } - - tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.getRelease().set(17) - } - - processResources { - def expandProps = [ - "mod_version" : mod_version, - "group" : project.group, - "mod_authors" : mod_authors, - "mod_title" : mod_title, - "mod_id" : mod_id, - "mod_id_kebab" : mod_id_kebab, - "license" : license, - "description" : project.description, - "credits" : credits, - "github_user" : github_user, - "curseforge_id" : curseforge_id, - "minecraft_version" : minecraft_version, - "minecraft_version_range" : minecraft_version_range, - "fabric_version" : fabric_version, - "fabric_loader_version" : fabric_loader_version, - "forge_version" : forge_version, - "forge_loader_version_range" : forge_loader_version_range, - "neoforge_version" : neoforge_version, - "neoforge_loader_version_range": neoforge_loader_version_range, - "cobweb_version" : cobweb_version, - ] - - filesMatching(["pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml", "*.mixins.json"]) { - expand expandProps - } - inputs.properties(expandProps) - } - - tasks.withType(GenerateModuleMetadata).configureEach { - enabled = false - } - - def changelog_body = "See [Changelog](https://github.com/${github_user}/${mod_id_kebab}/blob/master/CHANGELOG.md#v${mod_version.replaceAll('\\.', '')}---${new Date().format("yyyyMMdd")})." - def version_type = mod_version.replaceFirst("([0-9]+\\.?)+-?", "") ?: "release" - def loader = "Common" - switch (subproject.name) { - case "fabric": - loader = "Fabric" - break - case "forge": - loader = "Forge" - break - case "neoforge": - loader = "NeoForge" - break - } - - publishing { - repositories { - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/${github_user}/${mod_id_kebab}") - credentials { - username = github_user - password = System.getenv("GITHUB_TOKEN") ?: "" - } - } - } - publications { - gpr(MavenPublication) { - groupId = project.group - artifactId = "${mod_id_kebab}-${loader.toLowerCase()}" - version = project.version - from components.java - pom { - name = "[${loader} - ${minecraft_version}] ${mod_title} v${mod_version}" - description = "${description}" - url = "https://github.com/${github_user}/${mod_id_kebab}/tree/${minecraft_version}" - issueManagement { - system = "github" - url = "https://github.com/${github_user}/${mod_id_kebab}/issues" - } - licenses { - license { - name = license - url = "https://spdx.org/licenses/${license}.html" - } - } - developers { - mod_authors.split(", ").each { author -> - developer { - id = author.toLowerCase() - name = author - } - } - } - } - } - } - } - - publisher { - apiKeys { - github System.getenv("GITHUB_TOKEN") ?: "" - modrinth System.getenv("MODRINTH_TOKEN") ?: "" - curseforge System.getenv("CURSEFORGE_TOKEN") ?: "" - } - setDebug(noPublish) - setVersion(mod_version) - setChangelog(changelog_body) - setVersionType(version_type) - setArtifact(isFabric ? remapJar : jar) - setDisableMalwareScanner(true) // Disable the built in Fractureizer scanner. - setDisableEmptyJarCheck(true) // Disable check for valid mod metadata entry in artifact, which could possibly mean that the jar is empty. - setModrinthID(mod_id_kebab) - setCurseID(curseforge_id) - if (!noPublish) { - setLoaders(loader) - } - setGameVersions(minecraft_version) - setDisplayName("[${loader} - ${minecraft_version}] ${mod_title} v${mod_version}") - setJavaVersions([JavaVersion.VERSION_17]) - setCurseEnvironment("both") // "server", "client" or "both". - github { - repo = "${github_user}/${mod_id_kebab}" - tag = "v${project.version}" - displayName("v${project.version}") - target = minecraft_version - createTag = true - createRelease = true - updateRelease = true - draft = false - } - modrinthDepends { - required "cobweb" - switch (loader) { - case "Fabric": - required "fabric-api" - break - case "Forge": - break - case "NeoForge": - break - } - } - curseDepends { - required "cobweb" - switch (loader) { - case "Fabric": - required "fabric-api" - break - case "Forge": - break - case "NeoForge": - break - } - } - } - - tasks.register("publishLoader") { - group = "publishing" - description = "Publish ${loader} specific versions to all platforms" - dependsOn "publish" - dependsOn "publishMod" - } -} - tasks.register("publishAll") { group = "publishing" description = "Publish all loader specific versions to all platforms" diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..0aa2ba4 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,3 @@ +plugins { + id "groovy-gradle-plugin" +} diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle new file mode 100644 index 0000000..70d94e3 --- /dev/null +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -0,0 +1,251 @@ +plugins { + id "java-library" + id "maven-publish" + id "com.hypherionmc.modutils.modpublisher" +} + +base { + archivesName = "$mod_id_kebab-$name" + version = "$minecraft_version-$mod_version" +} + +java { + toolchain.languageVersion = JavaLanguageVersion.of(java_version) + withSourcesJar() + withJavadocJar() +} + +tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" + it.options.getRelease().set(java_version as Integer) +} + +repositories { + mavenCentral() + exclusiveContent { + forRepository { + maven { + name = "Sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + } + filter { includeGroupAndSubgroups("org.spongepowered") } + } + exclusiveContent { + forRepositories( + maven { + name = "ParchmentMC" + url = "https://maven.parchmentmc.org/" + }, + maven { + name = "NeoForge" + url = "https://maven.neoforged.net/releases" + } + ) + filter { includeGroup("org.parchmentmc.data") } + } + maven { + name = "Crystal Nest" + url = "https://maven.crystalnest.it" + } + exclusiveContent { + forRepository { + maven { + url "https://cursemaven.com" + } + } + filter { + includeGroup "curse.maven" + } + } +} + +if (name != "fabric") { + dependencies { + implementation "it.crystalnest:cobweb-$name:$minecraft_version-$cobweb_version" + } +} + +["apiElements", "runtimeElements", "sourcesElements", "javadocElements"].each { variant -> + configurations."$variant".outgoing { + capability("$group:${base.archivesName.get()}:$version") + capability("$group:$mod_id-${project.name}-$minecraft_version:$version") + capability("$group:$mod_id:$version") + } + publishing.publications.configureEach { + suppressPomMetadataWarningsFor(variant) + } +} + +sourcesJar { + from(rootProject.file("LICENSE")) { + rename { "${it}_$mod_title" } + } +} + +jar { + from(rootProject.file("LICENSE")) { + rename { "${it}_$mod_title" } + } + manifest { + attributes([ + "Specification-Title" : mod_title, + "Specification-Vendor" : mod_authors, + "Specification-Version" : project.version, + "Implementation-Title" : mod_title, + "Implementation-Vendor" : mod_authors, + "Implementation-Version" : project.version, + "Implementation-URL" : "https://github.com/$github_user/$mod_id_kebab/tree/$minecraft_version", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "Timestamp" : System.currentTimeMillis(), + "Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + "Built-On-Minecraft" : minecraft_version + ]) + } +} + +processResources { + def expandProps = [ + "java_version" : java_version, + "mod_version" : mod_version, + "group" : project.group, + "mod_authors" : mod_authors, + "mod_title" : mod_title, + "mod_id" : mod_id, + "mod_id_kebab" : mod_id_kebab, + "license" : license, + "description" : project.description, + "credits" : credits, + "github_user" : github_user, + "curseforge_id" : curseforge_id, + "minecraft_version" : minecraft_version, + "minecraft_version_range" : minecraft_version_range, + "fabric_version" : fabric_version, + "fabric_loader_version" : fabric_loader_version, + "neoforge_version" : neoforge_version, + "neoforge_loader_version_range": neoforge_loader_version_range, + "cobweb_version" : cobweb_version, + ] + filesMatching(["pack.mcmeta", "fabric.mod.json", "META-INF/neoforge.mods.toml", "*.mixins.json"]) { + expand expandProps + } + inputs.properties(expandProps) +} + +def noPublish = name == "common" +def changelog_body = "See [Changelog](https://github.com/$github_user/$mod_id_kebab/blob/master/CHANGELOG.md#v${mod_version.replaceAll('\\.', '')}---${new Date().format("yyyyMMdd")})." +def version_type = mod_version.replaceFirst("([0-9]+\\.?)+-?", "") ?: "release" +def loader = "Common" +switch (name) { + case "fabric": + loader = "Fabric" + break + case "neoforge": + loader = "NeoForge" + break +} + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/$github_user/$mod_id_kebab") + credentials { + username = github_user + password = System.getenv("GITHUB_TOKEN") ?: "" + } + } + } + publications { + gpr(MavenPublication) { + groupId = project.group + artifactId = "$mod_id_kebab-${loader.toLowerCase()}" + version = project.version + from components.java + pom { + name = "[$loader - $minecraft_version] $mod_title v$mod_version" + description = "$description" + url = "https://github.com/$github_user/$mod_id_kebab/tree/$minecraft_version" + issueManagement { + system = "github" + url = "https://github.com/$github_user/$mod_id_kebab/issues" + } + licenses { + license { + name = license + url = "https://spdx.org/licenses/${license}.html" + } + } + developers { + mod_authors.split(", ").each { author -> + developer { + id = author.toLowerCase() + name = author + } + } + } + } + } + } +} + +publisher { + apiKeys { + github System.getenv("GITHUB_TOKEN") ?: "" + modrinth System.getenv("MODRINTH_TOKEN") ?: "" + curseforge System.getenv("CURSEFORGE_TOKEN") ?: "" + } + setDebug(noPublish) + setVersion(mod_version) + setChangelog(changelog_body) + setVersionType(version_type) + setArtifact(jar) + setDisableMalwareScanner(true) // Disable the built in Fractureizer scanner. + setDisableEmptyJarCheck(true) // Disable check for valid mod metadata entry in artifact, which could possibly mean that the jar is empty. + setModrinthID(mod_id_kebab) + setCurseID(curseforge_id) + if (!noPublish) { + setLoaders(loader) + } + setGameVersions(minecraft_version) + setDisplayName("[$loader - $minecraft_version] $mod_title v$mod_version") + setJavaVersions([JavaVersion.VERSION_21]) // Remember to update this to match java_version gradle property. + setCurseEnvironment("both") // "server", "client" or "both". + github { + repo = "$github_user/$mod_id_kebab" + tag = "v${project.version}" + displayName("v${project.version}") + target = minecraft_version + createTag = true + createRelease = true + updateRelease = true + draft = false + } + modrinthDepends { + required "cobweb" + switch (loader) { + case "Fabric": + required "fabric-api" + break + case "NeoForge": + break + } + } + curseDepends { + required "cobweb" + switch (loader) { + case "Fabric": + required "fabric-api" + break + case "NeoForge": + break + } + } +} + +tasks.register("publishLoader") { + group = "publishing" + description = "Publish $loader specific versions to all platforms" + dependsOn "publish" + dependsOn "publishMod" +} diff --git a/buildSrc/src/main/groovy/multiloader-loader.gradle b/buildSrc/src/main/groovy/multiloader-loader.gradle new file mode 100644 index 0000000..618b808 --- /dev/null +++ b/buildSrc/src/main/groovy/multiloader-loader.gradle @@ -0,0 +1,44 @@ +plugins { + id "multiloader-common" +} + +configurations { + commonJava{ + canBeResolved = true + } + commonResources{ + canBeResolved = true + } +} + +dependencies { + compileOnly(project(":common")) { + capabilities { + requireCapability "$group:$mod_id" + } + } + commonJava project(path: ":common", configuration: "commonJava") + commonResources project(path: ":common", configuration: "commonResources") +} + +tasks.named('compileJava', JavaCompile) { + dependsOn(configurations.commonJava) + source(configurations.commonJava) +} + +processResources { + dependsOn(configurations.commonResources) + from(configurations.commonResources) +} + +tasks.named("javadoc", Javadoc).configure { + dependsOn(configurations.commonJava) + source(configurations.commonJava) +} + +tasks.named("sourcesJar", Jar) { + dependsOn(configurations.commonJava) + from(configurations.commonJava) + dependsOn(configurations.commonResources) + from(configurations.commonResources) +} diff --git a/common/build.gradle b/common/build.gradle index 38e5ecd..4619786 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,19 +1,40 @@ plugins { - id "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT" - id "com.github.johnrengelman.shadow" version "8.1.0" + id "multiloader-common" + id "net.neoforged.moddev" } -minecraft { - version(minecraft_version) - if (file("src/main/resources/${mod_id}.accesswidener").exists()) { - accessWideners(file("src/main/resources/${mod_id}.accesswidener")) +neoForge { + neoFormVersion = neo_form_version + def at = file("src/main/resources/META-INF/accesstransformer.cfg") + if (at.exists()) { + accessTransformers.add(at.absolutePath) + } + parchment { + minecraftVersion = minecraft_version + mappingsVersion = parchment_version } } dependencies { compileOnly group: "org.spongepowered", name: "mixin", version: "0.8.5" - compileOnly group: "io.github.llamalad7", name: "mixinextras-common", version: "0.3.6" - implementation "it.crystalnest:cobweb-common:${minecraft_version}-${cobweb_version}" + compileOnly group: "io.github.llamalad7", name: "mixinextras-common", version: "0.3.5" + annotationProcessor group: "io.github.llamalad7", name: "mixinextras-common", version: "0.3.5" +} + +configurations { + commonJava { + canBeResolved = false + canBeConsumed = true + } + commonResources { + canBeResolved = false + canBeConsumed = true + } +} + +artifacts { + commonJava sourceSets.main.java.sourceDirectories.singleFile + commonResources sourceSets.main.resources.sourceDirectories.singleFile } // Disable publishing tasks where common is not published diff --git a/common/src/main/java/it/crystalnest/leathered_boots/CommonModLoader.java b/common/src/main/java/it/crystalnest/leathered_boots/CommonModLoader.java index 91e6598..139d640 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/CommonModLoader.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/CommonModLoader.java @@ -1,6 +1,5 @@ package it.crystalnest.leathered_boots; -import it.crystalnest.leathered_boots.enchantment.EnchantmentRegistry; import it.crystalnest.leathered_boots.item.ItemRegistry; import it.crystalnest.leathered_boots.loot.CommonLootRegistry; import org.jetbrains.annotations.ApiStatus; @@ -17,7 +16,6 @@ private CommonModLoader() {} */ public static void init() { ItemRegistry.register(); - EnchantmentRegistry.register(); CommonLootRegistry.register(); Constants.LEATHERED_BOOTS_DYNAMIC_DATA_PACK.register(); } diff --git a/common/src/main/java/it/crystalnest/leathered_boots/Constants.java b/common/src/main/java/it/crystalnest/leathered_boots/Constants.java index 1d78faf..5be8115 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/Constants.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/Constants.java @@ -4,19 +4,18 @@ import it.crystalnest.cobweb.api.pack.DynamicDataPack; import it.crystalnest.cobweb.api.pack.DynamicTagBuilder; import it.crystalnest.leathered_boots.api.LeatheredBootsManager; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; +import it.crystalnest.leathered_boots.item.ItemRegistry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.ItemCost; import net.minecraft.world.item.trading.MerchantOffer; import org.jetbrains.annotations.ApiStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Map; -import java.util.Objects; import java.util.function.Supplier; /** @@ -25,7 +24,7 @@ @ApiStatus.Internal public final class Constants { /** - * Mod id. + * Mod ID. */ public static final String MOD_ID = "leathered_boots"; @@ -36,19 +35,19 @@ public final class Constants { /** * Leathered boots dynamic datapack.
- * Adds all leathered boots to {@link ItemTags#TRIMMABLE_ARMOR} and {@link ItemTags#FREEZE_IMMUNE_WEARABLES}. + * Adds all leathered boots to {@link ItemTags#DYEABLE}, {@link ItemTags#TRIMMABLE_ARMOR}, {@link ItemTags#TRIMMABLE_ARMOR} and {@link ItemTags#FOOT_ARMOR}. */ public static final DynamicDataPack LEATHERED_BOOTS_DYNAMIC_DATA_PACK = (DynamicDataPack) DynamicDataPack - .named(new ResourceLocation(MOD_ID, "leathered_boots")) - .add(() -> DynamicTagBuilder.of(Registries.ITEM, ItemTags.TRIMMABLE_ARMOR, ItemTags.FREEZE_IMMUNE_WEARABLES).addElements(LeatheredBootsManager.getBoots())); + .named(ResourceLocation.fromNamespaceAndPath(MOD_ID, "leathered_boots")) + .add(() -> DynamicTagBuilder.of(Registries.ITEM, ItemTags.DYEABLE, ItemTags.TRIMMABLE_ARMOR, ItemTags.FREEZE_IMMUNE_WEARABLES, ItemTags.FOOT_ARMOR).addElements(LeatheredBootsManager.getBoots())); /** * Leathered boots trade offers. */ public static final Supplier> LEATHERED_BOOTS_TRADES = Suppliers.memoize(() -> Map.ofEntries( - Map.entry(3, new MerchantOffer(new ItemStack(Items.EMERALD, 4), Objects.requireNonNull(LeatheredBootsManager.getBootsStack(Constants.MOD_ID, LeatheredArmorMaterial.LEATHERED_CHAIN)), 5, 6, 0.02F)), - Map.entry(4, new MerchantOffer(new ItemStack(Items.EMERALD, 9), Objects.requireNonNull(LeatheredBootsManager.getBootsStack(Constants.MOD_ID, LeatheredArmorMaterial.LEATHERED_IRON)), 3, 10, 0.02F)), - Map.entry(5, new MerchantOffer(new ItemStack(Items.EMERALD, 13), Objects.requireNonNull(LeatheredBootsManager.getBootsStack(Constants.MOD_ID, LeatheredArmorMaterial.LEATHERED_DIAMOND)), 1, 30, 0.02F)) + Map.entry(3, new MerchantOffer(new ItemCost(Items.EMERALD, 4), ItemRegistry.LEATHERED_CHAIN_BOOTS.get().getDefaultInstance(), 5, 6, 0.02F)), + Map.entry(4, new MerchantOffer(new ItemCost(Items.EMERALD, 9), ItemRegistry.LEATHERED_IRON_BOOTS.get().getDefaultInstance(), 3, 10, 0.02F)), + Map.entry(5, new MerchantOffer(new ItemCost(Items.EMERALD, 13), ItemRegistry.LEATHERED_DIAMOND_BOOTS.get().getDefaultInstance(), 1, 30, 0.02F)) )); /** diff --git a/common/src/main/java/it/crystalnest/leathered_boots/api/LeatheredBootsManager.java b/common/src/main/java/it/crystalnest/leathered_boots/api/LeatheredBootsManager.java index e2cee22..ebd90df 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/api/LeatheredBootsManager.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/api/LeatheredBootsManager.java @@ -1,22 +1,23 @@ package it.crystalnest.leathered_boots.api; +import it.crystalnest.cobweb.api.registry.CobwebEntry; import it.crystalnest.cobweb.api.registry.CobwebRegistry; import it.crystalnest.leathered_boots.Constants; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; import it.crystalnest.leathered_boots.platform.Services; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; -import java.util.stream.Collectors; /** * Leathered Boots API. @@ -25,82 +26,18 @@ public final class LeatheredBootsManager { /** * {@link ConcurrentHashMap} of all registered {@link LeatheredBootsItem}s. */ - private static final ConcurrentHashMap> LEATHERED_BOOTS = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap> LEATHERED_BOOTS = new ConcurrentHashMap<>(); private LeatheredBootsManager() {} /** - * Registers a new {@link LeatheredBootsItem} made of the given {@link ArmorMaterial}. + * Provides a {@link BootsRegister} to register {@link LeatheredBootsItem}s. * * @param modId mod ID. - * @param isFireResistant whether the boots are fire-resistant. - * @param armorMaterial armor material. - * @return {@link Supplier} of the registered {@link LeatheredBootsItem}. + * @return {@link BootsRegister}. */ - public static synchronized Supplier registerBoots(@NotNull String modId, boolean isFireResistant, ArmorMaterial armorMaterial) { - LeatheredArmorMaterial leatheredArmorMaterial = armorMaterial instanceof LeatheredArmorMaterial leathered ? leathered : new LeatheredArmorMaterial(armorMaterial); - ResourceLocation id = getKey(modId, leatheredArmorMaterial); - if (LEATHERED_BOOTS.containsKey(id)) { - Constants.LOGGER.error("LeatheredBootsItem [{}] was already registered.", id); - } - return LEATHERED_BOOTS.computeIfAbsent(id, key -> CobwebRegistry.ofItems(modId).register(key.getPath(), Services.ITEM.supplyItem(leatheredArmorMaterial, isFireResistant))); - } - - /** - * Registers a new {@link LeatheredBootsItem} made of the given {@link ArmorMaterial}. - * - * @param modId mod ID. - * @param armorMaterial armor material. - * @return {@link Supplier} of the registered {@link LeatheredBootsItem}. - */ - public static synchronized Supplier registerBoots(@NotNull String modId, ArmorMaterial armorMaterial) { - return registerBoots(modId, false, armorMaterial); - } - - /** - * Registers new {@link LeatheredBootsItem}s made of the given {@link ArmorMaterial}s. - * - * @param modId mod ID. - * @param isFireResistant whether the boots are fire-resistant. - * @param armorMaterials armor materials. - * @return map of {@link Supplier}s of the registered {@link LeatheredBootsItem}. - */ - public static synchronized Map> registerBoots(@NotNull String modId, boolean isFireResistant, List armorMaterials) { - return armorMaterials.stream().map(armorMaterial -> Map.entry(getKey(modId, armorMaterial), registerBoots(modId, isFireResistant, armorMaterial))).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - - /** - * Registers new {@link LeatheredBootsItem}s made of the given {@link ArmorMaterial}s. - * - * @param modId mod ID. - * @param armorMaterials armor materials. - * @return map of {@link Supplier}s of the registered {@link LeatheredBootsItem}. - */ - public static synchronized Map> registerBoots(@NotNull String modId, List armorMaterials) { - return registerBoots(modId, false, armorMaterials); - } - - /** - * Registers new {@link LeatheredBootsItem}s made of the given {@link ArmorMaterial}s. - * - * @param modId mod ID. - * @param isFireResistant whether the boots are fire-resistant. - * @param armorMaterials armor materials. - * @return map of {@link Supplier}s of the registered {@link LeatheredBootsItem}. - */ - public static synchronized Map> registerBoots(@NotNull String modId, boolean isFireResistant, ArmorMaterial... armorMaterials) { - return registerBoots(modId, isFireResistant, Arrays.asList(armorMaterials)); - } - - /** - * Registers new {@link LeatheredBootsItem}s made of the given {@link ArmorMaterial}s. - * - * @param modId mod ID. - * @param armorMaterials armor materials. - * @return map of {@link Supplier}s of the registered {@link LeatheredBootsItem}. - */ - public static synchronized Map> registerBoots(@NotNull String modId, ArmorMaterial... armorMaterials) { - return registerBoots(modId, false, armorMaterials); + public static BootsRegister register(@NotNull String modId) { + return new BootsRegister(modId); } /** @@ -125,25 +62,12 @@ public static List getBoots(@NotNull String modId) { /** * Returns the {@link LeatheredBootsItem} registered with the given {@link ResourceLocation}. * - * @param key leathered boots ID.
- * See also {@link #getKey(String, ArmorMaterial)}. + * @param key leathered boots ID. * @return registered {@link LeatheredBootsItem} or {@code null}. */ @Nullable public static LeatheredBootsItem getBoots(@NotNull ResourceLocation key) { - return LEATHERED_BOOTS.getOrDefault(key, () -> null).get(); - } - - /** - * Returns the {@link LeatheredBootsItem} registered with the given {@link ArmorMaterial}. - * - * @param modId mod ID. - * @param armorMaterial armor material. - * @return registered {@link LeatheredBootsItem} or {@code null}. - */ - @Nullable - public static LeatheredBootsItem getBoots(@NotNull String modId, @NotNull ArmorMaterial armorMaterial) { - return getBoots(getKey(modId, armorMaterial)); + return LEATHERED_BOOTS.containsKey(key) ? LEATHERED_BOOTS.get(key).get() : null; } /** @@ -168,28 +92,15 @@ public static List getBootsStack(@NotNull String modId) { /** * Returns the {@link ItemStack} of the {@link LeatheredBootsItem} registered with the given {@link ArmorMaterial}. * - * @param key leathered boots ID.
- * See also {@link #getKey(String, ArmorMaterial)}. + * @param key leathered boots ID. * @return registered {@link LeatheredBootsItem} or {@code null}. */ @Nullable - public static ItemStack getBootsStack(ResourceLocation key) { + public static ItemStack getBootsStack(@NotNull ResourceLocation key) { LeatheredBootsItem item = getBoots(key); return item == null ? null : item.getDefaultInstance(); } - /** - * Returns the {@link ItemStack} of the {@link LeatheredBootsItem} registered with the given {@link ArmorMaterial}. - * - * @param modId mod ID. - * @param armorMaterial armor material. - * @return registered {@link LeatheredBootsItem} or {@code null}. - */ - @Nullable - public static ItemStack getBootsStack(String modId, ArmorMaterial armorMaterial) { - return getBootsStack(getKey(modId, armorMaterial)); - } - /** * Returns the list of all registered mod IDs. * @@ -200,14 +111,61 @@ public static List getModIds() { } /** - * Returns the {@link ResourceLocation} that would be given to a {@link LeatheredBootsItem} of the given {@link ArmorMaterial} when registered.
- * Note: this does not grant that such a {@link LeatheredBootsItem} has been registered. - * - * @param modId mod ID. - * @param armorMaterial armor material. - * @return {@link ResourceLocation} for a {@link LeatheredBootsItem} made of the given {@link ArmorMaterial}. - */ - public static ResourceLocation getKey(@NotNull String modId, @NotNull ArmorMaterial armorMaterial) { - return new ResourceLocation(modId, (armorMaterial instanceof LeatheredArmorMaterial leatheredArmorMaterial ? leatheredArmorMaterial : new LeatheredArmorMaterial(armorMaterial)).getName() + "_boots"); + * Register for {@link LeatheredBootsItem}s. + */ + public record BootsRegister(String modId) { + /** + * Registers a new {@link LeatheredBootsItem} made of the given {@link ArmorMaterial}. + * + * @param name base armor material name. + * @param durabilityFactor durability factor. + * @param isFireResistant whether the boots are fire-resistant. + * @param armorMaterial armor material holder. + * @return {@link CobwebEntry} of the registered {@link LeatheredBootsItem}. + */ + public synchronized CobwebEntry register(@NotNull String name, int durabilityFactor, boolean isFireResistant, Holder armorMaterial) { + ResourceLocation id = ResourceLocation.fromNamespaceAndPath(modId, "leathered_" + name + "_boots"); + if (LEATHERED_BOOTS.containsKey(id)) { + Constants.LOGGER.error("LeatheredBootsItem [{}] was already registered.", id); + } + return LEATHERED_BOOTS.computeIfAbsent(id, key -> CobwebRegistry.ofItems(modId).register( + key.getPath(), + Services.ITEM.supplyItem(durabilityFactor, isFireResistant, CobwebRegistry.of(Registries.ARMOR_MATERIAL, Constants.MOD_ID).register("leathered_" + name, supplyLeatheredArmorMaterial(armorMaterial))) + )); + } + + /** + * Registers a new {@link LeatheredBootsItem} made of the given {@link ArmorMaterial}. + * + * @param name armor material name. + * @param durabilityFactor durability factor. + * @param armorMaterial armor material holder. + * @return {@link CobwebEntry} of the registered {@link LeatheredBootsItem}. + */ + public synchronized CobwebEntry register(@NotNull String name, int durabilityFactor, Holder armorMaterial) { + return register(name, durabilityFactor, false, armorMaterial); + } + + /** + * Provides a supplier for a new armor material, copying the given one. + * + * @param holder armor material to copy. + * @return armor material supplier. + */ + private static Supplier supplyLeatheredArmorMaterial(Holder holder) { + return () -> { + ArmorMaterial armorMaterial = holder.value(); + ResourceLocation armorName = armorMaterial.layers().getFirst().assetName.withPath(path -> "leathered_" + path); + return new ArmorMaterial( + armorMaterial.defense(), + armorMaterial.enchantmentValue(), + armorMaterial.equipSound(), + armorMaterial.repairIngredient(), + ((ArmorItem) Items.LEATHER_BOOTS).getMaterial().value().layers().stream().map(layer -> new ArmorMaterial.Layer(armorName, layer.suffix, layer.dyeable())).toList(), + armorMaterial.toughness(), + armorMaterial.knockbackResistance() + ); + }; + } } } diff --git a/common/src/main/java/it/crystalnest/leathered_boots/enchantment/EnchantmentRegistry.java b/common/src/main/java/it/crystalnest/leathered_boots/enchantment/EnchantmentRegistry.java deleted file mode 100644 index 78bbefb..0000000 --- a/common/src/main/java/it/crystalnest/leathered_boots/enchantment/EnchantmentRegistry.java +++ /dev/null @@ -1,33 +0,0 @@ -package it.crystalnest.leathered_boots.enchantment; - -import it.crystalnest.cobweb.api.registry.CobwebRegister; -import it.crystalnest.cobweb.api.registry.CobwebRegistry; -import it.crystalnest.leathered_boots.Constants; -import net.minecraft.core.registries.Registries; -import net.minecraft.world.item.enchantment.Enchantment; -import org.jetbrains.annotations.ApiStatus; - -import java.util.function.Supplier; - -/** - * Registry for enchantments. - */ -@ApiStatus.Internal -public final class EnchantmentRegistry { - /** - * {@link CobwebRegister} for {@link Enchantment}s. - */ - private static final CobwebRegister ENCHANTMENTS = CobwebRegistry.of(Registries.ENCHANTMENT, Constants.MOD_ID); - - /** - * {@link SoftStepEnchantment}. - */ - public static final Supplier SOFT_STEP = ENCHANTMENTS.register("soft_step", SoftStepEnchantment::new); - - private EnchantmentRegistry() {} - - /** - * Called to load the class and register. - */ - public static void register() {} -} diff --git a/common/src/main/java/it/crystalnest/leathered_boots/enchantment/SoftStepEnchantment.java b/common/src/main/java/it/crystalnest/leathered_boots/enchantment/SoftStepEnchantment.java deleted file mode 100644 index 8e66937..0000000 --- a/common/src/main/java/it/crystalnest/leathered_boots/enchantment/SoftStepEnchantment.java +++ /dev/null @@ -1,14 +0,0 @@ -package it.crystalnest.leathered_boots.enchantment; - -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.EnchantmentCategory; - -/** - * {@link Enchantment} to walk on powder snow. - */ -public class SoftStepEnchantment extends Enchantment { - public SoftStepEnchantment() { - super(Rarity.UNCOMMON, EnchantmentCategory.ARMOR_FEET, new EquipmentSlot[]{ EquipmentSlot.FEET }); - } -} diff --git a/common/src/main/java/it/crystalnest/leathered_boots/item/ItemRegistry.java b/common/src/main/java/it/crystalnest/leathered_boots/item/ItemRegistry.java index 7496ee9..6e23af0 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/item/ItemRegistry.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/item/ItemRegistry.java @@ -1,10 +1,12 @@ package it.crystalnest.leathered_boots.item; +import it.crystalnest.cobweb.api.registry.CobwebEntry; import it.crystalnest.cobweb.api.registry.CobwebRegister; import it.crystalnest.cobweb.api.registry.CobwebRegistry; import it.crystalnest.leathered_boots.Constants; import it.crystalnest.leathered_boots.api.LeatheredBootsManager; import it.crystalnest.leathered_boots.platform.Services; +import net.minecraft.world.item.ArmorMaterials; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import org.jetbrains.annotations.ApiStatus; @@ -22,21 +24,51 @@ public final class ItemRegistry { private static final CobwebRegister ITEMS = CobwebRegistry.ofItems(Constants.MOD_ID); /** - * {@link CobwebRegister} for {@link CreativeModeTab}s. + * {@link LeatherUpgradeSmithingTemplateItem}. */ - private static final CobwebRegister CREATIVE_TABS = CobwebRegistry.ofCreativeModeTabs(Constants.MOD_ID); + public static final Supplier LEATHER_UPGRADE_SMITHING_TEMPLATE_ITEM = ITEMS.register("leather_upgrade_smithing_template", LeatherUpgradeSmithingTemplateItem::new); /** - * {@link LeatherUpgradeSmithingTemplateItem}. + * {@link LeatheredBootsManager.BootsRegister} for leathered boots. */ - public static final Supplier LEATHER_UPGRADE_SMITHING_TEMPLATE_ITEM = ITEMS.register("leather_upgrade_smithing_template", LeatherUpgradeSmithingTemplateItem::new); + private static final LeatheredBootsManager.BootsRegister LEATHERED_BOOTS = LeatheredBootsManager.register(Constants.MOD_ID); + + /** + * {@link LeatheredBootsItem} for chainmail boots. + */ + public static final CobwebEntry LEATHERED_CHAIN_BOOTS = LEATHERED_BOOTS.register("chainmail", 15, ArmorMaterials.CHAIN); + + /** + * {@link LeatheredBootsItem} for iron boots. + */ + public static final CobwebEntry LEATHERED_IRON_BOOTS = LEATHERED_BOOTS.register("iron", 15, ArmorMaterials.IRON); + + /** + * {@link LeatheredBootsItem} for golden boots. + */ + public static final CobwebEntry LEATHERED_GOLDEN_BOOTS = LEATHERED_BOOTS.register("gold", 7, ArmorMaterials.GOLD); + + /** + * {@link LeatheredBootsItem} for diamond boots. + */ + public static final CobwebEntry LEATHERED_DIAMOND_BOOTS = LEATHERED_BOOTS.register("diamond", 33, ArmorMaterials.DIAMOND); + + /** + * {@link LeatheredBootsItem} for netherite boots. + */ + public static final CobwebEntry LEATHERED_NETHERITE_BOOTS = LEATHERED_BOOTS.register("netherite", 37, true, ArmorMaterials.NETHERITE); + + /** + * {@link CobwebRegister} for {@link CreativeModeTab}s. + */ + private static final CobwebRegister CREATIVE_TABS = CobwebRegistry.ofCreativeModeTabs(Constants.MOD_ID); /** * Leathered boots tab.
* Includes all registered leathered boots. */ public static final Supplier LEATHERED_BOOTS_TAB = CREATIVE_TABS.register(Constants.LEATHERED_BOOTS_TAB_ID, Services.ITEM.supplyTab( - () -> LeatheredBootsManager.getBootsStack(Constants.MOD_ID, LeatheredArmorMaterial.LEATHERED_NETHERITE), + () -> LEATHERED_NETHERITE_BOOTS.get().getDefaultInstance(), Constants.LEATHERED_BOOTS_TAB_ID, output -> { output.acceptAll(LeatheredBootsManager.getBootsStack()); @@ -49,14 +81,5 @@ private ItemRegistry() {} /** * Called to load the class and register. */ - public static void register() { - LeatheredBootsManager.registerBoots( - Constants.MOD_ID, - LeatheredArmorMaterial.LEATHERED_CHAIN, - LeatheredArmorMaterial.LEATHERED_IRON, - LeatheredArmorMaterial.LEATHERED_GOLD, - LeatheredArmorMaterial.LEATHERED_DIAMOND - ); - LeatheredBootsManager.registerBoots(Constants.MOD_ID, true, LeatheredArmorMaterial.LEATHERED_NETHERITE); - } + public static void register() {} } diff --git a/common/src/main/java/it/crystalnest/leathered_boots/item/LeatherUpgradeSmithingTemplateItem.java b/common/src/main/java/it/crystalnest/leathered_boots/item/LeatherUpgradeSmithingTemplateItem.java index 17cf254..cbb9a55 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/item/LeatherUpgradeSmithingTemplateItem.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/item/LeatherUpgradeSmithingTemplateItem.java @@ -15,13 +15,13 @@ public class LeatherUpgradeSmithingTemplateItem extends SmithingTemplateItem { public LeatherUpgradeSmithingTemplateItem() { super( - Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(Constants.MOD_ID, "smithing_template.leather_upgrade.applies_to"))).withStyle(ChatFormatting.BLUE), - Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(Constants.MOD_ID, "smithing_template.leather_upgrade.ingredients"))).withStyle(ChatFormatting.BLUE), - Component.translatable(Util.makeDescriptionId("upgrade", new ResourceLocation(Constants.MOD_ID, "leather_upgrade"))).withStyle(ChatFormatting.GRAY), - Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(Constants.MOD_ID, "smithing_template.leather_upgrade.base_slot_description"))), - Component.translatable(Util.makeDescriptionId("item", new ResourceLocation(Constants.MOD_ID, "smithing_template.leather_upgrade.additions_slot_description"))), - List.of(new ResourceLocation("item/empty_armor_slot_boots")), - List.of(new ResourceLocation(Constants.MOD_ID, "item/empty_slot_leather")) + Component.translatable(Util.makeDescriptionId("item", ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "smithing_template.leather_upgrade.applies_to"))).withStyle(ChatFormatting.BLUE), + Component.translatable(Util.makeDescriptionId("item", ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "smithing_template.leather_upgrade.ingredients"))).withStyle(ChatFormatting.BLUE), + Component.translatable(Util.makeDescriptionId("upgrade", ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "leather_upgrade"))).withStyle(ChatFormatting.GRAY), + Component.translatable(Util.makeDescriptionId("item", ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "smithing_template.leather_upgrade.base_slot_description"))), + Component.translatable(Util.makeDescriptionId("item", ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "smithing_template.leather_upgrade.additions_slot_description"))), + List.of(ResourceLocation.withDefaultNamespace("item/empty_armor_slot_boots")), + List.of(ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "item/empty_slot_leather")) ); } } diff --git a/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredArmorMaterial.java b/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredArmorMaterial.java deleted file mode 100644 index b821582..0000000 --- a/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredArmorMaterial.java +++ /dev/null @@ -1,105 +0,0 @@ -package it.crystalnest.leathered_boots.item; - -import net.minecraft.sounds.SoundEvent; -import net.minecraft.world.item.ArmorItem.Type; -import net.minecraft.world.item.ArmorMaterial; -import net.minecraft.world.item.ArmorMaterials; -import net.minecraft.world.item.crafting.Ingredient; -import org.jetbrains.annotations.NotNull; - -/** - * All base leathered boots {@link ArmorMaterial}s. - */ -public class LeatheredArmorMaterial implements ArmorMaterial { - /** - * {@link LeatheredArmorMaterial} for Vanilla {@link ArmorMaterials#CHAIN}. - */ - public static final LeatheredArmorMaterial LEATHERED_CHAIN = new LeatheredArmorMaterial(ArmorMaterials.CHAIN); - - /** - * {@link LeatheredArmorMaterial} for Vanilla {@link ArmorMaterials#IRON}. - */ - public static final LeatheredArmorMaterial LEATHERED_IRON = new LeatheredArmorMaterial(ArmorMaterials.IRON); - - /** - * {@link LeatheredArmorMaterial} for Vanilla {@link ArmorMaterials#GOLD}. - */ - public static final LeatheredArmorMaterial LEATHERED_GOLD = new LeatheredArmorMaterial(ArmorMaterials.GOLD); - - /** - * {@link LeatheredArmorMaterial} for Vanilla {@link ArmorMaterials#DIAMOND}. - */ - public static final LeatheredArmorMaterial LEATHERED_DIAMOND = new LeatheredArmorMaterial(ArmorMaterials.DIAMOND); - - /** - * {@link LeatheredArmorMaterial} for Vanilla {@link ArmorMaterials#NETHERITE}. - */ - public static final LeatheredArmorMaterial LEATHERED_NETHERITE = new LeatheredArmorMaterial(ArmorMaterials.NETHERITE); - - /** - * Name of this {@link ArmorMaterial}.
- * Always equal to {@code "leathered_" + baseArmorMaterialName}. - */ - private final String name; - - /** - * Base {@link ArmorMaterial}. - */ - private final ArmorMaterial armorMaterial; - - /** - * @param armorMaterial {@link #armorMaterial}. - */ - public LeatheredArmorMaterial(ArmorMaterial armorMaterial) { - this.name = "leathered_" + armorMaterial.getName(); - this.armorMaterial = armorMaterial; - } - - @Override - public int getDurabilityForType(@NotNull Type type) { - return this.armorMaterial.getDurabilityForType(type); - } - - @Override - public int getDefenseForType(@NotNull Type type) { - return this.armorMaterial.getDefenseForType(type); - } - - @Override - public int getEnchantmentValue() { - return this.armorMaterial.getEnchantmentValue(); - } - - @NotNull - @Override - public SoundEvent getEquipSound() { - return this.armorMaterial.getEquipSound(); - } - - @NotNull - @Override - public Ingredient getRepairIngredient() { - return this.armorMaterial.getRepairIngredient(); - } - - @NotNull - @Override - public String getName() { - return this.name; - } - - @Override - public float getToughness() { - return this.armorMaterial.getToughness(); - } - - @Override - public float getKnockbackResistance() { - return this.armorMaterial.getKnockbackResistance(); - } - - @Override - public String toString() { - return "LeatheredArmorMaterial{name=" + name + "}"; - } -} diff --git a/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredBootsItem.java b/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredBootsItem.java index 9c2512c..677c100 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredBootsItem.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/item/LeatheredBootsItem.java @@ -1,23 +1,29 @@ package it.crystalnest.leathered_boots.item; -import net.minecraft.world.item.DyeableArmorItem; +import net.minecraft.core.Holder; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterial; import org.jetbrains.annotations.NotNull; /** * Leathered Boots Item. */ -public class LeatheredBootsItem extends DyeableArmorItem { +public class LeatheredBootsItem extends ArmorItem { /** - * @param armorMaterial {@link LeatheredArmorMaterial}. - * @param isFireResistant {@link #isFireResistant}. + * @param armorMaterial {@link ArmorMaterial}. + * @param isFireResistant whether the boots are fire-resistant. */ - public LeatheredBootsItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant) { - super(armorMaterial, Type.BOOTS, isFireResistant ? new Properties().fireResistant() : new Properties()); + public LeatheredBootsItem(Holder armorMaterial, int durabilityFactor, boolean isFireResistant) { + super(armorMaterial, Type.BOOTS, isFireResistant ? getProperties(durabilityFactor).fireResistant() : getProperties(durabilityFactor)); + } + + private static Properties getProperties(int durabilityFactor) { + return new Properties().durability(Type.BOOTS.getDurability(durabilityFactor)); } @NotNull @Override - public LeatheredArmorMaterial getMaterial() { - return (LeatheredArmorMaterial) super.getMaterial(); + public Holder getMaterial() { + return super.getMaterial(); } } diff --git a/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesCheck.java b/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesCheck.java index a0aff81..ab566f3 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesCheck.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesCheck.java @@ -1,6 +1,7 @@ package it.crystalnest.leathered_boots.loot; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.biome.Biome; @@ -13,28 +14,17 @@ import java.util.List; -import static com.mojang.serialization.codecs.RecordCodecBuilder.create; /** * {@link LootItemCondition} to check whether the location is in one of the provided biomes. + * + * @param predicate {@link BiomesPredicate}. */ -public final class BiomesCheck implements LootItemCondition { +public record BiomesCheck(BiomesPredicate predicate) implements LootItemCondition { /** - * {@link Codec}. + * {@link MapCodec}. */ - public static final Codec CODEC = create(instance -> instance.group(BiomesPredicate.CODEC.fieldOf("predicate").forGetter(check -> check.predicate)).apply(instance, BiomesCheck::new)); - - /** - * {@link BiomesPredicate}. - */ - private final BiomesPredicate predicate; - - /** - * @param predicate {@link #predicate}. - */ - BiomesCheck(BiomesPredicate predicate) { - this.predicate = predicate; - } + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(BiomesPredicate.CODEC.fieldOf("predicate").forGetter(BiomesCheck::predicate)).apply(instance, BiomesCheck::new)); /** * {@link BiomesCheck} builder. diff --git a/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesPredicate.java b/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesPredicate.java index a6c2bbb..8eafcd8 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesPredicate.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/loot/BiomesPredicate.java @@ -14,30 +14,20 @@ /** * {@link BiPredicate} to check whether a {@link BlockPos} is in the provided list of biomes. + * + * @param biomes List of biomes to check against. */ -public final class BiomesPredicate implements BiPredicate { +public record BiomesPredicate(List> biomes) implements BiPredicate { /** * {@link Codec}. */ - public static final Codec CODEC = create(instance -> instance.group(ResourceKey.codec(Registries.BIOME).listOf().fieldOf("biomes").forGetter(predicate -> predicate.biomes)).apply(instance, BiomesPredicate::new)); + public static final Codec CODEC = create(instance -> instance.group(ResourceKey.codec(Registries.BIOME).listOf().fieldOf("biomes").forGetter(BiomesPredicate::biomes)).apply(instance, BiomesPredicate::new)); /** * Neutral {@link BiomesPredicate}. */ public static final BiomesPredicate ANY = new BiomesPredicate(List.of()); - /** - * List of biomes to check against. - */ - private final List> biomes; - - /** - * @param biomes {@link #biomes}. - */ - public BiomesPredicate(List> biomes) { - this.biomes = biomes; - } - @Override public boolean test(ServerLevel world, BlockPos pos) { return this.biomes.isEmpty() || world.isLoaded(pos) && this.biomes.stream().anyMatch(biome -> world.getBiome(pos).is(biome)); diff --git a/common/src/main/java/it/crystalnest/leathered_boots/mixin/PowderSnowBlockMixin.java b/common/src/main/java/it/crystalnest/leathered_boots/mixin/PowderSnowBlockMixin.java index 62ef153..4bfc45a 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/mixin/PowderSnowBlockMixin.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/mixin/PowderSnowBlockMixin.java @@ -1,9 +1,11 @@ package it.crystalnest.leathered_boots.mixin; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import it.crystalnest.leathered_boots.enchantment.EnchantmentRegistry; -import it.crystalnest.leathered_boots.enchantment.SoftStepEnchantment; +import it.crystalnest.leathered_boots.Constants; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; @@ -23,13 +25,16 @@ public abstract class PowderSnowBlockMixin { * * @param original original condition value. * @param entity {@link Entity} the entity to check. - * @return condition extended to take into account {@link LeatheredBootsItem} and {@link SoftStepEnchantment}. + * @return condition extended to take into account {@link LeatheredBootsItem} and Soft Step enchantment. */ @ModifyReturnValue(method = "canEntityWalkOnPowderSnow", at = @At(value = "RETURN", ordinal = 1)) private static boolean modifyCanEntityWalkOnPowderSnow(boolean original, Entity entity) { return original || entity instanceof LivingEntity livingEntity && ( livingEntity.getItemBySlot(EquipmentSlot.FEET).getItem() instanceof LeatheredBootsItem || - EnchantmentHelper.getItemEnchantmentLevel(EnchantmentRegistry.SOFT_STEP.get(), livingEntity.getItemBySlot(EquipmentSlot.FEET)) > 0 + EnchantmentHelper.getItemEnchantmentLevel( + entity.level().holderLookup(Registries.ENCHANTMENT).getOrThrow(ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "soft_step"))), + livingEntity.getItemBySlot(EquipmentSlot.FEET) + ) > 0 ); } } diff --git a/common/src/main/java/it/crystalnest/leathered_boots/platform/services/ItemHelper.java b/common/src/main/java/it/crystalnest/leathered_boots/platform/services/ItemHelper.java index 784b62b..00227ba 100644 --- a/common/src/main/java/it/crystalnest/leathered_boots/platform/services/ItemHelper.java +++ b/common/src/main/java/it/crystalnest/leathered_boots/platform/services/ItemHelper.java @@ -1,9 +1,10 @@ package it.crystalnest.leathered_boots.platform.services; import it.crystalnest.leathered_boots.Constants; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; +import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; @@ -29,11 +30,12 @@ public final Supplier supplyTab(Supplier icon, Strin /** * Returns a supplier for a {@link LeatheredBootsItem}. * - * @param armorMaterial {@link LeatheredArmorMaterial}. + * @param durabilityFactor durability factor. * @param isFireResistant whether the {@link LeatheredBootsItem} is fire-resistant. + * @param armorMaterial {@link ArmorMaterial}. * @return {@link Supplier} for the {@link LeatheredBootsItem}. */ - public abstract Supplier supplyItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant); + public abstract Supplier supplyItem(int durabilityFactor, boolean isFireResistant, Holder armorMaterial); /** * Builds a {@link CreativeModeTab} with the given icon, title, and items to display. diff --git a/common/src/main/resources/META-INF/accesstransformer.cfg b/common/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..7d37e4f --- /dev/null +++ b/common/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,2 @@ +public net.minecraft.world.item.ArmorMaterial$Layer assetName +public net.minecraft.world.item.ArmorMaterial$Layer suffix \ No newline at end of file diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/leather_upgrade_smithing_template.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/leather_upgrade_smithing_template.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/leather_upgrade_smithing_template.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/leather_upgrade_smithing_template.json diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_chainmail_boots.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_chainmail_boots.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_chainmail_boots.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_chainmail_boots.json diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_diamond_boots.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_diamond_boots.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_diamond_boots.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_diamond_boots.json diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_gold_boots.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_gold_boots.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_gold_boots.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_gold_boots.json diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_iron_boots.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_iron_boots.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_iron_boots.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_iron_boots.json diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_netherite_boots.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_netherite_boots.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_netherite_boots.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_netherite_boots.json diff --git a/common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_netherite_boots_from_diamond.json b/common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_netherite_boots_from_diamond.json similarity index 100% rename from common/src/main/resources/data/leathered_boots/advancements/recipes/smithing/leathered_netherite_boots_from_diamond.json rename to common/src/main/resources/data/leathered_boots/advancement/recipes/smithing/leathered_netherite_boots_from_diamond.json diff --git a/common/src/main/resources/data/leathered_boots/enchantment/soft_step.json b/common/src/main/resources/data/leathered_boots/enchantment/soft_step.json new file mode 100644 index 0000000..d47c0d3 --- /dev/null +++ b/common/src/main/resources/data/leathered_boots/enchantment/soft_step.json @@ -0,0 +1,20 @@ +{ + "anvil_cost": 2, + "description": { + "translate": "enchantment.leathered_boots.soft_step" + }, + "max_cost": { + "base": 11, + "per_level_above_first": 0 + }, + "max_level": 1, + "min_cost": { + "base": 5, + "per_level_above_first": 0 + }, + "slots": [ + "feet" + ], + "supported_items": "#minecraft:enchantable/foot_armor", + "weight": 5 +} \ No newline at end of file diff --git a/common/src/main/resources/data/leathered_boots/recipes/leather_upgrade_smithing_template.json b/common/src/main/resources/data/leathered_boots/recipe/leather_upgrade_smithing_template.json similarity index 84% rename from common/src/main/resources/data/leathered_boots/recipes/leather_upgrade_smithing_template.json rename to common/src/main/resources/data/leathered_boots/recipe/leather_upgrade_smithing_template.json index 29f9057..63839c4 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/leather_upgrade_smithing_template.json +++ b/common/src/main/resources/data/leathered_boots/recipe/leather_upgrade_smithing_template.json @@ -19,6 +19,6 @@ ], "result": { "count": 2, - "item": "leathered_boots:leather_upgrade_smithing_template" + "id": "leathered_boots:leather_upgrade_smithing_template" } -} \ No newline at end of file +} diff --git a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_chainmail_boots.json b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_chainmail_boots.json similarity index 78% rename from common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_chainmail_boots.json rename to common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_chainmail_boots.json index ccb6582..a65d791 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_chainmail_boots.json +++ b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_chainmail_boots.json @@ -7,7 +7,8 @@ "item": "minecraft:chainmail_boots" }, "result": { - "item": "leathered_boots:leathered_chainmail_boots" + "count": 1, + "id": "leathered_boots:leathered_chainmail_boots" }, "template": { "item": "leathered_boots:leather_upgrade_smithing_template" diff --git a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_diamond_boots.json b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_diamond_boots.json similarity index 79% rename from common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_diamond_boots.json rename to common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_diamond_boots.json index 521e6b7..06b9fe8 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_diamond_boots.json +++ b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_diamond_boots.json @@ -7,7 +7,8 @@ "item": "minecraft:diamond_boots" }, "result": { - "item": "leathered_boots:leathered_diamond_boots" + "count": 1, + "id": "leathered_boots:leathered_diamond_boots" }, "template": { "item": "leathered_boots:leather_upgrade_smithing_template" diff --git a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_gold_boots.json b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_gold_boots.json similarity index 79% rename from common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_gold_boots.json rename to common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_gold_boots.json index bea04e6..7eae311 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_gold_boots.json +++ b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_gold_boots.json @@ -7,7 +7,8 @@ "item": "minecraft:golden_boots" }, "result": { - "item": "leathered_boots:leathered_gold_boots" + "count": 1, + "id": "leathered_boots:leathered_gold_boots" }, "template": { "item": "leathered_boots:leather_upgrade_smithing_template" diff --git a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_iron_boots.json b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_iron_boots.json similarity index 79% rename from common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_iron_boots.json rename to common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_iron_boots.json index 3addcc6..3e6f7d3 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_iron_boots.json +++ b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_iron_boots.json @@ -7,7 +7,8 @@ "item": "minecraft:iron_boots" }, "result": { - "item": "leathered_boots:leathered_iron_boots" + "count": 1, + "id": "leathered_boots:leathered_iron_boots" }, "template": { "item": "leathered_boots:leather_upgrade_smithing_template" diff --git a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_netherite_boots.json b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_netherite_boots.json similarity index 78% rename from common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_netherite_boots.json rename to common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_netherite_boots.json index e6b6ec2..1edbb60 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_netherite_boots.json +++ b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_netherite_boots.json @@ -7,7 +7,8 @@ "item": "minecraft:netherite_boots" }, "result": { - "item": "leathered_boots:leathered_netherite_boots" + "count": 1, + "id": "leathered_boots:leathered_netherite_boots" }, "template": { "item": "leathered_boots:leather_upgrade_smithing_template" diff --git a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_netherite_boots_from_diamond.json b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_netherite_boots_from_diamond.json similarity index 79% rename from common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_netherite_boots_from_diamond.json rename to common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_netherite_boots_from_diamond.json index 7ceb77e..8697655 100644 --- a/common/src/main/resources/data/leathered_boots/recipes/smithing/leathered_netherite_boots_from_diamond.json +++ b/common/src/main/resources/data/leathered_boots/recipe/smithing/leathered_netherite_boots_from_diamond.json @@ -7,7 +7,8 @@ "item": "leathered_boots:leathered_diamond_boots" }, "result": { - "item": "leathered_boots:leathered_netherite_boots" + "count": 1, + "id": "leathered_boots:leathered_netherite_boots" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/common/src/main/resources/data/minecraft/advancements/adventure/walk_on_powder_snow_with_leather_boots.json b/common/src/main/resources/data/minecraft/advancement/adventure/walk_on_powder_snow_with_leather_boots.json similarity index 91% rename from common/src/main/resources/data/minecraft/advancements/adventure/walk_on_powder_snow_with_leather_boots.json rename to common/src/main/resources/data/minecraft/advancement/adventure/walk_on_powder_snow_with_leather_boots.json index 7dc51fc..028c1f1 100644 --- a/common/src/main/resources/data/minecraft/advancements/adventure/walk_on_powder_snow_with_leather_boots.json +++ b/common/src/main/resources/data/minecraft/advancement/adventure/walk_on_powder_snow_with_leather_boots.json @@ -57,17 +57,13 @@ } }, "display": { - "announce_to_chat": true, "description": { "translate": "advancements.adventure.walk_on_powder_snow_with_leather_boots.description" }, - "frame": "task", - "hidden": false, "icon": { - "item": "minecraft:leather_boots", - "nbt": "{Damage:0}" + "count": 1, + "id": "minecraft:leather_boots" }, - "show_toast": true, "title": { "translate": "advancements.adventure.walk_on_powder_snow_with_leather_boots.title" } @@ -77,5 +73,6 @@ "walk_on_powder_snow_with_leather_boots", "walk_on_powder_snow_with_soft_step" ] - ] -} + ], + "sends_telemetry_event": true +} \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/advancements/nether/distract_piglin.json b/common/src/main/resources/data/minecraft/advancement/nether/distract_piglin.json similarity index 97% rename from common/src/main/resources/data/minecraft/advancements/nether/distract_piglin.json rename to common/src/main/resources/data/minecraft/advancement/nether/distract_piglin.json index da15eb8..34d7b7e 100644 --- a/common/src/main/resources/data/minecraft/advancements/nether/distract_piglin.json +++ b/common/src/main/resources/data/minecraft/advancement/nether/distract_piglin.json @@ -209,16 +209,13 @@ } }, "display": { - "announce_to_chat": true, "description": { "translate": "advancements.nether.distract_piglin.description" }, - "frame": "task", - "hidden": false, "icon": { - "item": "minecraft:gold_ingot" + "count": 1, + "id": "minecraft:gold_ingot" }, - "show_toast": true, "title": { "translate": "advancements.nether.distract_piglin.title" } @@ -228,5 +225,6 @@ "distract_piglin", "distract_piglin_directly" ] - ] + ], + "sends_telemetry_event": true } \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/advancements/nether/netherite_armor.json b/common/src/main/resources/data/minecraft/advancement/nether/netherite_armor.json similarity index 87% rename from common/src/main/resources/data/minecraft/advancements/nether/netherite_armor.json rename to common/src/main/resources/data/minecraft/advancement/nether/netherite_armor.json index d99abd5..b814ae9 100644 --- a/common/src/main/resources/data/minecraft/advancements/nether/netherite_armor.json +++ b/common/src/main/resources/data/minecraft/advancement/nether/netherite_armor.json @@ -31,17 +31,14 @@ } }, "display": { - "announce_to_chat": true, "description": { "translate": "advancements.nether.netherite_armor.description" }, "frame": "challenge", - "hidden": false, "icon": { - "item": "minecraft:netherite_chestplate", - "nbt": "{Damage:0}" + "count": 1, + "id": "minecraft:netherite_chestplate" }, - "show_toast": true, "title": { "translate": "advancements.nether.netherite_armor.title" } @@ -53,5 +50,6 @@ ], "rewards": { "experience": 100 - } + }, + "sends_telemetry_event": true } \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/advancements/story/obtain_armor.json b/common/src/main/resources/data/minecraft/advancement/story/obtain_armor.json similarity index 90% rename from common/src/main/resources/data/minecraft/advancements/story/obtain_armor.json rename to common/src/main/resources/data/minecraft/advancement/story/obtain_armor.json index 5f4c931..b5c908f 100644 --- a/common/src/main/resources/data/minecraft/advancements/story/obtain_armor.json +++ b/common/src/main/resources/data/minecraft/advancement/story/obtain_armor.json @@ -63,17 +63,13 @@ } }, "display": { - "announce_to_chat": true, "description": { "translate": "advancements.story.obtain_armor.description" }, - "frame": "task", - "hidden": false, "icon": { - "item": "minecraft:iron_chestplate", - "nbt": "{Damage:0}" + "count": 1, + "id": "minecraft:iron_chestplate" }, - "show_toast": true, "title": { "translate": "advancements.story.obtain_armor.title" } @@ -86,5 +82,6 @@ "iron_boots", "leathered_iron_boots" ] - ] + ], + "sends_telemetry_event": true } \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/advancements/story/shiny_gear.json b/common/src/main/resources/data/minecraft/advancement/story/shiny_gear.json similarity index 90% rename from common/src/main/resources/data/minecraft/advancements/story/shiny_gear.json rename to common/src/main/resources/data/minecraft/advancement/story/shiny_gear.json index ca625b0..154f978 100644 --- a/common/src/main/resources/data/minecraft/advancements/story/shiny_gear.json +++ b/common/src/main/resources/data/minecraft/advancement/story/shiny_gear.json @@ -63,17 +63,13 @@ } }, "display": { - "announce_to_chat": true, "description": { "translate": "advancements.story.shiny_gear.description" }, - "frame": "task", - "hidden": false, "icon": { - "item": "minecraft:diamond_chestplate", - "nbt": "{Damage:0}" + "count": 1, + "id": "minecraft:diamond_chestplate" }, - "show_toast": true, "title": { "translate": "advancements.story.shiny_gear.title" } @@ -86,5 +82,6 @@ "diamond_boots", "leathered_diamond_boots" ] - ] + ], + "sends_telemetry_event": true } \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/tags/enchantment/non_treasure.json b/common/src/main/resources/data/minecraft/tags/enchantment/non_treasure.json new file mode 100644 index 0000000..edd567c --- /dev/null +++ b/common/src/main/resources/data/minecraft/tags/enchantment/non_treasure.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "leathered_boots:soft_step" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/data/minecraft/tags/items/piglin_loved.json b/common/src/main/resources/data/minecraft/tags/item/piglin_loved.json similarity index 100% rename from common/src/main/resources/data/minecraft/tags/items/piglin_loved.json rename to common/src/main/resources/data/minecraft/tags/item/piglin_loved.json diff --git a/common/src/main/resources/leathered_boots.accesswidener b/common/src/main/resources/leathered_boots.accesswidener index 99e9e93..83d67b8 100644 --- a/common/src/main/resources/leathered_boots.accesswidener +++ b/common/src/main/resources/leathered_boots.accesswidener @@ -1,2 +1,4 @@ accessWidener v2 named -accessible field net/minecraft/world/level/storage/loot/LootTable pools Ljava/util/List; \ No newline at end of file +accessible field net/minecraft/world/level/storage/loot/LootTable pools Ljava/util/List; +accessible field net/minecraft/world/item/ArmorMaterial$Layer assetName Lnet/minecraft/resources/ResourceLocation; +accessible field net/minecraft/world/item/ArmorMaterial$Layer suffix Ljava/lang/String; \ No newline at end of file diff --git a/common/src/main/resources/leathered_boots.mixins.json b/common/src/main/resources/leathered_boots.mixins.json index 025d87d..3a3ef1c 100644 --- a/common/src/main/resources/leathered_boots.mixins.json +++ b/common/src/main/resources/leathered_boots.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "${group}.${mod_id}.mixin", "refmap": "${mod_id}.refmap.json", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_${java_version}", "mixins": [ "PowderSnowBlockMixin" ], diff --git a/common/src/main/resources/pack.mcmeta b/common/src/main/resources/pack.mcmeta index 6d54e6f..647fa99 100644 --- a/common/src/main/resources/pack.mcmeta +++ b/common/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "${mod_title}", - "pack_format": 22 + "pack_format": 34 } } diff --git a/fabric/build.gradle b/fabric/build.gradle index a2611fb..407fd7f 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,19 +1,25 @@ -plugins {} +plugins { + id "multiloader-loader" + id "fabric-loom" +} dependencies { - minecraft "com.mojang:minecraft:${minecraft_version}" - mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" - compileOnly project(":common") - modImplementation "it.crystalnest:cobweb-fabric:${minecraft_version}-${cobweb_version}" + minecraft "com.mojang:minecraft:$minecraft_version" + mappings loom.layered { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-$minecraft_version:$parchment_version@zip") + } + modImplementation "net.fabricmc:fabric-loader:$fabric_loader_version" + modImplementation "net.fabricmc.fabric-api:fabric-api:$fabric_version" + modImplementation "it.crystalnest:cobweb-$name:$minecraft_version-$cobweb_version" // Detail Armor Bar dependency - modImplementation "curse.maven:detail-armor-bar-506898:4936710" + modImplementation "curse.maven:detail-armor-bar-506898:5424464" } loom { - if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) { - accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener")) + def aw = project(":common").file("src/main/resources/${mod_id}.accesswidener") + if (aw.exists()) { + accessWidenerPath.set(aw) } mixin { defaultRefmapName.set("${mod_id}.refmap.json") @@ -23,27 +29,17 @@ loom { client() setConfigName("Fabric Client") ideConfigGenerated(true) - runDir("run") + runDir("run/client") } server { server() setConfigName("Fabric Server") ideConfigGenerated(true) - runDir("run") + runDir("run/client") } } } -tasks.withType(JavaCompile).configureEach { - source(project(":common").sourceSets.main.allSource) -} -tasks.withType(Javadoc).configureEach { - source(project(":common").sourceSets.main.allJava) -} -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} - -processResources { - from project(":common").sourceSets.main.resources +publisher { + setArtifact(remapJar) } diff --git a/fabric/src/main/java/it/crystalnest/leathered_boots/ClientModLoader.java b/fabric/src/main/java/it/crystalnest/leathered_boots/ClientModLoader.java index 6ca1a72..4f36ba3 100644 --- a/fabric/src/main/java/it/crystalnest/leathered_boots/ClientModLoader.java +++ b/fabric/src/main/java/it/crystalnest/leathered_boots/ClientModLoader.java @@ -6,7 +6,7 @@ import it.crystalnest.leathered_boots.platform.Services; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; -import net.minecraft.world.item.DyeableLeatherItem; +import net.minecraft.world.item.component.DyedItemColor; import org.jetbrains.annotations.ApiStatus; /** @@ -16,7 +16,7 @@ public final class ClientModLoader implements ClientModInitializer { @Override public void onInitializeClient() { - ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((DyeableLeatherItem) stack.getItem()).getColor(stack), LeatheredBootsManager.getBoots().toArray(LeatheredBootsItem[]::new)); + ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : DyedItemColor.getOrDefault(stack, DyedItemColor.LEATHER_COLOR), LeatheredBootsManager.getBoots().toArray(LeatheredBootsItem[]::new)); if (Services.PLATFORM.isModLoaded("detailab")) { DetailArmorBar.register(); } diff --git a/fabric/src/main/java/it/crystalnest/leathered_boots/compat/DetailArmorBar.java b/fabric/src/main/java/it/crystalnest/leathered_boots/compat/DetailArmorBar.java index b27776e..7d25cef 100644 --- a/fabric/src/main/java/it/crystalnest/leathered_boots/compat/DetailArmorBar.java +++ b/fabric/src/main/java/it/crystalnest/leathered_boots/compat/DetailArmorBar.java @@ -5,9 +5,11 @@ import com.redlimerl.detailab.api.render.TextureOffset; import it.crystalnest.leathered_boots.Constants; import it.crystalnest.leathered_boots.api.LeatheredBootsManager; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; +import it.crystalnest.leathered_boots.item.ItemRegistry; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; +import net.minecraft.core.Holder; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ArmorMaterial; import org.jetbrains.annotations.ApiStatus; import java.util.function.Function; @@ -25,29 +27,30 @@ private DetailArmorBar() {} * Register base Leathered Boots to Detail Armor Bar. */ @ApiStatus.Internal + @SuppressWarnings("deprecation") public static void register() { register( armorMaterial -> { int offsetFullX; int offsetHalfX; int offsetIconY = 9 + isVanillaTexture(); - if (armorMaterial == LeatheredArmorMaterial.LEATHERED_CHAIN) { + if (armorMaterial.is(ItemRegistry.LEATHERED_CHAIN_BOOTS.get().getMaterial())) { offsetFullX = 81; offsetHalfX = 72; - } else if (armorMaterial == LeatheredArmorMaterial.LEATHERED_IRON) { + } else if (armorMaterial.is(ItemRegistry.LEATHERED_IRON_BOOTS.get().getMaterial())) { offsetFullX = 63; offsetHalfX = 54; - } else if (armorMaterial == LeatheredArmorMaterial.LEATHERED_GOLD) { + } else if (armorMaterial.is(ItemRegistry.LEATHERED_GOLDEN_BOOTS.get().getMaterial())) { offsetFullX = 99; offsetHalfX = 90; - } else if (armorMaterial == LeatheredArmorMaterial.LEATHERED_DIAMOND) { + } else if (armorMaterial.is(ItemRegistry.LEATHERED_DIAMOND_BOOTS.get().getMaterial())) { offsetFullX = 27; offsetHalfX = 18; - } else if (armorMaterial == LeatheredArmorMaterial.LEATHERED_NETHERITE) { + } else if (armorMaterial.is(ItemRegistry.LEATHERED_NETHERITE_BOOTS.get().getMaterial())) { offsetFullX = 9; offsetHalfX = 0; } else { - Constants.LOGGER.error("An error occurred while attempting to register Leathered Boots {} to Detail Armor Bar:\nUnknown armor type: {}", LeatheredBootsManager.getKey(Constants.MOD_ID, armorMaterial), armorMaterial); + Constants.LOGGER.error("An error occurred while attempting to register Leathered Boots for {} to Detail Armor Bar:\nUnknown armor type: {}", Constants.MOD_ID, armorMaterial); offsetFullX = -1; offsetHalfX = -1; } @@ -60,10 +63,10 @@ public static void register() { /** * Register custom Leathered Boots to Detail Armor Bar. * - * @param armorBarTexture function that returns an {@link ArmorBarRenderManager} based on the {@link LeatheredArmorMaterial}. + * @param armorBarTexture function that returns an {@link ArmorBarRenderManager} based on the {@link ArmorMaterial}. * @param leatheredBoots {@link LeatheredBootsItem}s to register. */ - public static void register(Function armorBarTexture, LeatheredBootsItem... leatheredBoots) { + public static void register(Function, ArmorBarTexture> armorBarTexture, LeatheredBootsItem... leatheredBoots) { DetailArmorBarAPI.customArmorBarBuilder() .armor(leatheredBoots) .render(stack -> { diff --git a/fabric/src/main/java/it/crystalnest/leathered_boots/handler/HandlerRegistry.java b/fabric/src/main/java/it/crystalnest/leathered_boots/handler/HandlerRegistry.java index 9dbf824..fbf584e 100644 --- a/fabric/src/main/java/it/crystalnest/leathered_boots/handler/HandlerRegistry.java +++ b/fabric/src/main/java/it/crystalnest/leathered_boots/handler/HandlerRegistry.java @@ -1,6 +1,6 @@ package it.crystalnest.leathered_boots.handler; -import net.fabricmc.fabric.api.loot.v2.LootTableEvents; +import net.fabricmc.fabric.api.loot.v3.LootTableEvents; /** * Handlers register. diff --git a/fabric/src/main/java/it/crystalnest/leathered_boots/handler/LootTableEventsHandler.java b/fabric/src/main/java/it/crystalnest/leathered_boots/handler/LootTableEventsHandler.java index 2c909e7..f1cd3ba 100644 --- a/fabric/src/main/java/it/crystalnest/leathered_boots/handler/LootTableEventsHandler.java +++ b/fabric/src/main/java/it/crystalnest/leathered_boots/handler/LootTableEventsHandler.java @@ -1,20 +1,15 @@ package it.crystalnest.leathered_boots.handler; -import it.crystalnest.leathered_boots.Constants; -import it.crystalnest.leathered_boots.api.LeatheredBootsManager; import it.crystalnest.leathered_boots.item.ItemRegistry; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; import it.crystalnest.leathered_boots.loot.BiomesCheck; -import net.fabricmc.fabric.api.loot.v2.LootTableEvents; -import net.fabricmc.fabric.api.loot.v2.LootTableSource; +import net.fabricmc.fabric.api.loot.v3.LootTableEvents; +import net.fabricmc.fabric.api.loot.v3.LootTableSource; +import net.minecraft.core.HolderLookup; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.world.item.Item; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biomes; -import net.minecraft.world.level.storage.loot.LootDataManager; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.entries.LootItem; @@ -23,6 +18,7 @@ import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import java.util.List; +import java.util.function.Supplier; /** * {@link LootTableEvents} handler. @@ -33,23 +29,22 @@ private LootTableEventsHandler() {} /** * Handles modifying Vanilla loot tables to include mod items. * - * @param resourceManager resource manager. - * @param lootManager loot manager. - * @param id loot table ID. - * @param builder loot table builder. + * @param key loot table key. + * @param builder builder of the loot table being loaded. * @param source loot table source. + * @param provider holder lookup provider. */ - public static void handle(ResourceManager resourceManager, LootDataManager lootManager, ResourceLocation id, LootTable.Builder builder, LootTableSource source) { - switch (id.toString()) { + public static void handle(ResourceKey key, LootTable.Builder builder, LootTableSource source, HolderLookup.Provider provider) { + switch (key.location().toString()) { case "minecraft:chests/village/village_snowy_house" -> { - builder.pool(buildPool(0.2F, LeatheredArmorMaterial.LEATHERED_CHAIN)); - builder.pool(buildPool(0.1F, LeatheredArmorMaterial.LEATHERED_IRON)); - builder.pool(buildPool(0.05F, LeatheredArmorMaterial.LEATHERED_DIAMOND)); + builder.pool(buildPool(0.2F, ItemRegistry.LEATHERED_CHAIN_BOOTS)); + builder.pool(buildPool(0.1F, ItemRegistry.LEATHERED_IRON_BOOTS)); + builder.pool(buildPool(0.05F, ItemRegistry.LEATHERED_DIAMOND_BOOTS)); } case "minecraft:chests/igloo_chest" -> { - builder.pool(buildPool(0.2F, LeatheredArmorMaterial.LEATHERED_GOLD)); - builder.pool(buildPool(0.1F, LeatheredArmorMaterial.LEATHERED_IRON)); - builder.pool(buildPool(0.05F, LeatheredArmorMaterial.LEATHERED_DIAMOND)); + builder.pool(buildPool(0.2F, ItemRegistry.LEATHERED_GOLDEN_BOOTS)); + builder.pool(buildPool(0.1F, ItemRegistry.LEATHERED_IRON_BOOTS)); + builder.pool(buildPool(0.05F, ItemRegistry.LEATHERED_DIAMOND_BOOTS)); builder.pool(buildPool(0.5F, ItemRegistry.LEATHER_UPGRADE_SMITHING_TEMPLATE_ITEM.get())); } case "minecraft:chests/shipwreck_map", "minecraft:chests/shipwreck_treasure", "minecraft:chests/shipwreck_supply" -> builder.pool(buildPool(0.2F, Biomes.SNOWY_BEACH)); @@ -60,16 +55,17 @@ public static void handle(ResourceManager resourceManager, LootDataManager lootM /** * Handles replacing Vanilla loot tables to include mod items. * - * @param resourceManager resource manager. - * @param lootManager loot manager. - * @param id loot table ID. - * @param original original loot table. + * @param key loot table key. + * @param original loot table being modified. * @param source loot table source. - * @return replaced {@link LootTable} or {@code null}. + * @param provider holder lookup provider. */ - public static LootTable handle(ResourceManager resourceManager, LootDataManager lootManager, ResourceLocation id, LootTable original, LootTableSource source) { - if ("minecraft:archaeology/trail_ruins_rare".equals(id.toString())) { - return LootTable.lootTable().pool(LootPool.lootPool().with(original.pools.get(0).entries).with(LootItem.lootTableItem(ItemRegistry.LEATHER_UPGRADE_SMITHING_TEMPLATE_ITEM.get()).when(BiomesCheck.builder(Biomes.SNOWY_TAIGA)).build()).build()).build(); + public static LootTable handle(ResourceKey key, LootTable original, LootTableSource source, HolderLookup.Provider provider) { + if ("minecraft:archaeology/trail_ruins_rare".equals(key.location().toString())) { + return LootTable + .lootTable() + .pool(LootPool.lootPool().with(original.pools.getFirst().entries).with(LootItem.lootTableItem(ItemRegistry.LEATHER_UPGRADE_SMITHING_TEMPLATE_ITEM.get()).when(BiomesCheck.builder(Biomes.SNOWY_TAIGA)).build()).build()) + .build(); } return null; } @@ -91,14 +87,14 @@ private static LootPool buildPool(float chance, Item item) { } /** - * Builds a loot pool with the given random {@code chance} to find a {@link LeatheredBootsItem} of the given {@link LeatheredArmorMaterial}. + * Builds a loot pool with the given random {@code chance} to find the given {@link LeatheredBootsItem}. * * @param chance chance to spawn the item. - * @param armorMaterial {@link LeatheredArmorMaterial}. + * @param item leathered boots item. * @return loot pool. */ - private static LootPool buildPool(float chance, LeatheredArmorMaterial armorMaterial) { - return buildPool(chance, LeatheredBootsManager.getBoots(Constants.MOD_ID, armorMaterial)); + private static LootPool buildPool(float chance, Supplier item) { + return buildPool(chance, item.get()); } /** diff --git a/fabric/src/main/java/it/crystalnest/leathered_boots/mixin/PiglinAiMixin.java b/fabric/src/main/java/it/crystalnest/leathered_boots/mixin/PiglinAiMixin.java index 522fcf0..efd939e 100644 --- a/fabric/src/main/java/it/crystalnest/leathered_boots/mixin/PiglinAiMixin.java +++ b/fabric/src/main/java/it/crystalnest/leathered_boots/mixin/PiglinAiMixin.java @@ -1,7 +1,6 @@ package it.crystalnest.leathered_boots.mixin; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; -import it.crystalnest.leathered_boots.item.LeatheredBootsItem; +import it.crystalnest.leathered_boots.item.ItemRegistry; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.monster.piglin.PiglinAi; @@ -18,14 +17,14 @@ public abstract class PiglinAiMixin { /** * Injects at the start of the method {@link PiglinAi#isWearingGold(LivingEntity)}.
- * Adds a check for {@link LeatheredArmorMaterial#LEATHERED_GOLD}. + * Adds a check for {@link ItemRegistry#LEATHERED_GOLDEN_BOOTS}. * * @param entity {@link LivingEntity} to check. * @param cir {@link CallbackInfoReturnable}. */ @Inject(method = "isWearingGold", at = @At(value = "HEAD"), cancellable = true) private static void onIsWearingGold(LivingEntity entity, CallbackInfoReturnable cir) { - if (entity.getItemBySlot(EquipmentSlot.FEET).getItem() instanceof LeatheredBootsItem leatheredBoots && leatheredBoots.getMaterial() == LeatheredArmorMaterial.LEATHERED_GOLD) { + if (entity.getItemBySlot(EquipmentSlot.FEET).getItem() == ItemRegistry.LEATHERED_GOLDEN_BOOTS.get()) { cir.setReturnValue(true); } } diff --git a/fabric/src/main/java/it/crystalnest/leathered_boots/platform/FabricItemHelper.java b/fabric/src/main/java/it/crystalnest/leathered_boots/platform/FabricItemHelper.java index 6c990db..e0eb192 100644 --- a/fabric/src/main/java/it/crystalnest/leathered_boots/platform/FabricItemHelper.java +++ b/fabric/src/main/java/it/crystalnest/leathered_boots/platform/FabricItemHelper.java @@ -1,12 +1,13 @@ package it.crystalnest.leathered_boots.platform; import com.google.common.base.Suppliers; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; import it.crystalnest.leathered_boots.platform.services.ItemHelper; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.minecraft.core.Holder; import net.minecraft.core.cauldron.CauldronInteraction; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; @@ -17,9 +18,9 @@ */ public final class FabricItemHelper extends ItemHelper { @Override - public Supplier supplyItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant) { + public Supplier supplyItem(int durabilityFactor, boolean isFireResistant, Holder armorMaterial) { return Suppliers.memoize(() -> { - LeatheredBootsItem item = new LeatheredBootsItem(armorMaterial, isFireResistant); + LeatheredBootsItem item = new LeatheredBootsItem(armorMaterial, durabilityFactor, isFireResistant); CauldronInteraction.WATER.map().put(item, CauldronInteraction.DYED_ITEM); return item; }); diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index a9fa628..7b1ad31 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -32,7 +32,7 @@ "fabricloader": ">=${fabric_loader_version}", "fabric-api": "*", "minecraft": "${minecraft_version}", - "java": ">=17", + "java": ">=${java_version}", "cobweb": "^${cobweb_version}" } } diff --git a/fabric/src/main/resources/leathered_boots.fabric.mixins.json b/fabric/src/main/resources/leathered_boots.fabric.mixins.json index d582a9c..3617d8f 100644 --- a/fabric/src/main/resources/leathered_boots.fabric.mixins.json +++ b/fabric/src/main/resources/leathered_boots.fabric.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "${group}.${mod_id}.mixin", "refmap": "${mod_id}.refmap.json", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_${java_version}", "mixins": [ "PiglinAiMixin" ], diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index ca27c87..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,110 +0,0 @@ -plugins { - id "net.minecraftforge.gradle" version "[6.0,6.2)" - id "org.spongepowered.mixin" version "0.7-SNAPSHOT" -} - -mixin { - add(sourceSets.main, "${mod_id}.refmap.json") - config("${mod_id}.mixins.json") - config("${mod_id}.forge.mixins.json") -} - -minecraft { - mappings channel: "official", version: minecraft_version - - copyIdeResources = true // Calls processResources when in dev - - if (file("src/main/resources/META-INF/accesstransformer.cfg").exists()) { - accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg") - } - - runs { - client { - workingDirectory project.file("run") - ideaModule "${rootProject.name}.${project.name}.main" - taskName "Client" - property "mixin.env.remapRefMap", 'true' - property "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg" - mods { - modClientRun { - source sourceSets.main - source project(":common").sourceSets.main - } - } - } - - server { - workingDirectory project.file("run") - ideaModule "${rootProject.name}.${project.name}.main" - taskName "Server" - property "mixin.env.remapRefMap", "true" - property "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg" - mods { - modServerRun { - source sourceSets.main - source project(":common").sourceSets.main - } - } - } - - data { - workingDirectory project.file("run") - ideaModule "${rootProject.name}.${project.name}.main" - args "--mod", mod_id, "--all", "--output", file("src/generated/resources/"), "--existing", file("src/main/resources/") - taskName "Data" - property "mixin.env.remapRefMap", "true" - property "mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg" - mods { - modDataRun { - source sourceSets.main - source project(":common").sourceSets.main - } - } - } - } -} - -sourceSets.main.resources.srcDir "src/generated/resources" - -dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - compileOnly project(":common") - annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor") - compileOnly annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.6") - implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.3.6")) { jarJar.ranged(it, "[0.3.6,)") } - implementation fg.deobf("it.crystalnest:cobweb-forge:${minecraft_version}-${cobweb_version}") -} - -tasks.withType(JavaCompile).configureEach { - source(project(":common").sourceSets.main.allSource) -} -tasks.withType(Javadoc).configureEach { - source(project(":common").sourceSets.main.allJava) -} -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} - -processResources { - from project(":common").sourceSets.main.resources -} - -jar.finalizedBy("configureReobfTaskForReobfJar") -jar.finalizedBy("reobfJar") - -// Task seems bugged, breaks build because of mod dependencies in the Common project, with no apparent workaround. -tasks.named("compileTestJava").get().setEnabled(false) - -sourceSets.each { - def dir = layout.buildDirectory.dir("sourcesSets/$it.name") - it.output.resourcesDir = dir - it.java.destinationDirectory = dir -} - -publishing { - publications { - gpr(MavenPublication) { - fg.component(it) - } - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/ModLoader.java b/forge/src/main/java/it/crystalnest/leathered_boots/ModLoader.java deleted file mode 100644 index 9b52bc7..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/ModLoader.java +++ /dev/null @@ -1,21 +0,0 @@ -package it.crystalnest.leathered_boots; - -import it.crystalnest.leathered_boots.loot.LootRegistry; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.jetbrains.annotations.ApiStatus; - -/** - * Mod loader. - */ -@ApiStatus.Internal -@Mod(Constants.MOD_ID) -public final class ModLoader { - /** - * Mod initialization. - */ - public ModLoader() { - CommonModLoader.init(); - LootRegistry.register(FMLJavaModLoadingContext.get().getModEventBus()); - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java b/forge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java deleted file mode 100644 index 905d787..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package it.crystalnest.leathered_boots.handler; - -import it.crystalnest.leathered_boots.Constants; -import it.crystalnest.leathered_boots.api.LeatheredBootsManager; -import it.crystalnest.leathered_boots.item.LeatheredBootsItem; -import net.minecraft.client.color.item.ItemColor; -import net.minecraft.world.item.DyeableLeatherItem; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.RegisterColorHandlersEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -/** - * Client events handler. - */ -@Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) -public final class ClientEventsHandler { - private ClientEventsHandler() {} - - /** - * Registers the {@link ItemColor} for all {@link LeatheredBootsItem}s. - * - * @param event {@link RegisterColorHandlersEvent.Item}. - */ - @SubscribeEvent - public static void handleItem(RegisterColorHandlersEvent.Item event) { - event.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((DyeableLeatherItem) stack.getItem()).getColor(stack), LeatheredBootsManager.getBoots().toArray(LeatheredBootsItem[]::new)); - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java b/forge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java deleted file mode 100644 index 4f1fd05..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package it.crystalnest.leathered_boots.handler; - -import it.crystalnest.leathered_boots.Constants; -import it.crystalnest.leathered_boots.api.LeatheredBootsManager; -import it.crystalnest.leathered_boots.item.LeatheredBootsItem; -import net.minecraft.core.cauldron.CauldronInteraction; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; - -/** - * Event handler for events fired on the {@link Mod.EventBusSubscriber.Bus#MOD Mod Bus}. - */ -@Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public final class ModEventsHandler { - private ModEventsHandler() {} - - /** - * Registers the {@link CauldronInteraction}s for each {@link LeatheredBootsItem}. - * - * @param event {@link FMLCommonSetupEvent}. - */ - @SubscribeEvent - public static void handle(FMLCommonSetupEvent event) { - for (LeatheredBootsItem boots : LeatheredBootsManager.getBoots()) { - CauldronInteraction.WATER.map().put(boots, CauldronInteraction.DYED_ITEM); - } - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java b/forge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java deleted file mode 100644 index 99eea0e..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package it.crystalnest.leathered_boots.handler; - -import it.crystalnest.leathered_boots.Constants; -import net.minecraft.world.entity.npc.VillagerProfession; -import net.minecraft.world.item.trading.MerchantOffer; -import net.minecraftforge.event.village.VillagerTradesEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -import java.util.Map; - -/** - * {@link VillagerTradesEvent} handler. - */ -@Mod.EventBusSubscriber(modid = Constants.MOD_ID) -public final class VillagerTradesEventHandler { - private VillagerTradesEventHandler() {} - - /** - * Adds trades for some leathered boots. - * - * @param event {@link VillagerTradesEvent}. - */ - @SubscribeEvent - public static void handle(VillagerTradesEvent event) { - if (event.getType() == VillagerProfession.LEATHERWORKER) { - for (Map.Entry trade : Constants.LEATHERED_BOOTS_TRADES.get().entrySet()) { - event.getTrades().get(trade.getKey().intValue()).add((trader, rand) -> trade.getValue()); - } - } - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/item/ForgeLeatheredBootsItem.java b/forge/src/main/java/it/crystalnest/leathered_boots/item/ForgeLeatheredBootsItem.java deleted file mode 100644 index 0906bac..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/item/ForgeLeatheredBootsItem.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.crystalnest.leathered_boots.item; - -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; - -/** - * Forge Leathered Boots item. - */ -public class ForgeLeatheredBootsItem extends LeatheredBootsItem { - /** - * @param armorMaterial {@link LeatheredArmorMaterial}. - * @param isFireResistant {@link #isFireResistant}. - */ - public ForgeLeatheredBootsItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant) { - super(armorMaterial, isFireResistant); - } - - @Override - public final boolean canWalkOnPowderedSnow(ItemStack stack, LivingEntity wearer) { - return true; - } - - @Override - public final boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer) { - return getMaterial() == LeatheredArmorMaterial.LEATHERED_GOLD; - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java b/forge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java deleted file mode 100644 index c4f414a..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java +++ /dev/null @@ -1,105 +0,0 @@ -package it.crystalnest.leathered_boots.loot; - -import com.google.common.base.Suppliers; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; -import java.util.function.Supplier; - -/** - * Archaeology loot modifier. - */ -public final class ArchaeologyLootModifier extends LootModifier { - /** - * {@link Supplier} for this {@link LootModifier} {@link Codec}. - */ - public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(instance -> codecStart(instance) - .and(Addition.CODEC.listOf().fieldOf("additions").forGetter(modifier -> modifier.additions)) - .and(Codec.FLOAT.fieldOf("chance_to_replace").forGetter(modifier -> modifier.chanceToReplace)) - .apply(instance, ArchaeologyLootModifier::new))); - - /** - * Additional items to add to the chest loot. - */ - private final List additions; - - /** - * Chance to replace the current archaeology loot. - */ - private final Float chanceToReplace; - - /** - * @param conditionsIn {@link LootModifier#conditions}. - * @param additions {@link #additions}. - * @param chanceToReplace {@link #chanceToReplace}. - */ - ArchaeologyLootModifier(LootItemCondition[] conditionsIn, List additions, Float chanceToReplace) { - super(conditionsIn); - this.additions = additions; - this.chanceToReplace = chanceToReplace; - } - - @NotNull - @Override - protected ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { - List items = additions.stream().filter(addition -> BiomesCheck.builder(addition.biomes).build().test(context)).map(addition -> addition.item).toList(); - if (!items.isEmpty() && context.getRandom().nextFloat() <= chanceToReplace) { - generatedLoot.clear(); - generatedLoot.add(new ItemStack(items.get(context.getRandom().nextInt(0, items.size())))); - } - return generatedLoot; - } - - @NotNull - @Override - public Codec codec() { - return CODEC.get(); - } - - /** - * A single item addition to the loot. - */ - private static final class Addition { - /** - * {@link Codec}. - */ - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(addition -> addition.item), - ResourceKey.codec(Registries.BIOME).listOf().optionalFieldOf("biomes").forGetter(addition -> Optional.of(addition.biomes)) - ).apply(instance, Addition::new)); - - /** - * {@link Item} to add to the loot. - */ - private final Item item; - - /** - * Allowed biomes for the {@link #item} to add to the loot.
- * When empty or not specified, all biomes are allowed. - */ - private final List> biomes; - - /** - * @param item {@link #item}. - * @param biomes {@link #biomes}. - */ - private Addition(Item item, Optional>> biomes) { - this.item = item; - this.biomes = biomes.orElse(List.of()); - } - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java b/forge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java deleted file mode 100644 index 30caff3..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java +++ /dev/null @@ -1,112 +0,0 @@ -package it.crystalnest.leathered_boots.loot; - -import com.google.common.base.Suppliers; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; -import java.util.function.Supplier; - -/** - * Chests loot modifier. - */ -public final class ChestLootModifier extends LootModifier { - /** - * {@link Supplier} for this {@link LootModifier} {@link Codec}. - */ - public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(instance -> codecStart(instance) - .and(Addition.CODEC.listOf().fieldOf("additions").forGetter(modifier -> modifier.additions)) - .apply(instance, ChestLootModifier::new))); - - /** - * Additional items to add to the chest loot. - */ - private final List additions; - - /** - * @param conditionsIn {@link LootModifier#conditions}. - * @param additions {@link #additions}. - */ - ChestLootModifier(LootItemCondition[] conditionsIn, List additions) { - super(conditionsIn); - this.additions = additions; - } - - @NotNull - @Override - protected ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { - for (Addition addition : additions) { - if (BiomesCheck.builder(addition.biomes).build().test(context) && context.getRandom().nextFloat() <= addition.chance) { - generatedLoot.add(new ItemStack(addition.item, addition.quantity)); - } - } - return generatedLoot; - } - - @Override - public Codec codec() { - return CODEC.get(); - } - - /** - * A single item addition to the loot. - */ - private static final class Addition { - /** - * {@link Codec}. - */ - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(addition -> addition.item), - Codec.FLOAT.fieldOf("chance").forGetter(addition -> addition.chance), - Codec.INT.fieldOf("quantity").forGetter(addition -> addition.quantity), - ResourceKey.codec(Registries.BIOME).listOf().optionalFieldOf("biomes").forGetter(addition -> Optional.of(addition.biomes)) - ).apply(instance, Addition::new)); - - /** - * {@link Item} to add to the loot. - */ - private final Item item; - - /** - * Chance for this {@link #item} to add to the loot. - */ - private final Float chance; - - /** - * Amount of this {@link #item} to add to the loot. - */ - private final Integer quantity; - - /** - * Allowed biomes for the {@link #item} to add to the loot.
- * When empty or not specified, it allows all biomes. - */ - private final List> biomes; - - /** - * @param item {@link #item}. - * @param chance {@link #chance}. - * @param quantity {@link #quantity}. - * @param biomes {@link #biomes}. - */ - private Addition(Item item, Float chance, Integer quantity, Optional>> biomes) { - this.item = item; - this.chance = chance; - this.quantity = quantity; - this.biomes = biomes.orElse(List.of()); - } - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java b/forge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java deleted file mode 100644 index 605697a..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java +++ /dev/null @@ -1,34 +0,0 @@ -package it.crystalnest.leathered_boots.loot; - -import com.mojang.serialization.Codec; -import it.crystalnest.leathered_boots.Constants; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; - -/** - * Registry for loot modifiers. - */ -public final class LootRegistry { - /** - * {@link DeferredRegister} for {@link IGlobalLootModifier}s. - */ - private static final DeferredRegister> LOOT_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Constants.MOD_ID); - - static { - LOOT_MODIFIERS.register("chest_loot_modifier", ChestLootModifier.CODEC); - LOOT_MODIFIERS.register("archaeology_loot_modifier", ArchaeologyLootModifier.CODEC); - } - - private LootRegistry() {} - - /** - * Registers all loot modifiers. - * - * @param bus {@link IEventBus}. - */ - public static void register(IEventBus bus) { - LOOT_MODIFIERS.register(bus); - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/platform/ForgeItemHelper.java b/forge/src/main/java/it/crystalnest/leathered_boots/platform/ForgeItemHelper.java deleted file mode 100644 index 6d1daef..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/platform/ForgeItemHelper.java +++ /dev/null @@ -1,26 +0,0 @@ -package it.crystalnest.leathered_boots.platform; - -import it.crystalnest.leathered_boots.item.ForgeLeatheredBootsItem; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; -import it.crystalnest.leathered_boots.item.LeatheredBootsItem; -import it.crystalnest.leathered_boots.platform.services.ItemHelper; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; - -import java.util.function.Supplier; - -/** - * Forge item helper. - */ -public final class ForgeItemHelper extends ItemHelper { - @Override - public Supplier supplyItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant) { - return () -> new ForgeLeatheredBootsItem(armorMaterial, isFireResistant); - } - - @Override - protected Supplier buildTab(Supplier icon, Component title, CreativeModeTab.DisplayItemsGenerator displayItemsGenerator) { - return () -> CreativeModeTab.builder().icon(icon).title(title).displayItems(displayItemsGenerator).build(); - } -} diff --git a/forge/src/main/java/it/crystalnest/leathered_boots/platform/ForgePlatformHelper.java b/forge/src/main/java/it/crystalnest/leathered_boots/platform/ForgePlatformHelper.java deleted file mode 100644 index ea93878..0000000 --- a/forge/src/main/java/it/crystalnest/leathered_boots/platform/ForgePlatformHelper.java +++ /dev/null @@ -1,26 +0,0 @@ -package it.crystalnest.leathered_boots.platform; - -import it.crystalnest.cobweb.platform.model.Platform; -import it.crystalnest.leathered_boots.platform.services.PlatformHelper; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.FMLLoader; - -/** - * Forge platform helper. - */ -public final class ForgePlatformHelper implements PlatformHelper { - @Override - public Platform getPlatformName() { - return Platform.FORGE; - } - - @Override - public boolean isModLoaded(String modId) { - return ModList.get().isLoaded(modId); - } - - @Override - public boolean isDevEnv() { - return !FMLLoader.isProduction(); - } -} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 5322905..0000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,32 +0,0 @@ -modLoader = "javafml" #mandatory -loaderVersion = "${forge_loader_version_range}" #mandatory -license = "${license}" -issueTrackerURL="https://github.com/${github_user}/${mod_id_kebab}/issues" #optional -[[mods]] #mandatory - modId = "${mod_id}" #mandatory - version = "${mod_version}" #mandatory - displayName = "${mod_title}" #mandatory - updateJSONURL = "https://api.modrinth.com/updates/${mod_id_kebab}/forge_updates.json" #optional (see https://docs.neoforged.net/docs/misc/updatechecker/) - displayURL = "https://github.com/${github_user}/${mod_id_kebab}/tree/${minecraft_version}" #optional (displayed in the mod UI) - logoFile = "banner.png" #optional - credits = "${credits}" #optional - authors = "${mod_authors}" #optional - description = '''${description}''' #mandatory (Supports multiline text) -[[dependencies.${mod_id}]] #optional - modId = "forge" #mandatory - mandatory = true #mandatory - versionRange = "${forge_loader_version_range}" #mandatory - ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory - side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER' -[[dependencies.${mod_id}]] - modId = "minecraft" - mandatory = true - versionRange = "${minecraft_version_range}" - ordering = "NONE" - side = "BOTH" -[[dependencies.${mod_id}]] - modId = "cobweb" - mandatory = true - versionRange = "[${cobweb_version},)" - ordering = "NONE" - side = "BOTH" diff --git a/forge/src/main/resources/META-INF/services/it.crystalnest.leathered_boots.platform.services.ItemHelper b/forge/src/main/resources/META-INF/services/it.crystalnest.leathered_boots.platform.services.ItemHelper deleted file mode 100644 index 76df086..0000000 --- a/forge/src/main/resources/META-INF/services/it.crystalnest.leathered_boots.platform.services.ItemHelper +++ /dev/null @@ -1 +0,0 @@ -it.crystalnest.leathered_boots.platform.ForgeItemHelper \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/services/it.crystalnest.leathered_boots.platform.services.PlatformHelper b/forge/src/main/resources/META-INF/services/it.crystalnest.leathered_boots.platform.services.PlatformHelper deleted file mode 100644 index 68b6fbf..0000000 --- a/forge/src/main/resources/META-INF/services/it.crystalnest.leathered_boots.platform.services.PlatformHelper +++ /dev/null @@ -1 +0,0 @@ -it.crystalnest.leathered_boots.platform.ForgePlatformHelper \ No newline at end of file diff --git a/forge/src/main/resources/data/forge/loot_modifiers/global_loot_modifiers.json b/forge/src/main/resources/data/forge/loot_modifiers/global_loot_modifiers.json deleted file mode 100644 index 8b91601..0000000 --- a/forge/src/main/resources/data/forge/loot_modifiers/global_loot_modifiers.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "replace": false, - "entries": [ - "leathered_boots:igloo_chest_loot_modifier", - "leathered_boots:pillager_outpost_loot_modifier", - "leathered_boots:shipwreck_loot_modifier", - "leathered_boots:trail_ruins_loot_modifier", - "leathered_boots:village_snowy_house_loot_modifier" - ] -} \ No newline at end of file diff --git a/forge/src/main/resources/data/leathered_boots/loot_modifiers/igloo_chest_loot_modifier.json b/forge/src/main/resources/data/leathered_boots/loot_modifiers/igloo_chest_loot_modifier.json deleted file mode 100644 index 3a207a8..0000000 --- a/forge/src/main/resources/data/leathered_boots/loot_modifiers/igloo_chest_loot_modifier.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "type": "leathered_boots:chest_loot_modifier", - "conditions": [ - { - "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:chests/igloo_chest" - } - ], - "additions": [ - { - "item": "leathered_boots:leathered_gold_boots", - "chance": 0.2, - "quantity": 1 - }, - { - "item": "leathered_boots:leathered_iron_boots", - "chance": 0.1, - "quantity": 1 - }, - { - "item": "leathered_boots:leathered_diamond_boots", - "chance": 0.05, - "quantity": 1 - }, - { - "item": "leathered_boots:leather_upgrade_smithing_template", - "chance": 0.5, - "quantity": 1 - } - ] -} \ No newline at end of file diff --git a/forge/src/main/resources/data/leathered_boots/loot_modifiers/pillager_outpost_loot_modifier.json b/forge/src/main/resources/data/leathered_boots/loot_modifiers/pillager_outpost_loot_modifier.json deleted file mode 100644 index 9107aa8..0000000 --- a/forge/src/main/resources/data/leathered_boots/loot_modifiers/pillager_outpost_loot_modifier.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "leathered_boots:chest_loot_modifier", - "conditions": [ - { - "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:chests/pillager_outpost" - } - ], - "additions": [ - { - "item": "leathered_boots:leather_upgrade_smithing_template", - "chance": 0.334, - "quantity": 1, - "biomes": [ - "grove", - "snowy_slopes", - "jagged_peaks", - "frozen_peaks", - "snowy_taiga", - "snowy_plains" - ] - } - ] -} \ No newline at end of file diff --git a/forge/src/main/resources/data/leathered_boots/loot_modifiers/shipwreck_loot_modifier.json b/forge/src/main/resources/data/leathered_boots/loot_modifiers/shipwreck_loot_modifier.json deleted file mode 100644 index a614a93..0000000 --- a/forge/src/main/resources/data/leathered_boots/loot_modifiers/shipwreck_loot_modifier.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "type": "leathered_boots:chest_loot_modifier", - "conditions": [ - { - "condition": "any_of", - "terms": [ - { - "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:chests/shipwreck_map" - }, - { - "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:chests/shipwreck_treasure" - }, - { - "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:chests/shipwreck_supply" - } - ] - } - ], - "additions": [ - { - "item": "leathered_boots:leather_upgrade_smithing_template", - "chance": 0.2, - "quantity": 1, - "biomes": [ - "snowy_beach" - ] - } - ] -} \ No newline at end of file diff --git a/forge/src/main/resources/data/leathered_boots/loot_modifiers/trail_ruins_loot_modifier.json b/forge/src/main/resources/data/leathered_boots/loot_modifiers/trail_ruins_loot_modifier.json deleted file mode 100644 index 92e1f65..0000000 --- a/forge/src/main/resources/data/leathered_boots/loot_modifiers/trail_ruins_loot_modifier.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "leathered_boots:archaeology_loot_modifier", - "conditions": [ - { - "condition": "forge:loot_table_id", - "loot_table_id": "archaeology/trail_ruins_rare" - } - ], - "additions": [ - { - "item": "leathered_boots:leather_upgrade_smithing_template", - "biomes": [ - "snowy_taiga" - ] - } - ], - "chance_to_replace": 0.0834 -} \ No newline at end of file diff --git a/forge/src/main/resources/data/leathered_boots/loot_modifiers/village_snowy_house_loot_modifier.json b/forge/src/main/resources/data/leathered_boots/loot_modifiers/village_snowy_house_loot_modifier.json deleted file mode 100644 index c90db0a..0000000 --- a/forge/src/main/resources/data/leathered_boots/loot_modifiers/village_snowy_house_loot_modifier.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "leathered_boots:chest_loot_modifier", - "conditions": [ - { - "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:chests/village/village_snowy_house" - } - ], - "additions": [ - { - "item": "leathered_boots:leathered_chainmail_boots", - "chance": 0.2, - "quantity": 1 - }, - { - "item": "leathered_boots:leathered_iron_boots", - "chance": 0.1, - "quantity": 1 - }, - { - "item": "leathered_boots:leathered_diamond_boots", - "chance": 0.05, - "quantity": 1 - } - ] -} \ No newline at end of file diff --git a/forge/src/main/resources/leathered_boots.forge.mixins.json b/forge/src/main/resources/leathered_boots.forge.mixins.json deleted file mode 100644 index f588bd5..0000000 --- a/forge/src/main/resources/leathered_boots.forge.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "${group}.${mod_id}.mixin", - "refmap": "${mod_id}.refmap.json", - "compatibilityLevel": "JAVA_17", - "mixins": [], - "client": [], - "server": [], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0801a9b..d6a03c2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,7 @@ # Every field must be added to the root build.gradle expandProps map. # Common +java_version = 21 mod_version = 4.0.0 group = it.crystalnest mod_authors = Crystal Spider, Moonstone Webber, Noir @@ -12,23 +13,23 @@ description = Comfy and sturdy boots! credits = github_user = crystal-nest curseforge_id = 689785 -minecraft_version = 1.20.4 -minecraft_version_range = [1.20.4,) +minecraft_version = 1.21 +minecraft_version_range = [1.21,) +# https://parchmentmc.org/docs/getting-started#choose-a-version +parchment_version = 2024.06.23 +# https://projects.neoforged.net/neoforged/neoform +neo_form_version = 1.21-20240613.152323 # Fabric -fabric_version = 0.92.1+1.20.4 -fabric_loader_version = 0.15.3 - -# Forge -forge_version = 49.0.30 -forge_loader_version_range = [49,) +fabric_version = 0.100.6+1.21 +fabric_loader_version = 0.15.11 # NeoForge -neoforge_version = 20.4.170 -neoforge_loader_version_range = [20.4,) +neoforge_version = 21.0.59-beta +neoforge_loader_version_range = [21.0,) # Dependencies -cobweb_version = 1.0.0 +cobweb_version = 1.1.2 # Gradle org.gradle.jvmargs = -Xmx4G diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 5381c9b..04f2adc 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -1,57 +1,38 @@ plugins { - id "net.neoforged.gradle.userdev" version "7.0.84" + id "multiloader-loader" + id "net.neoforged.moddev" } -if (file("src/main/resources/META-INF/accesstransformer.cfg").exists()) { - minecraft.accessTransformers.file file("src/main/resources/META-INF/accesstransformer.cfg") -} -runs { - configureEach { - modSource project.sourceSets.main - } - client { - systemProperty "neoforge.enabledGameTestNamespaces", mod_id +neoForge { + version = neoforge_version + def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg') + if (at.exists()) { + accessTransformers.add(at.absolutePath) } - server { - systemProperty "neoforge.enabledGameTestNamespaces", mod_id - programArgument "--nogui" + parchment { + minecraftVersion = minecraft_version + mappingsVersion = parchment_version } - - gameTestServer { - systemProperty "neoforge.enabledGameTestNamespaces", mod_id + runs { + configureEach { + systemProperty('neoforge.enabledGameTestNamespaces', mod_id) + ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric + } + client { + client() + } + data { + data() + } + server { + server() + } } - - data { - programArguments.addAll "--mod", mod_id, "--all", "--output", file("src/generated/resources/").getAbsolutePath(), "--existing", file("src/main/resources/").getAbsolutePath() + mods { + "${mod_id}" { + sourceSet sourceSets.main + } } } sourceSets.main.resources { srcDir "src/generated/resources" } - -dependencies { - implementation "net.neoforged:neoforge:${neoforge_version}" - implementation project(":common") - implementation "it.crystalnest:cobweb-neoforge:${minecraft_version}-${cobweb_version}" -} - -// NeoGradle compiles the game, but we don't want to add our common code to the game's code -Spec notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec - -tasks.withType(JavaCompile).matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.allSource) -} - -tasks.withType(Javadoc).matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.allJava) -} - -tasks.named("sourcesJar", Jar) { - from(project(":common").sourceSets.main.allSource) -} - -tasks.withType(ProcessResources).matching(notNeoTask).configureEach { - from project(":common").sourceSets.main.resources -} - -// Task seems bugged, breaks build because of mod dependencies in the Common project, with no apparent workaround. -tasks.named('compileTestJava').get().setEnabled(false) diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java index 831caa0..3babf9a 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ClientEventsHandler.java @@ -4,16 +4,16 @@ import it.crystalnest.leathered_boots.api.LeatheredBootsManager; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; import net.minecraft.client.color.item.ItemColor; -import net.minecraft.world.item.DyeableLeatherItem; +import net.minecraft.world.item.component.DyedItemColor; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; /** * Client events handler. */ -@Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +@EventBusSubscriber(modid = Constants.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public final class ClientEventsHandler { private ClientEventsHandler() {} @@ -24,6 +24,6 @@ private ClientEventsHandler() {} */ @SubscribeEvent public static void handleItem(RegisterColorHandlersEvent.Item event) { - event.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((DyeableLeatherItem) stack.getItem()).getColor(stack), LeatheredBootsManager.getBoots().toArray(LeatheredBootsItem[]::new)); + event.register((stack, tintIndex) -> tintIndex > 0 ? -1 : DyedItemColor.getOrDefault(stack, DyedItemColor.LEATHER_COLOR), LeatheredBootsManager.getBoots().toArray(LeatheredBootsItem[]::new)); } } diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java index 766d342..bb7c824 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/ModEventsHandler.java @@ -5,13 +5,13 @@ import it.crystalnest.leathered_boots.item.LeatheredBootsItem; import net.minecraft.core.cauldron.CauldronInteraction; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; /** - * Event handler for events fired on the {@link Mod.EventBusSubscriber.Bus#MOD Mod Bus}. + * Event handler for events fired on the {@link EventBusSubscriber.Bus#MOD Mod Bus}. */ -@Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = Constants.MOD_ID, bus = EventBusSubscriber.Bus.MOD) public final class ModEventsHandler { private ModEventsHandler() {} diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java index 80efb25..6e1198e 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/handler/VillagerTradesEventHandler.java @@ -4,7 +4,7 @@ import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.item.trading.MerchantOffer; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.village.VillagerTradesEvent; import java.util.Map; @@ -12,7 +12,7 @@ /** * {@link VillagerTradesEvent} handler. */ -@Mod.EventBusSubscriber(modid = Constants.MOD_ID) +@EventBusSubscriber(modid = Constants.MOD_ID) public final class VillagerTradesEventHandler { private VillagerTradesEventHandler() {} diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/item/NeoForgeLeatheredBootsItem.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/item/NeoForgeLeatheredBootsItem.java index 8fb2665..b80b9e2 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/item/NeoForgeLeatheredBootsItem.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/item/NeoForgeLeatheredBootsItem.java @@ -1,6 +1,8 @@ package it.crystalnest.leathered_boots.item; +import net.minecraft.core.Holder; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; @@ -9,11 +11,11 @@ */ public class NeoForgeLeatheredBootsItem extends LeatheredBootsItem { /** - * @param armorMaterial {@link LeatheredArmorMaterial}. - * @param isFireResistant {@link #isFireResistant}. + * @param armorMaterial {@link ArmorMaterial}. + * @param isFireResistant whether the boots are fire-resistant. */ - public NeoForgeLeatheredBootsItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant) { - super(armorMaterial, isFireResistant); + public NeoForgeLeatheredBootsItem(Holder armorMaterial, int durabilityFactor, boolean isFireResistant) { + super(armorMaterial, durabilityFactor, isFireResistant); } @Override @@ -23,6 +25,6 @@ public final boolean canWalkOnPowderedSnow(@NotNull ItemStack stack, @NotNull Li @Override public final boolean makesPiglinsNeutral(@NotNull ItemStack stack, @NotNull LivingEntity wearer) { - return getMaterial() == LeatheredArmorMaterial.LEATHERED_GOLD; + return this == ItemRegistry.LEATHERED_GOLDEN_BOOTS.get(); } } diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java index 5d47e06..794cf4d 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ArchaeologyLootModifier.java @@ -2,6 +2,7 @@ import com.google.common.base.Suppliers; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.registries.BuiltInRegistries; @@ -25,9 +26,9 @@ */ public final class ArchaeologyLootModifier extends LootModifier { /** - * {@link Supplier} for this {@link LootModifier} {@link Codec}. + * {@link Supplier} for this {@link LootModifier} {@link MapCodec}. */ - public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(instance -> codecStart(instance) + public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.mapCodec(instance -> codecStart(instance) .and(Addition.CODEC.listOf().fieldOf("additions").forGetter(modifier -> modifier.additions)) .and(Codec.FLOAT.fieldOf("chance_to_replace").forGetter(modifier -> modifier.chanceToReplace)) .apply(instance, ArchaeologyLootModifier::new))); @@ -66,7 +67,7 @@ protected ObjectArrayList doApply(@NotNull ObjectArrayList @NotNull @Override - public Codec codec() { + public MapCodec codec() { return CODEC.get(); } diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java index 79cff73..da7745a 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/ChestLootModifier.java @@ -2,6 +2,7 @@ import com.google.common.base.Suppliers; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.registries.BuiltInRegistries; @@ -25,9 +26,9 @@ */ public final class ChestLootModifier extends LootModifier { /** - * {@link Supplier} for this {@link LootModifier} {@link Codec}. + * {@link Supplier} for this {@link LootModifier} {@link MapCodec}. */ - public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(instance -> codecStart(instance) + public static final Supplier> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.mapCodec(instance -> codecStart(instance) .and(Addition.CODEC.listOf().fieldOf("additions").forGetter(modifier -> modifier.additions)) .apply(instance, ChestLootModifier::new))); @@ -58,7 +59,7 @@ protected ObjectArrayList doApply(@NotNull ObjectArrayList @NotNull @Override - public Codec codec() { + public MapCodec codec() { return CODEC.get(); } diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java index cf291b8..5ac99eb 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/loot/LootRegistry.java @@ -1,6 +1,6 @@ package it.crystalnest.leathered_boots.loot; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import it.crystalnest.leathered_boots.Constants; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.common.loot.IGlobalLootModifier; @@ -14,7 +14,7 @@ public final class LootRegistry { /** * {@link DeferredRegister} for {@link IGlobalLootModifier}s. */ - private static final DeferredRegister> LOOT_MODIFIERS = DeferredRegister.create(NeoForgeRegistries.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Constants.MOD_ID); + private static final DeferredRegister> LOOT_MODIFIERS = DeferredRegister.create(NeoForgeRegistries.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Constants.MOD_ID); static { LOOT_MODIFIERS.register("chest_loot_modifier", ChestLootModifier.CODEC); diff --git a/neoforge/src/main/java/it/crystalnest/leathered_boots/platform/NeoForgeItemHelper.java b/neoforge/src/main/java/it/crystalnest/leathered_boots/platform/NeoForgeItemHelper.java index 0fe5fa9..b66ef9e 100644 --- a/neoforge/src/main/java/it/crystalnest/leathered_boots/platform/NeoForgeItemHelper.java +++ b/neoforge/src/main/java/it/crystalnest/leathered_boots/platform/NeoForgeItemHelper.java @@ -1,10 +1,11 @@ package it.crystalnest.leathered_boots.platform; -import it.crystalnest.leathered_boots.item.LeatheredArmorMaterial; import it.crystalnest.leathered_boots.item.LeatheredBootsItem; import it.crystalnest.leathered_boots.item.NeoForgeLeatheredBootsItem; import it.crystalnest.leathered_boots.platform.services.ItemHelper; +import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; @@ -15,8 +16,8 @@ */ public final class NeoForgeItemHelper extends ItemHelper { @Override - public Supplier supplyItem(LeatheredArmorMaterial armorMaterial, boolean isFireResistant) { - return () -> new NeoForgeLeatheredBootsItem(armorMaterial, isFireResistant); + public Supplier supplyItem(int durabilityFactor, boolean isFireResistant, Holder armorMaterial) { + return () -> new NeoForgeLeatheredBootsItem(armorMaterial, durabilityFactor, isFireResistant); } @Override diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 98% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index d345975..d1418c8 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" #mandatory -loaderVersion = "[2,)" #mandatory +loaderVersion = "[4,)" #mandatory license = "${license}" #mandatory issueTrackerURL="https://github.com/${github_user}/${mod_id_kebab}/issues" #optional [[mods]] #mandatory diff --git a/neoforge/src/main/resources/leathered_boots.neoforge.mixins.json b/neoforge/src/main/resources/leathered_boots.neoforge.mixins.json index 5d29c43..009e244 100644 --- a/neoforge/src/main/resources/leathered_boots.neoforge.mixins.json +++ b/neoforge/src/main/resources/leathered_boots.neoforge.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "${group}.${mod_id}.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_${java_version}", "mixins": [], "client": [], "server": [], diff --git a/settings.gradle b/settings.gradle index b06d199..6489066 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,24 +1,19 @@ pluginManagement { repositories { gradlePluginPortal() - maven { - name = "Fabric" - url = "https://maven.fabricmc.net/" - } - maven { - name = "NeoForge" - url = "https://maven.neoforged.net/releases/" - } - maven { - name = "Forge" - url = "https://maven.minecraftforge.net/" - } - maven { - name = "Sponge Snapshots" - url = "https://repo.spongepowered.org/repository/maven-public/" - } - maven { - url "https://maven.firstdark.dev/releases" + mavenCentral() + maven { url "https://maven.firstdark.dev/releases" } + exclusiveContent { + forRepository { + maven { + name = "Fabric" + url = uri('https://maven.fabricmc.net') + } + } + filter { + includeGroup("net.fabricmc") + includeGroup("fabric-loom") + } } } } @@ -31,5 +26,4 @@ plugins { rootProject.name = "leathered-boots" include("common") include("fabric") -include("forge") include("neoforge")