From 2907a54e1e836d086d3d743b3c2e3253c85c6a30 Mon Sep 17 00:00:00 2001 From: cech12 Date: Sat, 11 May 2024 10:53:50 +0200 Subject: [PATCH] add Fabric (>=0.96.11+1.20.4) support (Fabric, Quilt) - updated BucketLib to 1.20.4-3.2.0.2 - break temperature can also be configured to be negative (Deactivation by setting a number larger than the hottest fluid) - changed the config descriptions to be more precisely --- .github/ISSUE_TEMPLATE/bug.yml | 1 + .github/workflows/cicd-workflow.yml | 38 +++++++++++ CHANGELOG.md | 12 ++++ README.md | 15 +++- build.gradle | 10 ++- .../de/cech12/ceramicbucket/init/ModTags.java | 4 +- .../platform/services/IConfigHelper.java | 16 +++++ .../assets/ceramicbucket/lang/en_us.json | 29 +++++++- fabric/build.gradle | 68 +++++++++++++++++++ .../ceramicbucket/CeramicBucketMod.java | 42 ++++++++++++ .../ceramicbucket/compat/ModMenuCompat.java | 18 +++++ .../platform/FabricConfigHelper.java | 60 ++++++++++++++++ .../platform/FabricPlatformHelper.java | 26 +++++++ ...amicbucket.platform.services.IConfigHelper | 1 + ...icbucket.platform.services.IPlatformHelper | 1 + fabric/src/main/resources/fabric.mod.json | 37 ++++++++++ forge/build.gradle | 7 -- .../ceramicbucket/CeramicBucketMod.java | 14 ++-- .../de/cech12/ceramicbucket/init/ModTags.java | 23 ------- .../platform/ForgeConfigHelper.java | 14 ++-- gradle.properties | 12 ++-- neoforge/build.gradle | 7 -- .../ceramicbucket/CeramicBucketMod.java | 8 +-- .../platform/NeoForgeConfigHelper.java | 14 ++-- settings.gradle | 4 +- 25 files changed, 400 insertions(+), 81 deletions(-) rename {neoforge => common}/src/main/java/de/cech12/ceramicbucket/init/ModTags.java (85%) create mode 100644 fabric/build.gradle create mode 100644 fabric/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java create mode 100644 fabric/src/main/java/de/cech12/ceramicbucket/compat/ModMenuCompat.java create mode 100644 fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricConfigHelper.java create mode 100644 fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricPlatformHelper.java create mode 100644 fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IConfigHelper create mode 100644 fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IPlatformHelper create mode 100644 fabric/src/main/resources/fabric.mod.json delete mode 100644 forge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index e9fb17a..220b9c2 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -23,6 +23,7 @@ body: - Fabric - Forge - NeoForge + - Quilt validations: required: true - type: input diff --git a/.github/workflows/cicd-workflow.yml b/.github/workflows/cicd-workflow.yml index ba58ca4..d171a8e 100644 --- a/.github/workflows/cicd-workflow.yml +++ b/.github/workflows/cicd-workflow.yml @@ -105,3 +105,41 @@ jobs: secrets: github-token: ${{ secrets.GITHUB_TOKEN }} modrinth-token: ${{ secrets.MODRINTH_API_KEY }} + publish-fabric-on-curseforge: + needs: publish-github + if: startsWith(github.ref, 'refs/tags/') + name: Publish Fabric on Curseforge + uses: cech12/MinecraftModActions/.github/workflows/publish-curseforge.yml@main + with: + java-version: 17 + subproject: fabric + title-prefix: fabric- + curseforge-id: 363799 + game-versions: | + 1.20.4 + release-type: release + loaders: | + fabric + quilt + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }} + publish-fabric-on-modrinth: + needs: publish-github + if: startsWith(github.ref, 'refs/tags/') + name: Publish Fabric on Modrinth + uses: cech12/MinecraftModActions/.github/workflows/publish-modrinth.yml@main + with: + java-version: 17 + subproject: fabric + title-prefix: fabric- + modrinth-id: M9G5zpf1 + game-versions: | + 1.20.4 + release-type: release + loaders: | + fabric + quilt + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + modrinth-token: ${{ secrets.MODRINTH_API_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 361c88b..e40018c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Forge Recommended Versioning](https://mcforge.readthedocs.io/en/latest/conventions/versioning/). +## [1.20.4-5.2.0.0] - 2024-05-11 +### Added +- add Fabric (>=0.96.11+1.20.4) support (Fabric, Quilt) + +### Changed +- updated BucketLib to 1.20.4-3.2.0.2 +- break temperature can also be configured to be negative (Deactivation by setting a number larger than the hottest fluid) +- changed the config descriptions to be more precisely + +### Known issues +- Fabric: max stack size of 16 is not taken into account and defaults to 1 + ## [1.20.4-5.1.0.0] - 2024-01-29 - Update to Minecraft 1.20.4 (Forge 49.0.22, Neoforge 20.4.138-beta) - Update BucketLib to 1.20.4-3.1.0.0 diff --git a/README.md b/README.md index c007773..d64a985 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,21 @@ [![License](https://img.shields.io/github/license/cech12/CeramicBucket)](http://opensource.org/licenses/MIT) [![](https://img.shields.io/discord/752506676719910963.svg?style=flat&color=informational&logo=discord&label=Discord)](https://discord.gg/gRUFH5t) -This is a **Minecraft Forge** mod that adds a **Ceramic Bucket** to the game. - -Since mod version 3.0.0.0 the library mod [BucketLib](https://www.curseforge.com/minecraft/mc-mods/bucketlib) is required. +This is a Minecraft mod that adds a **Ceramic Bucket** to the game. (Forge, NeoForge, Fabric, Quilt) ![All Buckets](https://raw.githubusercontent.com/cech12/CeramicBucket/1.18/material/all_buckets.png) +## Dependencies + +Since mod version 3.0.0.0 the library mod BucketLib ([Github](https://github.com/cech12/BucketLib/), [Curseforge](https://www.curseforge.com/minecraft/mc-mods/bucketlib), [Modrinth](https://modrinth.com/mod/bucketlib)) is required. + +The Fabric / Quilt version needs also the following mods: + +- Fabric API ([Github](https://github.com/FabricMC/fabric), [Curseforge](https://www.curseforge.com/minecraft/mc-mods/fabric-api), [Modrinth](https://modrinth.com/mod/fabric-api)) +- Cloth Config API ([Github](https://github.com/shedaniel/cloth-config), [Curseforge](https://www.curseforge.com/minecraft/mc-mods/cloth-config), [Modrinth](https://modrinth.com/mod/cloth-config)) + +## Features + Adds 2 items to the game: * **Unfired Clay Bucket**: Craftable with three clay balls. diff --git a/build.gradle b/build.gradle index 1f67105..745e848 100644 --- a/build.gradle +++ b/build.gradle @@ -44,6 +44,10 @@ subprojects { name = 'BlameJared Maven (JEI / CraftTweaker / Bookshelf)' url = 'https://maven.blamejared.com' } + maven { + name = 'Jitpack' + url = 'https://jitpack.io' + } } tasks.withType(JavaCompile).configureEach { @@ -60,8 +64,10 @@ subprojects { "forge_version": forge_version, "forge_version_range": forge_version_range, "forge_loader_version_range": forge_loader_version_range, - //"fabric_version": fabric_version, - //"fabric_loader_version": fabric_loader_version, + "fabric_version": fabric_version, + "fabric_loader_version": fabric_loader_version, + "cloth_config_version": cloth_config_version, + "mod_menu_version": mod_menu_version, "neoforge_version": neoforge_version, "neoforge_version_range": neoforge_version_range, "neoforge_loader_version_range": neoforge_loader_version_range, diff --git a/neoforge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java b/common/src/main/java/de/cech12/ceramicbucket/init/ModTags.java similarity index 85% rename from neoforge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java rename to common/src/main/java/de/cech12/ceramicbucket/init/ModTags.java index d633ab3..5588d8d 100644 --- a/neoforge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java +++ b/common/src/main/java/de/cech12/ceramicbucket/init/ModTags.java @@ -1,6 +1,6 @@ package de.cech12.ceramicbucket.init; -import de.cech12.ceramicbucket.CeramicBucketMod; +import de.cech12.ceramicbucket.Constants; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -15,7 +15,7 @@ public static class Fluids { public static final TagKey CERAMIC_CRACKING = tag("ceramic_cracking"); private static TagKey tag(@Nonnull String name) { - return TagKey.create(Registries.FLUID, new ResourceLocation(CeramicBucketMod.MOD_ID, name)); + return TagKey.create(Registries.FLUID, new ResourceLocation(Constants.MOD_ID, name)); } } diff --git a/common/src/main/java/de/cech12/ceramicbucket/platform/services/IConfigHelper.java b/common/src/main/java/de/cech12/ceramicbucket/platform/services/IConfigHelper.java index 903ef94..6026641 100644 --- a/common/src/main/java/de/cech12/ceramicbucket/platform/services/IConfigHelper.java +++ b/common/src/main/java/de/cech12/ceramicbucket/platform/services/IConfigHelper.java @@ -7,12 +7,28 @@ public interface IConfigHelper { /** Default value of break temperature */ int BREAK_TEMPERATURE_DEFAULT = 1000; + /** Config description of the break temperature */ + String BREAK_TEMPERATURE_DESCRIPTION = "Minimum temperature of fluid at which the Ceramic Bucket breaks when emptied. (default: " + BREAK_TEMPERATURE_DEFAULT + ") (Deactivation by setting a number larger than the hottest fluid)"; + /** Minimal value of the break temperature */ + int BREAK_TEMPERATURE_MIN = -10000; + /** Maximal value of the break temperature */ + int BREAK_TEMPERATURE_MAX = 10000; /** Default value of durability */ int DURABILITY_DEFAULT = 0; + /** Config description of the durability */ + String DURABILITY_DESCRIPTION = "Defines the maximum durability of Ceramic Bucket. (default: " + DURABILITY_DEFAULT + ", 0: deactivates the durability)"; + /** Minimal value of the durability */ + int DURABILITY_MIN = 0; + /** Maximal value of the durability */ + int DURABILITY_MAX = 10000; /** Default value of fish obtaining option */ boolean FISH_OBTAINING_ENABLED_DEFAULT = true; + /** Config description of the durability */ + String FISH_OBTAINING_ENABLED_DESCRIPTION = "Whether or not obtaining fish with a Ceramic Bucket should be enabled. (default: " + FISH_OBTAINING_ENABLED_DEFAULT + ")"; /** Default value of milking option */ boolean MILKING_ENABLED_DEFAULT = true; + /** Config description of the milking option */ + String MILKING_ENABLED_DESCRIPTION = "Whether or not milking entities with a Ceramic Bucket should be enabled. (default: " + MILKING_ENABLED_DEFAULT + ")"; /** diff --git a/common/src/main/resources/assets/ceramicbucket/lang/en_us.json b/common/src/main/resources/assets/ceramicbucket/lang/en_us.json index 3044c0e..6f293ce 100644 --- a/common/src/main/resources/assets/ceramicbucket/lang/en_us.json +++ b/common/src/main/resources/assets/ceramicbucket/lang/en_us.json @@ -2,5 +2,32 @@ "item.ceramicbucket.ceramic_bucket": "Ceramic Bucket", "item.ceramicbucket.ceramic_bucket.entity": "Ceramic Bucket of %s", "item.ceramicbucket.ceramic_bucket.filled": "Ceramic %s Bucket", - "item.ceramicbucket.unfired_clay_bucket": "Unfired Clay Bucket" + "item.ceramicbucket.unfired_clay_bucket": "Unfired Clay Bucket", + + "text.autoconfig.ceramicbucket.title": "Ceramic Bucket Settings", + + "text.autoconfig.ceramicbucket.option.BREAK_TEMPERATURE": "Break temperature", + "text.autoconfig.ceramicbucket.option.BREAK_TEMPERATURE.@Tooltip[0]": "§6§lBreak temperature", + "text.autoconfig.ceramicbucket.option.BREAK_TEMPERATURE.@Tooltip[1]": "Minimum temperature of fluid at which the", + "text.autoconfig.ceramicbucket.option.BREAK_TEMPERATURE.@Tooltip[2]": "Ceramic Bucket breaks when emptied.", + "text.autoconfig.ceramicbucket.option.BREAK_TEMPERATURE.@Tooltip[3]": "§7§oDeactivation by setting a number larger than the hottest fluid", + "text.autoconfig.ceramicbucket.option.BREAK_TEMPERATURE.@Tooltip[4]": "§7§oDefault: 1000", + + "text.autoconfig.ceramicbucket.option.DURABILITY": "Durability", + "text.autoconfig.ceramicbucket.option.DURABILITY.@Tooltip[0]": "§6§lDurability", + "text.autoconfig.ceramicbucket.option.DURABILITY.@Tooltip[1]": "Defines the maximum durability of a Ceramic Bucket.", + "text.autoconfig.ceramicbucket.option.DURABILITY.@Tooltip[2]": "§7§o0: deactivates the durability", + "text.autoconfig.ceramicbucket.option.DURABILITY.@Tooltip[3]": "§7§oDefault: 0", + + "text.autoconfig.ceramicbucket.option.FISH_OBTAINING_ENABLED": "Fish obtaining enabled", + "text.autoconfig.ceramicbucket.option.FISH_OBTAINING_ENABLED.@Tooltip[0]": "§6§lFish obtaining enabled", + "text.autoconfig.ceramicbucket.option.FISH_OBTAINING_ENABLED.@Tooltip[1]": "Whether or not obtaining fish with a", + "text.autoconfig.ceramicbucket.option.FISH_OBTAINING_ENABLED.@Tooltip[2]": "Ceramic Bucket should be enabled.", + "text.autoconfig.ceramicbucket.option.FISH_OBTAINING_ENABLED.@Tooltip[3]": "§7§oDefault: true", + + "text.autoconfig.ceramicbucket.option.MILKING_ENABLED": "Milking enabled", + "text.autoconfig.ceramicbucket.option.MILKING_ENABLED.@Tooltip[0]": "§6§lMilking enabled", + "text.autoconfig.ceramicbucket.option.MILKING_ENABLED.@Tooltip[1]": "Whether or not milking entities with a", + "text.autoconfig.ceramicbucket.option.MILKING_ENABLED.@Tooltip[2]": "Ceramic Bucket should be enabled.", + "text.autoconfig.ceramicbucket.option.MILKING_ENABLED.@Tooltip[3]": "§7§oDefault: true" } \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..d3f605c --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,68 @@ +plugins { + id 'java' + id 'idea' + id 'maven-publish' + id 'fabric-loom' version '[1.6.6,1.7)' +} +base { + archivesName = "${mod_id}-fabric" +} + +repositories { + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } +} + +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}" + + modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + modImplementation("com.terraformersmc:modmenu:${mod_menu_version}") + + modImplementation("com.github.cech12.BucketLib:fabric:${bucketlib_version}") + + implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' + compileOnly project(":common") +} + +loom { + if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) { + accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener")) + } + mixin { + defaultRefmapName.set("${mod_id}.refmap.json") + } + runs { + client { + client() + setConfigName("Fabric Client") + ideConfigGenerated(true) + runDir("run") + } + server { + server() + setConfigName("Fabric Server") + ideConfigGenerated(true) + runDir("run") + } + } +} + +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 +} diff --git a/fabric/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java b/fabric/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java new file mode 100644 index 0000000..77605d5 --- /dev/null +++ b/fabric/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java @@ -0,0 +1,42 @@ +package de.cech12.ceramicbucket; + +import de.cech12.bucketlib.api.BucketLibApi; +import de.cech12.bucketlib.api.item.UniversalBucketItem; +import de.cech12.ceramicbucket.init.ModTags; +import de.cech12.ceramicbucket.platform.Services; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.Item; + +@SuppressWarnings("unused") +public class CeramicBucketMod implements ModInitializer { + + public static final ResourceLocation UNFIRED_CLAY_BUCKET_LOCATION = new ResourceLocation(Constants.MOD_ID, "unfired_clay_bucket"); + public static final ResourceLocation CERAMIC_BUCKET_LOCATION = new ResourceLocation(Constants.MOD_ID, "ceramic_bucket"); + + public static final Item UNFIRED_CLAY_BUCKET = Registry.register(BuiltInRegistries.ITEM, UNFIRED_CLAY_BUCKET_LOCATION, new Item(new Item.Properties())); + public static final Item CERAMIC_BUCKET = Registry.register(BuiltInRegistries.ITEM, CERAMIC_BUCKET_LOCATION, new UniversalBucketItem(new UniversalBucketItem.Properties() + .upperCrackingTemperature(Services.CONFIG::getBreakTemperature) + .crackingFluids(ModTags.Fluids.CERAMIC_CRACKING) + .milking(Services.CONFIG::isMilkingEnabled) + .entityObtaining(Services.CONFIG::isFishObtainingEnabled) + .dyeable(14975336) + .durability(Services.CONFIG::getDurability) + )); + + @Override + public void onInitialize() { + CommonLoader.init(); + //register bucket + BucketLibApi.registerBucket(CERAMIC_BUCKET_LOCATION); + //register creative tab + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.INGREDIENTS).register(content -> { + content.accept(UNFIRED_CLAY_BUCKET); + }); + } + +} diff --git a/fabric/src/main/java/de/cech12/ceramicbucket/compat/ModMenuCompat.java b/fabric/src/main/java/de/cech12/ceramicbucket/compat/ModMenuCompat.java new file mode 100644 index 0000000..1a57a96 --- /dev/null +++ b/fabric/src/main/java/de/cech12/ceramicbucket/compat/ModMenuCompat.java @@ -0,0 +1,18 @@ +package de.cech12.ceramicbucket.compat; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import de.cech12.ceramicbucket.platform.FabricConfigHelper; +import me.shedaniel.autoconfig.AutoConfig; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +public class ModMenuCompat implements ModMenuApi { + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(FabricConfigHelper.class, parent).get(); + } + +} diff --git a/fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricConfigHelper.java b/fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricConfigHelper.java new file mode 100644 index 0000000..132c946 --- /dev/null +++ b/fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricConfigHelper.java @@ -0,0 +1,60 @@ +package de.cech12.ceramicbucket.platform; + +import de.cech12.ceramicbucket.Constants; +import de.cech12.ceramicbucket.platform.services.IConfigHelper; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; +import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer; + +/** + * The config service implementation for Fabric. + */ +@Config(name = Constants.MOD_ID) +public class FabricConfigHelper implements ConfigData, IConfigHelper { + + @ConfigEntry.Gui.Tooltip(count = 5) + @ConfigEntry.BoundedDiscrete(min = BREAK_TEMPERATURE_MIN, max = BREAK_TEMPERATURE_MAX) + public long BREAK_TEMPERATURE = BREAK_TEMPERATURE_DEFAULT; + + @ConfigEntry.Gui.Tooltip(count = 4) + @ConfigEntry.BoundedDiscrete(min = DURABILITY_MIN, max = DURABILITY_MAX) + public long DURABILITY = DURABILITY_DEFAULT; + + @ConfigEntry.Gui.Tooltip(count = 4) + public boolean FISH_OBTAINING_ENABLED = FISH_OBTAINING_ENABLED_DEFAULT; + + @ConfigEntry.Gui.Tooltip(count = 4) + public boolean MILKING_ENABLED = MILKING_ENABLED_DEFAULT; + + @Override + public void init() { + AutoConfig.register(FabricConfigHelper.class, Toml4jConfigSerializer::new); + } + + private FabricConfigHelper getConfig() { + return AutoConfig.getConfigHolder(FabricConfigHelper.class).getConfig(); + } + + @Override + public int getBreakTemperature() { + return (int) getConfig().BREAK_TEMPERATURE; + } + + @Override + public int getDurability() { + return (int) getConfig().DURABILITY; + } + + @Override + public boolean isFishObtainingEnabled() { + return getConfig().FISH_OBTAINING_ENABLED; + } + + @Override + public boolean isMilkingEnabled() { + return getConfig().MILKING_ENABLED; + } + +} diff --git a/fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricPlatformHelper.java b/fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricPlatformHelper.java new file mode 100644 index 0000000..597f710 --- /dev/null +++ b/fabric/src/main/java/de/cech12/ceramicbucket/platform/FabricPlatformHelper.java @@ -0,0 +1,26 @@ +package de.cech12.ceramicbucket.platform; + +import de.cech12.ceramicbucket.platform.services.IPlatformHelper; +import net.fabricmc.loader.api.FabricLoader; + +/** + * The platform service implementation for Fabric. + */ +public class FabricPlatformHelper implements IPlatformHelper { + + @Override + public String getPlatformName() { + return "Fabric"; + } + + @Override + public boolean isModLoaded(String modId) { + return FabricLoader.getInstance().isModLoaded(modId); + } + + @Override + public boolean isDevelopmentEnvironment() { + return FabricLoader.getInstance().isDevelopmentEnvironment(); + } + +} diff --git a/fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IConfigHelper b/fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IConfigHelper new file mode 100644 index 0000000..30597d1 --- /dev/null +++ b/fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IConfigHelper @@ -0,0 +1 @@ +de.cech12.ceramicbucket.platform.FabricConfigHelper \ No newline at end of file diff --git a/fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IPlatformHelper b/fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IPlatformHelper new file mode 100644 index 0000000..589a7f3 --- /dev/null +++ b/fabric/src/main/resources/META-INF/services/de.cech12.ceramicbucket.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.cech12.ceramicbucket.platform.FabricPlatformHelper \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..1eeebe6 --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,37 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "version": "${version}", + "name": "${mod_name}", + "description": "${mod_description}", + "authors": [ + "${mod_author}" + ], + "contact": { + "homepage": "${mod_url}", + "sources": "${mod_url}", + "issues": "${mod_issue_tracker}" + }, + "license": "${mod_license}", + "icon": "logo.png", + "environment": "*", + "entrypoints": { + "main": [ + "de.cech12.ceramicbucket.CeramicBucketMod" + ], + "modmenu": [ + "de.cech12.ceramicbucket.compat.ModMenuCompat" + ] + }, + "depends": { + "java": ">=17", + "minecraft": ">=${minecraft_version}", + "fabricloader": ">=${fabric_loader_version}", + "fabric-api": ">=${fabric_version}", + "cloth-config": ">=${cloth_config_version}", + "bucketlib": ">=${bucketlib_version}" + }, + "recommends": { + "modmenu": ">=${mod_menu_version}" + } +} diff --git a/forge/build.gradle b/forge/build.gradle index a2d043e..51593ca 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -59,13 +59,6 @@ sourceSets.each { sourceSets.main.resources.srcDir 'src/generated/resources' -repositories { - maven { - name = 'Jitpack' - url = 'https://jitpack.io' - } -} - dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" compileOnly project(":common") diff --git a/forge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java b/forge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java index d16da03..1f6cef9 100644 --- a/forge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java +++ b/forge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java @@ -21,15 +21,11 @@ import java.util.Arrays; import java.util.List; -import static de.cech12.ceramicbucket.CeramicBucketMod.MOD_ID; - -@Mod(MOD_ID) -@Mod.EventBusSubscriber(modid = MOD_ID) +@Mod(Constants.MOD_ID) +@Mod.EventBusSubscriber(modid = Constants.MOD_ID) public class CeramicBucketMod { - public static final String MOD_ID = "ceramicbucket"; - - public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); + public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Constants.MOD_ID); public static final RegistryObject UNFIRED_CLAY_BUCKET = ITEMS.register("unfired_clay_bucket", () -> new Item(new Item.Properties())); public static final RegistryObject CERAMIC_BUCKET = ITEMS.register("ceramic_bucket", () -> new UniversalBucketItem( @@ -50,7 +46,7 @@ public class CeramicBucketMod { "salmon_ceramic_bucket", "cod_ceramic_bucket", "tropical_fish_ceramic_bucket" - }).map(oldId -> new ResourceLocation(MOD_ID, oldId)).toList(); + }).map(oldId -> new ResourceLocation(Constants.MOD_ID, oldId)).toList(); public CeramicBucketMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); @@ -70,7 +66,7 @@ private void sendImc(InterModEnqueueEvent evt) { @SubscribeEvent public static void remapOldIds(MissingMappingsEvent event) { //to support old versions of this mod - event.getMappings(ForgeRegistries.ITEMS.getRegistryKey(), MOD_ID).forEach(itemMapping -> { + event.getMappings(ForgeRegistries.ITEMS.getRegistryKey(), Constants.MOD_ID).forEach(itemMapping -> { if (oldResourceLocations.stream().anyMatch(itemMapping.getKey()::equals)) { itemMapping.remap(CERAMIC_BUCKET.get()); } diff --git a/forge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java b/forge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java deleted file mode 100644 index ad11563..0000000 --- a/forge/src/main/java/de/cech12/ceramicbucket/init/ModTags.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.cech12.ceramicbucket.init; - -import de.cech12.ceramicbucket.CeramicBucketMod; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.registries.ForgeRegistries; - -import javax.annotation.Nonnull; - -public class ModTags { - - public static class Fluids { - - public static final TagKey CERAMIC_CRACKING = tag("ceramic_cracking"); - - private static TagKey tag(@Nonnull String name) { - return TagKey.create(ForgeRegistries.FLUIDS.getRegistryKey(), new ResourceLocation(CeramicBucketMod.MOD_ID, name)); - } - - } - -} diff --git a/forge/src/main/java/de/cech12/ceramicbucket/platform/ForgeConfigHelper.java b/forge/src/main/java/de/cech12/ceramicbucket/platform/ForgeConfigHelper.java index af42a84..b2869cd 100644 --- a/forge/src/main/java/de/cech12/ceramicbucket/platform/ForgeConfigHelper.java +++ b/forge/src/main/java/de/cech12/ceramicbucket/platform/ForgeConfigHelper.java @@ -17,7 +17,7 @@ */ public class ForgeConfigHelper implements IConfigHelper { - private static ForgeConfigSpec SERVER_CONFIG; + private static final ForgeConfigSpec SERVER_CONFIG; private static final ForgeConfigSpec.IntValue BREAK_TEMPERATURE; private static final ForgeConfigSpec.IntValue DURABILITY; @@ -30,19 +30,19 @@ public class ForgeConfigHelper implements IConfigHelper { builder.push("Balance Options"); BREAK_TEMPERATURE = builder - .comment("Minimum temperature of fluid at which the Ceramic Bucket breaks when emptied. (-1 means that bucket never breaks caused by high fluid temperature)") - .defineInRange("ceramicBucketBreakTemperature", BREAK_TEMPERATURE_DEFAULT, -1, 10000); + .comment(BREAK_TEMPERATURE_DESCRIPTION) + .defineInRange("crackingTemperature", BREAK_TEMPERATURE_DEFAULT, BREAK_TEMPERATURE_MIN, BREAK_TEMPERATURE_MAX); DURABILITY = builder - .comment("Defines the maximum durability of a Ceramic Bucket. (0 deactivates the durability)") - .defineInRange("durability", DURABILITY_DEFAULT, 0, 10000); + .comment(DURABILITY_DESCRIPTION) + .defineInRange("durability", DURABILITY_DEFAULT, DURABILITY_MIN, DURABILITY_MAX); FISH_OBTAINING_ENABLED = builder - .comment("Whether or not obtaining fish with a Ceramic Bucket should be enabled.") + .comment(FISH_OBTAINING_ENABLED_DESCRIPTION) .define("fishObtainingEnabled", FISH_OBTAINING_ENABLED_DEFAULT); MILKING_ENABLED = builder - .comment("Whether or not milking entities with a Ceramic Bucket should be enabled.") + .comment(MILKING_ENABLED_DESCRIPTION) .define("milkingEnabled", MILKING_ENABLED_DEFAULT); builder.pop(); diff --git a/gradle.properties b/gradle.properties index 80fcd7b..9905963 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ # Project group=de.cech12.ceramicbucket -mod_version=5.1.0.0 +mod_version=5.2.0.0 mod_id=ceramicbucket mod_name=Ceramic Bucket mod_author=Cech12 @@ -18,8 +18,10 @@ minecraft_version=1.20.4 minecraft_version_range=[1.20.4, 1.21) # Fabric -#fabric_version=0.91.0+1.20.2 -#fabric_loader_version=0.15.0 +fabric_version=0.96.11+1.20.4 +fabric_loader_version=0.15.7 +cloth_config_version=13.0.121 +mod_menu_version=9.0.0 # Forge forge_version=49.0.22 @@ -32,8 +34,8 @@ neoforge_version_range=[20.4.138-beta,) neoforge_loader_version_range=[2,) #Bucket Lib -bucketlib_version=1.20.4-3.1.0.0 -bucketlib_version_range=[1.20.4-3.1.0.0,) +bucketlib_version=1.20.4-3.2.0.2 +bucketlib_version_range=[1.20.4-3.2.0.2,) # Gradle org.gradle.jvmargs=-Xmx3G diff --git a/neoforge/build.gradle b/neoforge/build.gradle index e3ffbfa..17e7136 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -35,13 +35,6 @@ runs { sourceSets.main.resources { srcDir 'src/generated/resources' } -repositories { - maven { - name = 'Jitpack' - url = 'https://jitpack.io' - } -} - dependencies { implementation "net.neoforged:neoforge:${neoforge_version}" compileOnly project(":common") diff --git a/neoforge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java b/neoforge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java index 5d99ae5..9046de0 100644 --- a/neoforge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java +++ b/neoforge/src/main/java/de/cech12/ceramicbucket/CeramicBucketMod.java @@ -13,14 +13,10 @@ import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; -import static de.cech12.ceramicbucket.CeramicBucketMod.MOD_ID; - -@Mod(MOD_ID) +@Mod(Constants.MOD_ID) public class CeramicBucketMod { - public static final String MOD_ID = "ceramicbucket"; - - public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MOD_ID); + public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Constants.MOD_ID); public static final DeferredItem UNFIRED_CLAY_BUCKET = ITEMS.register("unfired_clay_bucket", () -> new Item(new Item.Properties())); diff --git a/neoforge/src/main/java/de/cech12/ceramicbucket/platform/NeoForgeConfigHelper.java b/neoforge/src/main/java/de/cech12/ceramicbucket/platform/NeoForgeConfigHelper.java index 6b41a6f..7d8c3be 100644 --- a/neoforge/src/main/java/de/cech12/ceramicbucket/platform/NeoForgeConfigHelper.java +++ b/neoforge/src/main/java/de/cech12/ceramicbucket/platform/NeoForgeConfigHelper.java @@ -17,7 +17,7 @@ */ public class NeoForgeConfigHelper implements IConfigHelper { - private static ModConfigSpec SERVER_CONFIG; + private static final ModConfigSpec SERVER_CONFIG; private static final ModConfigSpec.IntValue BREAK_TEMPERATURE; private static final ModConfigSpec.IntValue DURABILITY; @@ -30,19 +30,19 @@ public class NeoForgeConfigHelper implements IConfigHelper { builder.push("Balance Options"); BREAK_TEMPERATURE = builder - .comment("Minimum temperature of fluid at which the Ceramic Bucket breaks when emptied. (-1 means that bucket never breaks caused by high fluid temperature)") - .defineInRange("ceramicBucketBreakTemperature", BREAK_TEMPERATURE_DEFAULT, -1, 10000); + .comment(BREAK_TEMPERATURE_DESCRIPTION) + .defineInRange("crackingTemperature", BREAK_TEMPERATURE_DEFAULT, BREAK_TEMPERATURE_MIN, BREAK_TEMPERATURE_MAX); DURABILITY = builder - .comment("Defines the maximum durability of a Ceramic Bucket. (0 deactivates the durability)") - .defineInRange("durability", DURABILITY_DEFAULT, 0, 10000); + .comment(DURABILITY_DESCRIPTION) + .defineInRange("durability", DURABILITY_DEFAULT, DURABILITY_MIN, DURABILITY_MAX); FISH_OBTAINING_ENABLED = builder - .comment("Whether or not obtaining fish with a Ceramic Bucket should be enabled.") + .comment(FISH_OBTAINING_ENABLED_DESCRIPTION) .define("fishObtainingEnabled", FISH_OBTAINING_ENABLED_DEFAULT); MILKING_ENABLED = builder - .comment("Whether or not milking entities with a Ceramic Bucket should be enabled.") + .comment(MILKING_ENABLED_DESCRIPTION) .define("milkingEnabled", MILKING_ENABLED_DEFAULT); builder.pop(); diff --git a/settings.gradle b/settings.gradle index dfd3917..b102a39 100644 --- a/settings.gradle +++ b/settings.gradle @@ -21,12 +21,12 @@ pluginManagement { } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } // This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606) rootProject.name = 'CeramicBucket' include("common") -//include("fabric") +include("fabric") include("forge") include("neoforge") \ No newline at end of file