From 3478f97ee34c951c9fd39391afa7b743b29c4da2 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Fri, 7 Jun 2024 15:11:49 +0100 Subject: [PATCH 1/2] feat: allow viewing of fluid task fluid recipes in JEI/REI --- .../ftbquests/client/FTBQuestsClient.java | 5 ++++ .../integration/RecipeModHelper.java | 7 ++++++ .../mods/ftbquests/quest/task/FluidTask.java | 24 +++++++++++++++++++ .../assets/ftbquests/lang/en_us.json | 1 + fabric/src/main/resources/fabric.mod.json | 1 + .../src/main/resources/META-INF/mods.toml | 7 ++++++ 6 files changed, 45 insertions(+) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java index 775cb22e..57115970 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java @@ -20,6 +20,7 @@ import dev.ftb.mods.ftbquests.quest.theme.ThemeLoader; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -163,4 +164,8 @@ public static Optional registryAccess() { public static void copyToClipboard(QuestObjectBase qo) { Widget.setClipboardString(qo.getCodeString()); } + + public static boolean isShiftPressed() { + return Screen.hasShiftDown(); + } } \ No newline at end of file diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/integration/RecipeModHelper.java b/common/src/main/java/dev/ftb/mods/ftbquests/integration/RecipeModHelper.java index 67cede3f..b91aa0ac 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/integration/RecipeModHelper.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/integration/RecipeModHelper.java @@ -1,5 +1,6 @@ package dev.ftb.mods.ftbquests.integration; +import dev.architectury.fluid.FluidStack; import dev.ftb.mods.ftbquests.quest.QuestObjectBase; import net.minecraft.world.item.ItemStack; @@ -13,6 +14,8 @@ public interface RecipeModHelper { void showRecipes(ItemStack object); + void showRecipes(FluidStack object); + default boolean isRecipeModAvailable() { return false; } @@ -45,6 +48,10 @@ public void refreshRecipes(QuestObjectBase object) { public void showRecipes(ItemStack object) { } + @Override + public void showRecipes(FluidStack object) { + } + @Override public String getHelperName() { return "NO-OP"; diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/task/FluidTask.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/task/FluidTask.java index 01468cb0..c2a28799 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/task/FluidTask.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/task/FluidTask.java @@ -4,13 +4,18 @@ import dev.ftb.mods.ftblibrary.config.ConfigGroup; import dev.ftb.mods.ftblibrary.icon.Color4I; import dev.ftb.mods.ftblibrary.icon.Icon; +import dev.ftb.mods.ftblibrary.ui.Button; import dev.ftb.mods.ftblibrary.ui.Widget; import dev.ftb.mods.ftblibrary.util.StringUtils; +import dev.ftb.mods.ftblibrary.util.TooltipList; import dev.ftb.mods.ftblibrary.util.client.ClientUtils; import dev.ftb.mods.ftblibrary.util.client.PositionedIngredient; +import dev.ftb.mods.ftbquests.FTBQuests; import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.client.FTBQuestsClient; import dev.ftb.mods.ftbquests.quest.Quest; import dev.ftb.mods.ftbquests.quest.TeamData; +import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -70,6 +75,25 @@ public boolean consumesResources() { return true; } + @Override + public void addMouseOverText(TooltipList list, TeamData teamData) { + super.addMouseOverText(list, teamData); + + if (FTBQuests.getRecipeModHelper().isRecipeModAvailable()) { + list.blankLine(); + list.add(Component.translatable("ftbquests.task.ftbquests.item.shift_click_recipe").withStyle(ChatFormatting.YELLOW, ChatFormatting.UNDERLINE)); + } + } + + @Override + public void onButtonClicked(Button button, boolean canClick) { + if (FTBQuestsClient.isShiftPressed() && FTBQuests.getRecipeModHelper().isRecipeModAvailable()) { + FTBQuests.getRecipeModHelper().showRecipes(fluidStack); + } else { + super.onButtonClicked(button, canClick); + } + } + @Override public void writeData(CompoundTag nbt) { super.writeData(nbt); diff --git a/common/src/main/resources/assets/ftbquests/lang/en_us.json b/common/src/main/resources/assets/ftbquests/lang/en_us.json index ed628f69..7b521467 100644 --- a/common/src/main/resources/assets/ftbquests/lang/en_us.json +++ b/common/src/main/resources/assets/ftbquests/lang/en_us.json @@ -331,6 +331,7 @@ "ftbquests.task.ftbquests.item.view_items": "Click to view valid items", "ftbquests.task.ftbquests.item.valid_for": "Valid items for %s", "ftbquests.task.ftbquests.item.click_recipe": "Click to view recipe(s)", + "ftbquests.task.ftbquests.item.shift_click_recipe": "Shift-Click to view recipe(s)", "ftbquests.task.ftbquests.item.convert_tag": "Convert to '%s' Tag Filter", "ftbquests.task.ftbquests.item.select_tag": "Select an Item Tag", "ftbquests.task.ftbquests.item.only_from_crafting": "Only Detect From Crafting", diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 9dba0897..89fbc395 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -30,5 +30,6 @@ "ftbteams": ">=2001.1.4-build.1" }, "breaks": { + "ftbxmodcompat": "<3.0.4" } } diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index 99f2bff7..126b1441 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -46,3 +46,10 @@ type = "required" versionRange = "[${ftbteamsversion},)" ordering = "AFTER" side = "BOTH" + +[[dependencies.ftbquests]] +modId = "ftbxmodcompat" +type = "optional" +versionRange = ">=3.0.4" +ordering = "BEFORE" +side = "BOTH" From b0f0cd241afb6be156c7db3c7f755a5246847154 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Fri, 7 Jun 2024 15:24:28 +0100 Subject: [PATCH 2/2] build: update ftblib dep version, changelog updated --- CHANGELOG.md | 6 ++++++ gradle.properties | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0d8f128..b5a38505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [2004.2.2] + +### Added +* Fluids in fluid tasks can now be shift-clicked to show recipes for the fluid in JEI or REI + * Added a tooltip to fluid tasks when viewing quests to mention this + # [2004.2.1] ### Added diff --git a/gradle.properties b/gradle.properties index 93d3c375..e8d7146c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,7 +25,7 @@ fabric_api_version=0.96.4+1.20.4 fabric_loader_version=0.15.7 architectury_version=11.1.17 -ftb_library_version=2004.2.2 +ftb_library_version=2004.2.4 ftb_teams_version=2004.1.2 # Optional deps