diff --git a/build.gradle b/build.gradle index dd24204..bdaa304 100644 --- a/build.gradle +++ b/build.gradle @@ -1,73 +1,137 @@ plugins { - id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false - + id 'fabric-loom' version '1.1-SNAPSHOT' + id 'maven-publish' id 'com.matthewprenger.cursegradle' version '1.4.0' - id "com.modrinth.minotaur" version "1.1.0" + id "com.modrinth.minotaur" version "2.+" } -architectury { - minecraft = rootProject.minecraft_version -} +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 + +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. mavenCentral() - maven { - name = "ParchmentMC" - url = "https://maven.parchmentmc.net/" + maven { url 'https://jitpack.io' } // Taterzens itself + maven { url 'https://maven.nucleoid.xyz' } // Nucleoid (good stuff) + maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // Permission API +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + mappings loom.layered { + it.officialMojangMappings() } + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + // Taterzens + // We need this for profession API + modImplementation("com.github.samolego.Taterzens:taterzens-fabric:${project.taterzens}") + modImplementation include("eu.pb4:common-economy-api:${project.common_economy_api}") + modImplementation include("eu.pb4:sgui:${project.sgui}") + + modImplementation include("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${project.config2brigadier}") } -subprojects { - apply plugin: "dev.architectury.loom" +processResources { + inputs.property "version", project.version - loom { - silentMojangMappingsLicense() + filesMatching("fabric.mod.json") { + expand "version": project.version } +} - dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings loom.layered() { - officialMojangMappings() - //parchment("org.parchmentmc.data:parchment-1.18.1:2021.12.19@zip") - } +tasks.withType(JavaCompile).configureEach { + // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. + it.options.release = 17 +} - } +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } -allprojects { - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } +} - archivesBaseName = rootProject.archives_base_name - version = rootProject.mod_version - group = rootProject.maven_group +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} - // jitpack - maven { url "https://jitpack.io" } +def ENV = System.getenv(); - // nucleoid maven - maven { url "https://maven.nucleoid.xyz" } +curseforge { + if (ENV.CURSEFORGE_API_KEY) { + apiKey = ENV.CURSEFORGE_API_KEY + } + + project { + id = "560532" + changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" + releaseType = "release" + addGameVersion project.minecraft_version + addGameVersion "Fabric" + + mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")) { + displayName = "[${project.minecraft_version}] Blacksmiths ${version} [Fabric]" + } - // luckperms maven - maven { url "https://oss.sonatype.org/content/repositories/public/" } + afterEvaluate { + uploadTask.dependsOn("remapJar") + } } - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.release = 17 + options { + forgeGradleIntegration = false } +} + +task { + + token = ENV.MODRINTH_TOKEN + projectId = "C7X7fJhx" + versionNumber = project.minecraft_version + "+" + version + "-fabric" + changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" + versionName = "[${project.minecraft_version}] Blacksmiths ${version} [Fabric]" + versionType = "release" - java { - withSourcesJar() + uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar") + + gameVersions = ["${project.minecraft_version}"] + loaders = ['fabric', 'quilt'] + + dependencies { // A special DSL for creating dependencies + required.project "fabric-api" // Creates a new required dependency on Fabric API } + } diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index 3b15087..0000000 --- a/common/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader - modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}" - - // Taterzens - // We need this for profession API - modCompileOnly("com.github.samolego.Taterzens:taterzens-fabric:${project.taterzens}") -} - -architectury { - common(false) -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/fabric/build.gradle b/fabric/build.gradle deleted file mode 100644 index d51eb7f..0000000 --- a/fabric/build.gradle +++ /dev/null @@ -1,140 +0,0 @@ -import com.modrinth.minotaur.TaskModrinthUpload - -plugins { - id "com.github.johnrengelman.shadow" version "7.1.0" - - id 'com.matthewprenger.cursegradle' - id "com.modrinth.minotaur" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -def ENV = System.getenv(); - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common -} - -repositories { - maven { - name 'Cloth Config' - url 'https://maven.shedaniel.me/' - } - maven { - name 'Mod Menu' - url 'https://maven.terraformersmc.com/releases/' - } -} - -dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}" - - // Taterzens - // We need this for profession API - modImplementation("com.github.samolego.Taterzens:taterzens-fabric:${project.taterzens}") - - modCompileOnly "dev.the-fireplace:Grand-Economy:${project.grandeconomy_version}:api" - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar - classifier "fabric" -} - -jar { - classifier "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} -curseforge { - if (ENV.CURSEFORGE_API_KEY) { - apiKey = ENV.CURSEFORGE_API_KEY - } - - project { - id = "560532" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" - releaseType = "release" - addGameVersion project.minecraft_version - addGameVersion "Fabric" - - mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")) { - displayName = "[${project.minecraft_version}] Blacksmiths ${version} [Fabric]" - } - - afterEvaluate { - uploadTask.dependsOn("remapJar") - } - } - - options { - forgeGradleIntegration = false - } -} - -task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) { - onlyIf { - ENV.MODRINTH_TOKEN - } - - token = ENV.MODRINTH_TOKEN - projectId = "C7X7fJhx" - versionNumber = project.minecraft_version + "+" + version + "-fabric" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" - versionName = "[${project.minecraft_version}] Blacksmiths ${version} [Fabric]" - releaseType = "release" - - uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar") - - addGameVersion("${project.minecraft_version}") - addLoader('fabric') -} \ No newline at end of file diff --git a/fabric/gradle.properties b/fabric/gradle.properties deleted file mode 100644 index 8c4a014..0000000 --- a/fabric/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -grandeconomy_version=5.1.1+1.18 diff --git a/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/platform/GrandEconomyImpl.java b/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/platform/GrandEconomyImpl.java deleted file mode 100644 index fbd3f65..0000000 --- a/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/platform/GrandEconomyImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.samo_lego.blacksmiths.fabric.platform; - -import dev.the_fireplace.annotateddi.api.DIContainer; -import dev.the_fireplace.grandeconomy.api.injectables.CurrencyAPI; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.blacksmiths.economy.VanillaEconomy; - -public class GrandEconomyImpl extends VanillaEconomy { - private final CurrencyAPI currencyApi; - - public GrandEconomyImpl() { - this.currencyApi = DIContainer.get().getInstance(CurrencyAPI.class); - } - - @Override - public double canAfford(double amount, ServerPlayer player) { - return this.currencyApi.getBalance(player.getUUID(), true) - amount; - } - - @Override - public void withdraw(double amount, ServerPlayer player) { - this.currencyApi.addToBalance(player.getUUID(), -amount, true); - } - - @Override - public double getItemConversionCost(double amount) { - return amount; - } - - @Override - public MutableComponent getCurrencyFormat(double amount) { - return Component.literal(this.currencyApi.formatCurrency(amount)); - } -} diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index c883e26..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,130 +0,0 @@ -import com.modrinth.minotaur.TaskModrinthUpload - -plugins { - id "com.github.johnrengelman.shadow" version "7.1.0" - - id 'com.matthewprenger.cursegradle' - id "com.modrinth.minotaur" -} - - -architectury { - platformSetupLoomIde() - forge() -} - -def ENV = System.getenv(); - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common -} - -dependencies { - forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" - - modCompileOnly("com.github.samolego.Taterzens:taterzens-forge:47bd17b207") - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("META-INF/mods.toml") { - expand "version": project.version - } -} - -shadowJar { - exclude "fabric.mod.json" - - configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar - classifier "forge" -} - -jar { - classifier "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} - - - -curseforge { - if (ENV.CURSEFORGE_API_KEY) { - apiKey = ENV.CURSEFORGE_API_KEY - } - - project { - id = "560532" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" - releaseType = "release" - addGameVersion project.minecraft_version - addGameVersion "Forge" - - mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar")) { - displayName = "[${project.minecraft_version}] Blacksmiths ${version} [Forge]" - } - - afterEvaluate { - uploadTask.dependsOn("remapJar") - } - } - - options { - forgeGradleIntegration = false - } -} - -task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) { - onlyIf { - ENV.MODRINTH_TOKEN - } - - token = ENV.MODRINTH_TOKEN - projectId = "C7X7fJhx" - versionNumber = project.minecraft_version + "+" + version + "-forge" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" - versionName = "[${project.minecraft_version}] Blacksmiths ${version} [Forge]" - releaseType = "release" - - uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar") - - addGameVersion("${project.minecraft_version}") - addLoader('forge') -} diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index 32f842a..0000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/org/samo_lego/blacksmiths/forge/BlacksmithsForge.java b/forge/src/main/java/org/samo_lego/blacksmiths/forge/BlacksmithsForge.java deleted file mode 100644 index 05f5710..0000000 --- a/forge/src/main/java/org/samo_lego/blacksmiths/forge/BlacksmithsForge.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.samo_lego.blacksmiths.forge; - -import net.minecraft.commands.Commands; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import org.samo_lego.blacksmiths.Blacksmiths; -import org.samo_lego.blacksmiths.PlatformType; -import org.samo_lego.blacksmiths.economy.VanillaEconomy; -import org.samo_lego.blacksmiths.forge.platform.ForgePlatform; - -@Mod(Blacksmiths.MOD_ID) -public class BlacksmithsForge { - - public static final PlatformType forgePlatform = new ForgePlatform(); - - public BlacksmithsForge() { - MinecraftForge.EVENT_BUS.register(this); - VanillaEconomy economy = new VanillaEconomy(); - new Blacksmiths(forgePlatform, economy); - } - - @SubscribeEvent() - public void registerCommands(RegisterCommandsEvent event) { - forgePlatform.registerCommands(event.getDispatcher(), event.getEnvironment().equals(Commands.CommandSelection.DEDICATED)); - } -} diff --git a/forge/src/main/java/org/samo_lego/blacksmiths/forge/platform/ForgePlatform.java b/forge/src/main/java/org/samo_lego/blacksmiths/forge/platform/ForgePlatform.java deleted file mode 100644 index bedc7cf..0000000 --- a/forge/src/main/java/org/samo_lego/blacksmiths/forge/platform/ForgePlatform.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.samo_lego.blacksmiths.forge.platform; - -import net.minecraftforge.fml.loading.FMLPaths; -import org.samo_lego.blacksmiths.PlatformType; - -import java.nio.file.Path; - -public class ForgePlatform extends PlatformType { - @Override - public Path getConfigPath() { - return FMLPaths.CONFIGDIR.get(); - } -} 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 35a438f..0000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,35 +0,0 @@ -modLoader = "javafml" -loaderVersion = "[38,)" -issueTrackerURL = "https://github.com/samolego/Blacksmiths/issues" -license = "MIT" - -[[mods]] -modId = "blacksmiths" -version = "${version}" -displayName = "Blacksmiths" -authors = "samo_lego" -description = ''' -A Taterzens addon that brings tool-repairing-guys to Minecraft. -''' -logoFile = "blacksmiths_icon.png" - -[[dependencies.blacksmiths]] -modId = "forge" -mandatory = true -versionRange = "[38,)" -ordering = "NONE" -side = "BOTH" - -[[dependencies.blacksmiths]] -modId = "minecraft" -mandatory = true -versionRange = "[1.18,)" -ordering = "NONE" -side = "BOTH" - -[[dependencies.blacksmiths]] -modId = "taterzens" -mandatory = true -versionRange = "[1.6.5,)" -ordering = "AFTER" -side = "BOTH" \ No newline at end of file diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index 9252d3d..0000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Example Mod", - "pack_format": 8 - } -} diff --git a/gradle.properties b/gradle.properties index d15841a..2b454d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,18 @@ org.gradle.jvmargs=-Xmx2048M - -# Fabric -minecraft_version=1.19 -yarn_mappings=1.19+build.4 -loader_version=0.14.8 +# Fabric Properties +minecraft_version=1.19.4 +yarn_mappings=1.19.4+build.1 +loader_version=0.14.18 #Fabric api -fabric_version=0.57.0+1.19 - -#Forge -forge_version=41.0.87 - -mod_version = 1.2.0 +fabric_version=0.76.0+1.19.4 +# Mod Properties +mod_version = 1.3.0 maven_group = org.samo_lego archives_base_name = blacksmiths # Deps -taterzens = 1.10.4 - +taterzens=51402e01fe +sgui=1.2.1+1.19.3 +config2brigadier=1.2.3 +common_economy_api=1.1.0 diff --git a/settings.gradle b/settings.gradle index a82e6f0..f1d40b5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,14 +1,9 @@ pluginManagement { repositories { maven { url "https://maven.fabricmc.net/" } - maven { url "https://maven.architectury.dev/" } maven { url "https://maven.minecraftforge.net/" } gradlePluginPortal() } } -include("common") -include("fabric") -//include("forge") - rootProject.name = "blacksmiths" diff --git a/common/src/main/java/org/samo_lego/blacksmiths/Blacksmiths.java b/src/main/java/org/samo_lego/blacksmiths/Blacksmiths.java similarity index 84% rename from common/src/main/java/org/samo_lego/blacksmiths/Blacksmiths.java rename to src/main/java/org/samo_lego/blacksmiths/Blacksmiths.java index 47f89cc..0ce5b47 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/Blacksmiths.java +++ b/src/main/java/org/samo_lego/blacksmiths/Blacksmiths.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; import org.samo_lego.blacksmiths.config.SmithyConfig; import org.samo_lego.blacksmiths.economy.VanillaEconomy; +import org.samo_lego.blacksmiths.platform.PlatformType; import org.samo_lego.blacksmiths.profession.BlacksmithProfession; import org.samo_lego.taterzens.api.TaterzensAPI; @@ -17,7 +18,7 @@ public class Blacksmiths { private static Blacksmiths INSTANCE; private final Path configPath; - public static final Logger LOGGER = LogManager.getLogger("Blacksmiths"); + public static final Logger LOGGER = LogManager.getLogger(MOD_ID); private VanillaEconomy economy; public Blacksmiths(PlatformType platform, VanillaEconomy economy) { @@ -25,9 +26,7 @@ public Blacksmiths(PlatformType platform, VanillaEconomy economy) { this.economy = economy; this.configPath = Path.of(getConfigPath(platform)); - if (CONFIG == null) { - initConfig(platform); - } + initConfig(platform); TaterzensAPI.registerProfession(BlacksmithProfession.ID, BlacksmithProfession::new); } @@ -44,6 +43,10 @@ public static Blacksmiths getInstance() { return INSTANCE; } + public SmithyConfig getCofig() { + return CONFIG; + } + public File getConfigFile() { return this.configPath.toFile(); } @@ -55,4 +58,8 @@ public VanillaEconomy getEconomy() { public void setEconomy(VanillaEconomy economy) { this.economy = economy; } + + public Logger getLogger() { + return LOGGER; + } } diff --git a/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/BlacksmithsFabric.java b/src/main/java/org/samo_lego/blacksmiths/BlacksmithsFabric.java similarity index 50% rename from fabric/src/main/java/org/samo_lego/blacksmiths/fabric/BlacksmithsFabric.java rename to src/main/java/org/samo_lego/blacksmiths/BlacksmithsFabric.java index c4d9d4b..ca1b9d3 100644 --- a/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/BlacksmithsFabric.java +++ b/src/main/java/org/samo_lego/blacksmiths/BlacksmithsFabric.java @@ -1,28 +1,23 @@ -package org.samo_lego.blacksmiths.fabric; +package org.samo_lego.blacksmiths; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.loader.api.FabricLoader; -import org.samo_lego.blacksmiths.Blacksmiths; import org.samo_lego.blacksmiths.economy.VanillaEconomy; -import org.samo_lego.blacksmiths.fabric.platform.FabricPlatform; -import org.samo_lego.blacksmiths.fabric.platform.GrandEconomyImpl; - -import static org.samo_lego.blacksmiths.Blacksmiths.CONFIG; +import org.samo_lego.blacksmiths.platform.FabricPlatform; public class BlacksmithsFabric implements ModInitializer { @Override public void onInitialize() { - FabricPlatform platform = new FabricPlatform(); + var platform = new FabricPlatform(); Blacksmiths.initConfig(platform); VanillaEconomy economy; - if (FabricLoader.getInstance().isModLoaded("grandeconomy") && !CONFIG.costs.ignoreEconomyMod) { + /*if (FabricLoader.getInstance().isModLoaded("grandeconomy") && !CONFIG.costs.ignoreEconomyMod) { economy = new GrandEconomyImpl(); - } else { - economy = new VanillaEconomy(); - } + } else {*/ + economy = new VanillaEconomy(); + //} new Blacksmiths(platform, economy); CommandRegistrationCallback.EVENT.register((dispatcher, assets, selection) -> platform.registerCommands(dispatcher)); diff --git a/common/src/main/java/org/samo_lego/blacksmiths/command/BlacksmithCommand.java b/src/main/java/org/samo_lego/blacksmiths/command/BlacksmithCommand.java similarity index 100% rename from common/src/main/java/org/samo_lego/blacksmiths/command/BlacksmithCommand.java rename to src/main/java/org/samo_lego/blacksmiths/command/BlacksmithCommand.java diff --git a/common/src/main/java/org/samo_lego/blacksmiths/command/BlacksmithsCommand.java b/src/main/java/org/samo_lego/blacksmiths/command/BlacksmithsCommand.java similarity index 100% rename from common/src/main/java/org/samo_lego/blacksmiths/command/BlacksmithsCommand.java rename to src/main/java/org/samo_lego/blacksmiths/command/BlacksmithsCommand.java diff --git a/common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java b/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java similarity index 88% rename from common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java rename to src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java index 05ca29d..c11da48 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java +++ b/src/main/java/org/samo_lego/blacksmiths/config/SmithyConfig.java @@ -5,16 +5,8 @@ import org.samo_lego.blacksmiths.economy.VanillaEconomy; import org.samo_lego.config2brigadier.IBrigadierConfigurator; import org.samo_lego.config2brigadier.annotation.BrigadierDescription; -import org.samo_lego.config2brigadier.annotation.BrigadierExcluded; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Writer; + +import java.io.*; import java.nio.charset.StandardCharsets; import static org.apache.logging.log4j.LogManager.getLogger; @@ -74,9 +66,12 @@ public static class Costs { @SerializedName("// Whether to force item-based transactions.") public final String _comment_ignoreEconomyMod = ""; - @BrigadierExcluded - @SerializedName("ignore_economy_mod") - public boolean ignoreEconomyMod = false; + + + @SerializedName("// The id of the economy mod to use. If empty, will use the default (above) config.") + public final String _comment_economyModId = ""; + @SerializedName("economy_mod_id") + public String economyModId = ""; @SerializedName("// Whether to add lore with cost info to the item.") public final String _comment_addLore = ""; @@ -147,10 +142,10 @@ public void reload(File file) { SmithyConfig newConfig = loadConfigFile(file); // We can support GrandEconomy -> VanillaEconomy during runtime, but not the other way around. - if (newConfig.costs.ignoreEconomyMod && !this.costs.ignoreEconomyMod) { + if (newConfig.costs.economyModId.isEmpty() && !this.costs.economyModId.isEmpty()) { Blacksmiths.getInstance().setEconomy(new VanillaEconomy()); - } else if (!newConfig.costs.ignoreEconomyMod && this.costs.ignoreEconomyMod) { - getLogger(MOD_ID).warn("Enabling GrandEconomy support during runtime is not supported. Disabling it."); + } else if (!newConfig.costs.economyModId.isEmpty() && this.costs.economyModId.isEmpty()) { + getLogger(MOD_ID).warn("Enabling economy support during runtime is not supported. Disabling it."); } this.reload(newConfig); this.save(); diff --git a/common/src/main/java/org/samo_lego/blacksmiths/economy/VanillaEconomy.java b/src/main/java/org/samo_lego/blacksmiths/economy/VanillaEconomy.java similarity index 95% rename from common/src/main/java/org/samo_lego/blacksmiths/economy/VanillaEconomy.java rename to src/main/java/org/samo_lego/blacksmiths/economy/VanillaEconomy.java index c0fa5c4..be77dbb 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/economy/VanillaEconomy.java +++ b/src/main/java/org/samo_lego/blacksmiths/economy/VanillaEconomy.java @@ -1,6 +1,6 @@ package org.samo_lego.blacksmiths.economy; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; @@ -50,6 +50,6 @@ public MutableComponent getCurrencyFormat(double amount) { public Item getRequiredItem() { ResourceLocation itemId = new ResourceLocation(CONFIG.costs.paymentItem); - return Registry.ITEM.get(itemId); + return BuiltInRegistries.ITEM.get(itemId); } } diff --git a/common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java b/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java similarity index 98% rename from common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java rename to src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java index b447779..0a03114 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java +++ b/src/main/java/org/samo_lego/blacksmiths/gui/RepairGUI.java @@ -13,7 +13,7 @@ import org.samo_lego.blacksmiths.inventory.RepairInventory; import org.samo_lego.blacksmiths.inventory.RepairingSlot; import org.samo_lego.blacksmiths.profession.BlacksmithProfession; -import org.samo_lego.taterzens.gui.ListItemsGUI; +import org.samo_lego.taterzens.fabric.gui.ListItemsGUI; import java.util.List; @@ -167,7 +167,7 @@ public ItemStack removeItemNoUpdate(int index) { public MutableComponent notEnoughMoneyMessage(double needed) { final String message = CONFIG.messages.insufficentCredit; - if (!CONFIG.costs.ignoreEconomyMod) { + if (!CONFIG.costs.economyModId.isEmpty()) { // Round needed to 2 decimals needed = Math.round(needed * 100) / 100.0; } diff --git a/common/src/main/java/org/samo_lego/blacksmiths/inventory/RepairInventory.java b/src/main/java/org/samo_lego/blacksmiths/inventory/RepairInventory.java similarity index 100% rename from common/src/main/java/org/samo_lego/blacksmiths/inventory/RepairInventory.java rename to src/main/java/org/samo_lego/blacksmiths/inventory/RepairInventory.java diff --git a/common/src/main/java/org/samo_lego/blacksmiths/inventory/RepairingSlot.java b/src/main/java/org/samo_lego/blacksmiths/inventory/RepairingSlot.java similarity index 100% rename from common/src/main/java/org/samo_lego/blacksmiths/inventory/RepairingSlot.java rename to src/main/java/org/samo_lego/blacksmiths/inventory/RepairingSlot.java diff --git a/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/platform/FabricPlatform.java b/src/main/java/org/samo_lego/blacksmiths/platform/FabricPlatform.java similarity index 71% rename from fabric/src/main/java/org/samo_lego/blacksmiths/fabric/platform/FabricPlatform.java rename to src/main/java/org/samo_lego/blacksmiths/platform/FabricPlatform.java index 2ef468a..8329d94 100644 --- a/fabric/src/main/java/org/samo_lego/blacksmiths/fabric/platform/FabricPlatform.java +++ b/src/main/java/org/samo_lego/blacksmiths/platform/FabricPlatform.java @@ -1,7 +1,6 @@ -package org.samo_lego.blacksmiths.fabric.platform; +package org.samo_lego.blacksmiths.platform; import net.fabricmc.loader.api.FabricLoader; -import org.samo_lego.blacksmiths.PlatformType; import java.nio.file.Path; diff --git a/common/src/main/java/org/samo_lego/blacksmiths/PlatformType.java b/src/main/java/org/samo_lego/blacksmiths/platform/PlatformType.java similarity index 92% rename from common/src/main/java/org/samo_lego/blacksmiths/PlatformType.java rename to src/main/java/org/samo_lego/blacksmiths/platform/PlatformType.java index fbda7a1..d2a9427 100644 --- a/common/src/main/java/org/samo_lego/blacksmiths/PlatformType.java +++ b/src/main/java/org/samo_lego/blacksmiths/platform/PlatformType.java @@ -1,4 +1,4 @@ -package org.samo_lego.blacksmiths; +package org.samo_lego.blacksmiths.platform; import com.mojang.brigadier.CommandDispatcher; import net.minecraft.commands.CommandSourceStack; diff --git a/common/src/main/java/org/samo_lego/blacksmiths/profession/BlacksmithProfession.java b/src/main/java/org/samo_lego/blacksmiths/profession/BlacksmithProfession.java similarity index 100% rename from common/src/main/java/org/samo_lego/blacksmiths/profession/BlacksmithProfession.java rename to src/main/java/org/samo_lego/blacksmiths/profession/BlacksmithProfession.java diff --git a/common/src/main/resources/blackmiths_icon.png b/src/main/resources/blackmiths_icon.png similarity index 100% rename from common/src/main/resources/blackmiths_icon.png rename to src/main/resources/blackmiths_icon.png diff --git a/fabric/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json similarity index 83% rename from fabric/src/main/resources/fabric.mod.json rename to src/main/resources/fabric.mod.json index e2bd99f..bf36f0b 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -12,11 +12,11 @@ "sources": "https://github.com/FabricMC/fabric-example-mod" }, "license": "MIT", - "icon": "assets/blacksmiths/icon.png", + "icon": "assets/blacksmiths/blacksmiths_icon.png", "environment": "*", "entrypoints": { "main": [ - "org.samo_lego.blacksmiths.fabric.BlacksmithsFabric" + "org.samo_lego.blacksmiths.BlacksmithsFabric" ] }, "depends": {