From 4c5f7b84be4d044d3f27220d9881b0b2e170c933 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 28 Nov 2023 16:06:14 +0000 Subject: [PATCH 01/10] feat: added item filter integration for FTB Quests Now supports Item Filters and FTB Filter System --- common/build.gradle | 2 + .../ftb/mods/ftbxmodcompat/FTBXModCompat.java | 4 ++ .../ftbquests/FTBQuestsSetup.java | 3 + .../ftbquests/filtering/FFSSetup.java | 63 +++++++++++++++++++ .../filtering/ItemFilteringSetup.java | 14 +++++ .../ftbquests/filtering/ItemFiltersSetup.java | 63 +++++++++++++++++++ .../kubejs/CustomFilterItemEventJS.java | 23 +++++++ .../kubejs/FTBQuestsKubeJSEvents.java | 2 + .../ftbquests/kubejs/KubeJSIntegration.java | 6 ++ gradle.properties | 6 +- 10 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java diff --git a/common/build.gradle b/common/build.gradle index 6b3bb56..a150010 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -19,6 +19,7 @@ dependencies { modApi("dev.ftb.mods:ftb-ranks:${rootProject.ftb_ranks_version}") modApi("dev.ftb.mods:ftb-essentials:${rootProject.ftb_essentials_version}") modApi("dev.ftb.mods:ftb-teams:${rootProject.ftb_teams_version}") + modApi("dev.ftb.mods:ftb-filter-system:${rootProject.ftb_filter_system_version}") modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.rei_version}") modCompileOnly("mezz.jei:jei-${rootProject.minecraft_version}-common-api:${rootProject.jei_version}") @@ -26,6 +27,7 @@ dependencies { compileOnly("net.luckperms:api:${rootProject.luckperms_api_version}") modCompileOnlyApi "dev.latvian.mods:kubejs:${rootProject.kubejs_version}" + modCompileOnlyApi "dev.latvian.mods:item-filters:${rootProject.itemfilters_version}" } publishing { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java index 2a43efd..71a3a02 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java @@ -17,8 +17,10 @@ public class FTBXModCompat { public static boolean isFTBChunksLoaded; public static boolean isFTBRanksLoaded; public static boolean isFTBEssentialsLoaded; + public static boolean isFTBFilterSystemLoaded; public static boolean isKubeJSLoaded; + public static boolean isItemFiltersLoaded; public static boolean isGameStagesLoaded; public static boolean isREILoaded; public static boolean isJEILoaded; @@ -44,8 +46,10 @@ private static void detectLoadedMods() { isFTBChunksLoaded = Platform.isModLoaded("ftbchunks"); isFTBRanksLoaded = Platform.isModLoaded("ftbranks"); isFTBEssentialsLoaded = Platform.isModLoaded("ftbessentials"); + isFTBFilterSystemLoaded = Platform.isModLoaded("ftbfiltersystem"); isKubeJSLoaded = Platform.isModLoaded("kubejs"); + isItemFiltersLoaded = Platform.isModLoaded("itemfilters"); isGameStagesLoaded = Platform.isModLoaded("gamestages"); isREILoaded = Platform.isModLoaded("roughlyenoughitems"); isJEILoaded = Platform.isModLoaded("jei"); diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java index 3785de9..095879d 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java @@ -2,6 +2,7 @@ import dev.ftb.mods.ftbquests.FTBQuests; import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.ftb.mods.ftbxmodcompat.ftbquests.filtering.ItemFilteringSetup; import dev.ftb.mods.ftbxmodcompat.ftbquests.jei.helper.JEIRecipeHelper; import dev.ftb.mods.ftbxmodcompat.ftbquests.rei.helper.REIRecipeHelper; @@ -13,5 +14,7 @@ public static void init() { FTBQuests.setRecipeModHelper(new REIRecipeHelper()); } FTBXModCompat.LOGGER.info("[FTB Quests] recipe helper provider is [{}]", FTBQuests.getRecipeModHelper().getHelperName()); + + ItemFilteringSetup.init(); } } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java new file mode 100644 index 0000000..326a98e --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java @@ -0,0 +1,63 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbfiltersystem.api.FTBFilterSystemAPI; +import dev.ftb.mods.ftbfiltersystem.api.FilterException; +import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter; +import dev.ftb.mods.ftbquests.FTBQuests; +import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.api.ItemFilterAdapter; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +class FFSSetup { + public static void init() { + FTBQuestsAPI.api().registerFilterAdapter(new FFSAdapter()); + FTBXModCompat.LOGGER.info("FTB Quests: Enabled FTB Filter System integration"); + } + + private static class FFSAdapter implements ItemFilterAdapter { + @Override + public String getName() { + return "FTB Filter System"; + } + + @Override + public boolean isFilterStack(ItemStack stack) { + return FTBFilterSystemAPI.api().isFilterItem(stack); + } + + @Override + public boolean doesItemMatch(ItemStack filterStack, ItemStack toCheck) { + return FTBFilterSystemAPI.api().doesFilterMatch(filterStack, toCheck); + } + + @Override + public Matcher getMatcher(ItemStack filterStack) { + try { + return new FFSMatcher(filterStack); + } catch (FilterException e) { + return ItemFilterAdapter.NO_MATCH; + } + } + + @Override + public ItemStack makeTagFilterStack(TagKey tag) { + return FTBFilterSystemAPI.api().makeTagFilter(tag); + } + } + + private static class FFSMatcher implements ItemFilterAdapter.Matcher { + private final SmartFilter smartFilter; + + public FFSMatcher(ItemStack filterStack) { + smartFilter = FTBFilterSystemAPI.api().parseFilter(filterStack); + } + + @Override + public boolean test(ItemStack stack) { + return smartFilter.test(stack); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java new file mode 100644 index 0000000..891a2e7 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java @@ -0,0 +1,14 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; + +public class ItemFilteringSetup { + public static void init() { + if (FTBXModCompat.isFTBFilterSystemLoaded) { + FFSSetup.init(); + } + if (FTBXModCompat.isItemFiltersLoaded) { + ItemFiltersSetup.init(); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java new file mode 100644 index 0000000..61818ff --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java @@ -0,0 +1,63 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.api.ItemFilterAdapter; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.latvian.mods.itemfilters.api.IItemFilter; +import dev.latvian.mods.itemfilters.api.IStringValueFilter; +import dev.latvian.mods.itemfilters.api.ItemFiltersAPI; +import dev.latvian.mods.itemfilters.api.ItemFiltersItems; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +class ItemFiltersSetup { + public static void init() { + FTBQuestsAPI.api().registerFilterAdapter(new ItemFiltersAdapter()); + FTBXModCompat.LOGGER.info("FTB Quests: Enabled Item Filters integration"); + } + + private static class ItemFiltersAdapter implements ItemFilterAdapter { + @Override + public String getName() { + return "Item Filters"; + } + + @Override + public boolean isFilterStack(ItemStack stack) { + return ItemFiltersAPI.isFilter(stack); + } + + @Override + public boolean doesItemMatch(ItemStack filterStack, ItemStack toCheck) { + return ItemFiltersAPI.isFilter(filterStack) && ItemFiltersAPI.filter(filterStack, toCheck); + } + + @Override + public Matcher getMatcher(ItemStack filterStack) { + return new IFMatcher(filterStack); + } + + @Override + public ItemStack makeTagFilterStack(TagKey tag) { + ItemStack tagFilter = new ItemStack(ItemFiltersItems.TAG.get()); + ((IStringValueFilter) tagFilter.getItem()).setValue(tagFilter, tag.location().toString()); + return tagFilter; + } + } + + private static class IFMatcher implements ItemFilterAdapter.Matcher { + private final ItemStack filterStack; + private final IItemFilter filter; + + private IFMatcher(ItemStack filterStack) { + this.filterStack = filterStack; + this.filter = ItemFiltersAPI.getFilter(filterStack); + } + + @Override + public boolean test(ItemStack stack) { + return filter != null && filter.filter(filterStack, stack); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java new file mode 100644 index 0000000..4e1f892 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java @@ -0,0 +1,23 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; + +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.world.item.ItemStack; + +import java.util.Collection; + +public class CustomFilterItemEventJS extends EventJS { + private final CustomFilterDisplayItemsEvent event; + + public CustomFilterItemEventJS(CustomFilterDisplayItemsEvent event) { + this.event = event; + } + + public void addStack(ItemStack stack) { + event.add(stack); + } + + public void addStacks(Collection stacks) { + event.add(stacks); + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java index da08388..1057176 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java @@ -11,4 +11,6 @@ public interface FTBQuestsKubeJSEvents { EventHandler CUSTOM_REWARD = EVENT_GROUP.server("customReward", () -> CustomRewardEventJS.class).extra(Extra.STRING).hasResult(); EventHandler OBJECT_COMPLETED = EVENT_GROUP.server("completed", () -> QuestObjectCompletedEventJS.class).extra(Extra.STRING); EventHandler OBJECT_STARTED = EVENT_GROUP.server("started", () -> QuestObjectStartedEventJS.class).extra(Extra.STRING); + + EventHandler CUSTOM_FILTER_ITEM = EVENT_GROUP.client("customFilterItem", () -> CustomFilterItemEventJS.class); } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java index 44f827f..218093f 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java @@ -1,6 +1,7 @@ package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; import dev.ftb.mods.ftbquests.events.CustomRewardEvent; import dev.ftb.mods.ftbquests.events.CustomTaskEvent; import dev.ftb.mods.ftbquests.events.ObjectCompletedEvent; @@ -21,6 +22,7 @@ public void init() { CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward); ObjectCompletedEvent.GENERIC.register(KubeJSIntegration::onCompleted); ObjectStartedEvent.GENERIC.register(KubeJSIntegration::onStarted); + CustomFilterDisplayItemsEvent.ADD_ITEMSTACK.register(KubeJSIntegration::onCustomFilterItem); Stages.added(event -> { if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); @@ -47,6 +49,10 @@ public void registerEvents() { FTBQuestsKubeJSEvents.EVENT_GROUP.register(); } + private static void onCustomFilterItem(CustomFilterDisplayItemsEvent event) { + FTBQuestsKubeJSEvents.CUSTOM_FILTER_ITEM.post(ScriptType.CLIENT, new CustomFilterItemEventJS(event)); + } + public static EventResult onCustomTask(CustomTaskEvent event) { return FTBQuestsKubeJSEvents.CUSTOM_TASK.post(ScriptType.SERVER, event.getTask(), new CustomTaskEventJS(event)).arch(); } diff --git a/gradle.properties b/gradle.properties index 4fff6bd..c7dd600 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.1 enabled_platforms=fabric,forge archives_base_name=ftb-xmod-compat -mod_version=2.0.2 +mod_version=2.1.0 maven_group=dev.ftb.mods curseforge_id=889915 @@ -16,11 +16,13 @@ fabric_api_version=0.83.1+1.20.1 forge_version=1.20.1-47.1.3 ftb_library_version=2001.1.3 -ftb_quests_version=2001.1.3 +ftb_quests_version=2001.3.0-SNAPSHOT ftb_chunks_version=2001.2.0 ftb_ranks_version=2001.1.3 ftb_essentials_version=2001.2.0 ftb_teams_version=2001.1.4 +ftb_filter_system_version=1.0.1-SNAPSHOT +itemfilters_version=2001.1.0-build.55 kubejs_version=2001.6.3-build.18 gamestages_version=15.0.1 From 970fe7d3fdb395901252290b46581671669930be Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 28 Nov 2023 16:06:14 +0000 Subject: [PATCH 02/10] feat: added item filter integration for FTB Quests Now supports Item Filters and FTB Filter System --- common/build.gradle | 2 + .../ftb/mods/ftbxmodcompat/FTBXModCompat.java | 4 ++ .../ftbquests/FTBQuestsSetup.java | 3 + .../ftbquests/filtering/FFSSetup.java | 63 +++++++++++++++++++ .../filtering/ItemFilteringSetup.java | 14 +++++ .../ftbquests/filtering/ItemFiltersSetup.java | 63 +++++++++++++++++++ .../kubejs/CustomFilterItemEventJS.java | 23 +++++++ .../kubejs/FTBQuestsKubeJSEvents.java | 2 + .../ftbquests/kubejs/KubeJSIntegration.java | 6 ++ gradle.properties | 6 +- 10 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java diff --git a/common/build.gradle b/common/build.gradle index 6b3bb56..a150010 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -19,6 +19,7 @@ dependencies { modApi("dev.ftb.mods:ftb-ranks:${rootProject.ftb_ranks_version}") modApi("dev.ftb.mods:ftb-essentials:${rootProject.ftb_essentials_version}") modApi("dev.ftb.mods:ftb-teams:${rootProject.ftb_teams_version}") + modApi("dev.ftb.mods:ftb-filter-system:${rootProject.ftb_filter_system_version}") modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.rei_version}") modCompileOnly("mezz.jei:jei-${rootProject.minecraft_version}-common-api:${rootProject.jei_version}") @@ -26,6 +27,7 @@ dependencies { compileOnly("net.luckperms:api:${rootProject.luckperms_api_version}") modCompileOnlyApi "dev.latvian.mods:kubejs:${rootProject.kubejs_version}" + modCompileOnlyApi "dev.latvian.mods:item-filters:${rootProject.itemfilters_version}" } publishing { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java index 2a43efd..71a3a02 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java @@ -17,8 +17,10 @@ public class FTBXModCompat { public static boolean isFTBChunksLoaded; public static boolean isFTBRanksLoaded; public static boolean isFTBEssentialsLoaded; + public static boolean isFTBFilterSystemLoaded; public static boolean isKubeJSLoaded; + public static boolean isItemFiltersLoaded; public static boolean isGameStagesLoaded; public static boolean isREILoaded; public static boolean isJEILoaded; @@ -44,8 +46,10 @@ private static void detectLoadedMods() { isFTBChunksLoaded = Platform.isModLoaded("ftbchunks"); isFTBRanksLoaded = Platform.isModLoaded("ftbranks"); isFTBEssentialsLoaded = Platform.isModLoaded("ftbessentials"); + isFTBFilterSystemLoaded = Platform.isModLoaded("ftbfiltersystem"); isKubeJSLoaded = Platform.isModLoaded("kubejs"); + isItemFiltersLoaded = Platform.isModLoaded("itemfilters"); isGameStagesLoaded = Platform.isModLoaded("gamestages"); isREILoaded = Platform.isModLoaded("roughlyenoughitems"); isJEILoaded = Platform.isModLoaded("jei"); diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java index 3785de9..095879d 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java @@ -2,6 +2,7 @@ import dev.ftb.mods.ftbquests.FTBQuests; import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.ftb.mods.ftbxmodcompat.ftbquests.filtering.ItemFilteringSetup; import dev.ftb.mods.ftbxmodcompat.ftbquests.jei.helper.JEIRecipeHelper; import dev.ftb.mods.ftbxmodcompat.ftbquests.rei.helper.REIRecipeHelper; @@ -13,5 +14,7 @@ public static void init() { FTBQuests.setRecipeModHelper(new REIRecipeHelper()); } FTBXModCompat.LOGGER.info("[FTB Quests] recipe helper provider is [{}]", FTBQuests.getRecipeModHelper().getHelperName()); + + ItemFilteringSetup.init(); } } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java new file mode 100644 index 0000000..326a98e --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java @@ -0,0 +1,63 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbfiltersystem.api.FTBFilterSystemAPI; +import dev.ftb.mods.ftbfiltersystem.api.FilterException; +import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter; +import dev.ftb.mods.ftbquests.FTBQuests; +import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.api.ItemFilterAdapter; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +class FFSSetup { + public static void init() { + FTBQuestsAPI.api().registerFilterAdapter(new FFSAdapter()); + FTBXModCompat.LOGGER.info("FTB Quests: Enabled FTB Filter System integration"); + } + + private static class FFSAdapter implements ItemFilterAdapter { + @Override + public String getName() { + return "FTB Filter System"; + } + + @Override + public boolean isFilterStack(ItemStack stack) { + return FTBFilterSystemAPI.api().isFilterItem(stack); + } + + @Override + public boolean doesItemMatch(ItemStack filterStack, ItemStack toCheck) { + return FTBFilterSystemAPI.api().doesFilterMatch(filterStack, toCheck); + } + + @Override + public Matcher getMatcher(ItemStack filterStack) { + try { + return new FFSMatcher(filterStack); + } catch (FilterException e) { + return ItemFilterAdapter.NO_MATCH; + } + } + + @Override + public ItemStack makeTagFilterStack(TagKey tag) { + return FTBFilterSystemAPI.api().makeTagFilter(tag); + } + } + + private static class FFSMatcher implements ItemFilterAdapter.Matcher { + private final SmartFilter smartFilter; + + public FFSMatcher(ItemStack filterStack) { + smartFilter = FTBFilterSystemAPI.api().parseFilter(filterStack); + } + + @Override + public boolean test(ItemStack stack) { + return smartFilter.test(stack); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java new file mode 100644 index 0000000..891a2e7 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java @@ -0,0 +1,14 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; + +public class ItemFilteringSetup { + public static void init() { + if (FTBXModCompat.isFTBFilterSystemLoaded) { + FFSSetup.init(); + } + if (FTBXModCompat.isItemFiltersLoaded) { + ItemFiltersSetup.init(); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java new file mode 100644 index 0000000..61818ff --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java @@ -0,0 +1,63 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.api.ItemFilterAdapter; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.latvian.mods.itemfilters.api.IItemFilter; +import dev.latvian.mods.itemfilters.api.IStringValueFilter; +import dev.latvian.mods.itemfilters.api.ItemFiltersAPI; +import dev.latvian.mods.itemfilters.api.ItemFiltersItems; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +class ItemFiltersSetup { + public static void init() { + FTBQuestsAPI.api().registerFilterAdapter(new ItemFiltersAdapter()); + FTBXModCompat.LOGGER.info("FTB Quests: Enabled Item Filters integration"); + } + + private static class ItemFiltersAdapter implements ItemFilterAdapter { + @Override + public String getName() { + return "Item Filters"; + } + + @Override + public boolean isFilterStack(ItemStack stack) { + return ItemFiltersAPI.isFilter(stack); + } + + @Override + public boolean doesItemMatch(ItemStack filterStack, ItemStack toCheck) { + return ItemFiltersAPI.isFilter(filterStack) && ItemFiltersAPI.filter(filterStack, toCheck); + } + + @Override + public Matcher getMatcher(ItemStack filterStack) { + return new IFMatcher(filterStack); + } + + @Override + public ItemStack makeTagFilterStack(TagKey tag) { + ItemStack tagFilter = new ItemStack(ItemFiltersItems.TAG.get()); + ((IStringValueFilter) tagFilter.getItem()).setValue(tagFilter, tag.location().toString()); + return tagFilter; + } + } + + private static class IFMatcher implements ItemFilterAdapter.Matcher { + private final ItemStack filterStack; + private final IItemFilter filter; + + private IFMatcher(ItemStack filterStack) { + this.filterStack = filterStack; + this.filter = ItemFiltersAPI.getFilter(filterStack); + } + + @Override + public boolean test(ItemStack stack) { + return filter != null && filter.filter(filterStack, stack); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java new file mode 100644 index 0000000..4e1f892 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java @@ -0,0 +1,23 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; + +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.world.item.ItemStack; + +import java.util.Collection; + +public class CustomFilterItemEventJS extends EventJS { + private final CustomFilterDisplayItemsEvent event; + + public CustomFilterItemEventJS(CustomFilterDisplayItemsEvent event) { + this.event = event; + } + + public void addStack(ItemStack stack) { + event.add(stack); + } + + public void addStacks(Collection stacks) { + event.add(stacks); + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java index da08388..1057176 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java @@ -11,4 +11,6 @@ public interface FTBQuestsKubeJSEvents { EventHandler CUSTOM_REWARD = EVENT_GROUP.server("customReward", () -> CustomRewardEventJS.class).extra(Extra.STRING).hasResult(); EventHandler OBJECT_COMPLETED = EVENT_GROUP.server("completed", () -> QuestObjectCompletedEventJS.class).extra(Extra.STRING); EventHandler OBJECT_STARTED = EVENT_GROUP.server("started", () -> QuestObjectStartedEventJS.class).extra(Extra.STRING); + + EventHandler CUSTOM_FILTER_ITEM = EVENT_GROUP.client("customFilterItem", () -> CustomFilterItemEventJS.class); } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java index 44f827f..218093f 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java @@ -1,6 +1,7 @@ package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; import dev.ftb.mods.ftbquests.events.CustomRewardEvent; import dev.ftb.mods.ftbquests.events.CustomTaskEvent; import dev.ftb.mods.ftbquests.events.ObjectCompletedEvent; @@ -21,6 +22,7 @@ public void init() { CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward); ObjectCompletedEvent.GENERIC.register(KubeJSIntegration::onCompleted); ObjectStartedEvent.GENERIC.register(KubeJSIntegration::onStarted); + CustomFilterDisplayItemsEvent.ADD_ITEMSTACK.register(KubeJSIntegration::onCustomFilterItem); Stages.added(event -> { if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); @@ -47,6 +49,10 @@ public void registerEvents() { FTBQuestsKubeJSEvents.EVENT_GROUP.register(); } + private static void onCustomFilterItem(CustomFilterDisplayItemsEvent event) { + FTBQuestsKubeJSEvents.CUSTOM_FILTER_ITEM.post(ScriptType.CLIENT, new CustomFilterItemEventJS(event)); + } + public static EventResult onCustomTask(CustomTaskEvent event) { return FTBQuestsKubeJSEvents.CUSTOM_TASK.post(ScriptType.SERVER, event.getTask(), new CustomTaskEventJS(event)).arch(); } diff --git a/gradle.properties b/gradle.properties index ff75c7d..c7dd600 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.1 enabled_platforms=fabric,forge archives_base_name=ftb-xmod-compat -mod_version=2.0.3 +mod_version=2.1.0 maven_group=dev.ftb.mods curseforge_id=889915 @@ -16,11 +16,13 @@ fabric_api_version=0.83.1+1.20.1 forge_version=1.20.1-47.1.3 ftb_library_version=2001.1.3 -ftb_quests_version=2001.1.3 +ftb_quests_version=2001.3.0-SNAPSHOT ftb_chunks_version=2001.2.0 ftb_ranks_version=2001.1.3 ftb_essentials_version=2001.2.0 ftb_teams_version=2001.1.4 +ftb_filter_system_version=1.0.1-SNAPSHOT +itemfilters_version=2001.1.0-build.55 kubejs_version=2001.6.3-build.18 gamestages_version=15.0.1 From 51b52228268c2d3c5bc3ec35e4f838c807c9fa28 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Wed, 29 Nov 2023 08:27:09 +0000 Subject: [PATCH 03/10] chore: update mods.toml & fabric.mod.json --- fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index ac70b31..5246078 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ "ftblibrary": ">=2001.1.3" }, "breaks": { - "ftbquests": "<2001.1.3", + "ftbquests": "<2001.3.0", "ftbchunks": "<2001.2.0", "jei": "<15.2", "kubejs": "<2001.6.3-build.18" diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 7f898d1..cc1403b 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -44,7 +44,7 @@ side = "BOTH" [[dependencies.ftbxmodcompat]] modId = "ftbquests" mandatory = false -versionRange = "[2001.1.3,)" +versionRange = "[2001.3.0,)" ordering = "AFTER" side = "BOTH" @@ -55,13 +55,6 @@ versionRange = "[2001.2.0,)" ordering = "AFTER" side = "BOTH" -[[dependencies.ftbxmodcompat]] -modId = "kubejs" -mandatory = false -versionRange = "[1902.6.1,)" -ordering = "AFTER" -side = "BOTH" - [[dependencies.ftbxmodcompat]] modId = "jei" mandatory = false From 1e58cc760a60983f057074ab9050b4b73b602c70 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Fri, 1 Dec 2023 09:47:53 +0000 Subject: [PATCH 04/10] feat: FFS/KubeJS integration Fire a KJS event for the FFS CustomFilterEvent.MATCH_ITEM event --- .../kubejs/CustomFilterEventJS.java | 22 ++++++++++++++++++ .../ftbfiltersystem/kubejs/FFSEvents.java | 11 +++++++++ .../kubejs/FFSKubeJSPlugin.java | 23 +++++++++++++++++++ .../ftbquests/kubejs/KubeJSIntegration.java | 1 + .../rei/FTBQuestsREIIntegration.java | 6 +++++ common/src/main/resources/kubejs.plugins.txt | 3 ++- gradle.properties | 2 +- 7 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java new file mode 100644 index 0000000..9207253 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java @@ -0,0 +1,22 @@ +package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; + +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.world.item.ItemStack; + +public class CustomFilterEventJS extends EventJS { + private final ItemStack stack; + private final String data; + + public CustomFilterEventJS(ItemStack stack, String data) { + this.stack = stack; + this.data = data; + } + + public ItemStack getStack() { + return stack; + } + + public String getData() { + return data; + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java new file mode 100644 index 0000000..89fcf65 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java @@ -0,0 +1,11 @@ +package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; + +import dev.latvian.mods.kubejs.event.EventGroup; +import dev.latvian.mods.kubejs.event.EventHandler; +import dev.latvian.mods.kubejs.event.Extra; + +public interface FFSEvents { + EventGroup EVENT_GROUP = EventGroup.of("FTBFilterSystemEvents"); + + EventHandler CUSTOM_FILTER = EVENT_GROUP.server("customFilter", () -> CustomFilterEventJS.class).extra(Extra.STRING).hasResult(); +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java new file mode 100644 index 0000000..d7a11f7 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java @@ -0,0 +1,23 @@ +package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; + +import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbfiltersystem.api.event.CustomFilterEvent; +import dev.latvian.mods.kubejs.KubeJSPlugin; +import dev.latvian.mods.kubejs.script.ScriptType; +import net.minecraft.world.item.ItemStack; + +public class FFSKubeJSPlugin extends KubeJSPlugin { + @Override + public void init() { + CustomFilterEvent.MATCH_ITEM.register(FFSKubeJSPlugin::onCustomFilter); + } + + @Override + public void registerEvents() { + FFSEvents.EVENT_GROUP.register(); + } + + private static EventResult onCustomFilter(ItemStack stack, String eventId, String extraData) { + return FFSEvents.CUSTOM_FILTER.post(ScriptType.SERVER, eventId, new CustomFilterEventJS(stack, extraData)).arch(); + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java index 218093f..aabdc44 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java @@ -17,6 +17,7 @@ import net.minecraft.world.entity.player.Player; public class KubeJSIntegration extends KubeJSPlugin { + @Override public void init() { CustomTaskEvent.EVENT.register(KubeJSIntegration::onCustomTask); CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward); diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java index 0aceb38..db76d7c 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java @@ -3,17 +3,23 @@ import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; import dev.ftb.mods.ftbxmodcompat.ftbquests.recipemod_common.WrappedLootCrate; import dev.ftb.mods.ftbxmodcompat.ftbquests.recipemod_common.WrappedQuest; +import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.entry.filtering.base.BasicFilteringRule; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.item.ItemStack; +import java.util.Collection; + public class FTBQuestsREIIntegration implements REIClientPlugin { private static BasicFilteringRule.MarkDirty cratesChanged; diff --git a/common/src/main/resources/kubejs.plugins.txt b/common/src/main/resources/kubejs.plugins.txt index 47d94d3..b5f5441 100644 --- a/common/src/main/resources/kubejs.plugins.txt +++ b/common/src/main/resources/kubejs.plugins.txt @@ -1,3 +1,4 @@ dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs.KubeJSIntegration ftbquests dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs.FTBChunksKubeJSPlugin ftbchunks -dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams \ No newline at end of file +dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams +dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs.FFSKubeJSPlugin ftbfiltersystem \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c7dd600..9088737 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ ftb_chunks_version=2001.2.0 ftb_ranks_version=2001.1.3 ftb_essentials_version=2001.2.0 ftb_teams_version=2001.1.4 -ftb_filter_system_version=1.0.1-SNAPSHOT +ftb_filter_system_version=1.0.2-SNAPSHOT itemfilters_version=2001.1.0-build.55 kubejs_version=2001.6.3-build.18 From 71efe72a2a5adbbda066d723fbcf9232c01732cf Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 28 Nov 2023 16:06:14 +0000 Subject: [PATCH 05/10] feat: added item filter integration for FTB Quests Now supports Item Filters and FTB Filter System --- common/build.gradle | 2 + .../ftb/mods/ftbxmodcompat/FTBXModCompat.java | 4 ++ .../ftbquests/FTBQuestsSetup.java | 3 + .../ftbquests/filtering/FFSSetup.java | 63 +++++++++++++++++++ .../filtering/ItemFilteringSetup.java | 14 +++++ .../ftbquests/filtering/ItemFiltersSetup.java | 63 +++++++++++++++++++ .../kubejs/CustomFilterItemEventJS.java | 23 +++++++ .../kubejs/FTBQuestsKubeJSEvents.java | 2 + .../ftbquests/kubejs/KubeJSIntegration.java | 6 ++ gradle.properties | 6 +- 10 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java diff --git a/common/build.gradle b/common/build.gradle index 6b3bb56..a150010 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -19,6 +19,7 @@ dependencies { modApi("dev.ftb.mods:ftb-ranks:${rootProject.ftb_ranks_version}") modApi("dev.ftb.mods:ftb-essentials:${rootProject.ftb_essentials_version}") modApi("dev.ftb.mods:ftb-teams:${rootProject.ftb_teams_version}") + modApi("dev.ftb.mods:ftb-filter-system:${rootProject.ftb_filter_system_version}") modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.rei_version}") modCompileOnly("mezz.jei:jei-${rootProject.minecraft_version}-common-api:${rootProject.jei_version}") @@ -26,6 +27,7 @@ dependencies { compileOnly("net.luckperms:api:${rootProject.luckperms_api_version}") modCompileOnlyApi "dev.latvian.mods:kubejs:${rootProject.kubejs_version}" + modCompileOnlyApi "dev.latvian.mods:item-filters:${rootProject.itemfilters_version}" } publishing { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java index 41ac2cb..9a47211 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/FTBXModCompat.java @@ -19,8 +19,10 @@ public class FTBXModCompat { public static boolean isFTBChunksLoaded; public static boolean isFTBRanksLoaded; public static boolean isFTBEssentialsLoaded; + public static boolean isFTBFilterSystemLoaded; public static boolean isKubeJSLoaded; + public static boolean isItemFiltersLoaded; public static boolean isGameStagesLoaded; public static boolean isREILoaded; public static boolean isJEILoaded; @@ -48,8 +50,10 @@ private static void detectLoadedMods() { isFTBChunksLoaded = Platform.isModLoaded("ftbchunks"); isFTBRanksLoaded = Platform.isModLoaded("ftbranks"); isFTBEssentialsLoaded = Platform.isModLoaded("ftbessentials"); + isFTBFilterSystemLoaded = Platform.isModLoaded("ftbfiltersystem"); isKubeJSLoaded = Platform.isModLoaded("kubejs"); + isItemFiltersLoaded = Platform.isModLoaded("itemfilters"); isGameStagesLoaded = Platform.isModLoaded("gamestages"); isREILoaded = Platform.isModLoaded("roughlyenoughitems"); isJEILoaded = Platform.isModLoaded("jei"); diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java index 3785de9..095879d 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/FTBQuestsSetup.java @@ -2,6 +2,7 @@ import dev.ftb.mods.ftbquests.FTBQuests; import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.ftb.mods.ftbxmodcompat.ftbquests.filtering.ItemFilteringSetup; import dev.ftb.mods.ftbxmodcompat.ftbquests.jei.helper.JEIRecipeHelper; import dev.ftb.mods.ftbxmodcompat.ftbquests.rei.helper.REIRecipeHelper; @@ -13,5 +14,7 @@ public static void init() { FTBQuests.setRecipeModHelper(new REIRecipeHelper()); } FTBXModCompat.LOGGER.info("[FTB Quests] recipe helper provider is [{}]", FTBQuests.getRecipeModHelper().getHelperName()); + + ItemFilteringSetup.init(); } } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java new file mode 100644 index 0000000..326a98e --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java @@ -0,0 +1,63 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbfiltersystem.api.FTBFilterSystemAPI; +import dev.ftb.mods.ftbfiltersystem.api.FilterException; +import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter; +import dev.ftb.mods.ftbquests.FTBQuests; +import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.api.ItemFilterAdapter; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +class FFSSetup { + public static void init() { + FTBQuestsAPI.api().registerFilterAdapter(new FFSAdapter()); + FTBXModCompat.LOGGER.info("FTB Quests: Enabled FTB Filter System integration"); + } + + private static class FFSAdapter implements ItemFilterAdapter { + @Override + public String getName() { + return "FTB Filter System"; + } + + @Override + public boolean isFilterStack(ItemStack stack) { + return FTBFilterSystemAPI.api().isFilterItem(stack); + } + + @Override + public boolean doesItemMatch(ItemStack filterStack, ItemStack toCheck) { + return FTBFilterSystemAPI.api().doesFilterMatch(filterStack, toCheck); + } + + @Override + public Matcher getMatcher(ItemStack filterStack) { + try { + return new FFSMatcher(filterStack); + } catch (FilterException e) { + return ItemFilterAdapter.NO_MATCH; + } + } + + @Override + public ItemStack makeTagFilterStack(TagKey tag) { + return FTBFilterSystemAPI.api().makeTagFilter(tag); + } + } + + private static class FFSMatcher implements ItemFilterAdapter.Matcher { + private final SmartFilter smartFilter; + + public FFSMatcher(ItemStack filterStack) { + smartFilter = FTBFilterSystemAPI.api().parseFilter(filterStack); + } + + @Override + public boolean test(ItemStack stack) { + return smartFilter.test(stack); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java new file mode 100644 index 0000000..891a2e7 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFilteringSetup.java @@ -0,0 +1,14 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; + +public class ItemFilteringSetup { + public static void init() { + if (FTBXModCompat.isFTBFilterSystemLoaded) { + FFSSetup.init(); + } + if (FTBXModCompat.isItemFiltersLoaded) { + ItemFiltersSetup.init(); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java new file mode 100644 index 0000000..61818ff --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java @@ -0,0 +1,63 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.filtering; + +import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; +import dev.ftb.mods.ftbquests.api.ItemFilterAdapter; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.latvian.mods.itemfilters.api.IItemFilter; +import dev.latvian.mods.itemfilters.api.IStringValueFilter; +import dev.latvian.mods.itemfilters.api.ItemFiltersAPI; +import dev.latvian.mods.itemfilters.api.ItemFiltersItems; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +class ItemFiltersSetup { + public static void init() { + FTBQuestsAPI.api().registerFilterAdapter(new ItemFiltersAdapter()); + FTBXModCompat.LOGGER.info("FTB Quests: Enabled Item Filters integration"); + } + + private static class ItemFiltersAdapter implements ItemFilterAdapter { + @Override + public String getName() { + return "Item Filters"; + } + + @Override + public boolean isFilterStack(ItemStack stack) { + return ItemFiltersAPI.isFilter(stack); + } + + @Override + public boolean doesItemMatch(ItemStack filterStack, ItemStack toCheck) { + return ItemFiltersAPI.isFilter(filterStack) && ItemFiltersAPI.filter(filterStack, toCheck); + } + + @Override + public Matcher getMatcher(ItemStack filterStack) { + return new IFMatcher(filterStack); + } + + @Override + public ItemStack makeTagFilterStack(TagKey tag) { + ItemStack tagFilter = new ItemStack(ItemFiltersItems.TAG.get()); + ((IStringValueFilter) tagFilter.getItem()).setValue(tagFilter, tag.location().toString()); + return tagFilter; + } + } + + private static class IFMatcher implements ItemFilterAdapter.Matcher { + private final ItemStack filterStack; + private final IItemFilter filter; + + private IFMatcher(ItemStack filterStack) { + this.filterStack = filterStack; + this.filter = ItemFiltersAPI.getFilter(filterStack); + } + + @Override + public boolean test(ItemStack stack) { + return filter != null && filter.filter(filterStack, stack); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java new file mode 100644 index 0000000..4e1f892 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java @@ -0,0 +1,23 @@ +package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; + +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.world.item.ItemStack; + +import java.util.Collection; + +public class CustomFilterItemEventJS extends EventJS { + private final CustomFilterDisplayItemsEvent event; + + public CustomFilterItemEventJS(CustomFilterDisplayItemsEvent event) { + this.event = event; + } + + public void addStack(ItemStack stack) { + event.add(stack); + } + + public void addStacks(Collection stacks) { + event.add(stacks); + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java index da08388..1057176 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java @@ -11,4 +11,6 @@ public interface FTBQuestsKubeJSEvents { EventHandler CUSTOM_REWARD = EVENT_GROUP.server("customReward", () -> CustomRewardEventJS.class).extra(Extra.STRING).hasResult(); EventHandler OBJECT_COMPLETED = EVENT_GROUP.server("completed", () -> QuestObjectCompletedEventJS.class).extra(Extra.STRING); EventHandler OBJECT_STARTED = EVENT_GROUP.server("started", () -> QuestObjectStartedEventJS.class).extra(Extra.STRING); + + EventHandler CUSTOM_FILTER_ITEM = EVENT_GROUP.client("customFilterItem", () -> CustomFilterItemEventJS.class); } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java index 44f827f..218093f 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java @@ -1,6 +1,7 @@ package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; import dev.ftb.mods.ftbquests.events.CustomRewardEvent; import dev.ftb.mods.ftbquests.events.CustomTaskEvent; import dev.ftb.mods.ftbquests.events.ObjectCompletedEvent; @@ -21,6 +22,7 @@ public void init() { CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward); ObjectCompletedEvent.GENERIC.register(KubeJSIntegration::onCompleted); ObjectStartedEvent.GENERIC.register(KubeJSIntegration::onStarted); + CustomFilterDisplayItemsEvent.ADD_ITEMSTACK.register(KubeJSIntegration::onCustomFilterItem); Stages.added(event -> { if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); @@ -47,6 +49,10 @@ public void registerEvents() { FTBQuestsKubeJSEvents.EVENT_GROUP.register(); } + private static void onCustomFilterItem(CustomFilterDisplayItemsEvent event) { + FTBQuestsKubeJSEvents.CUSTOM_FILTER_ITEM.post(ScriptType.CLIENT, new CustomFilterItemEventJS(event)); + } + public static EventResult onCustomTask(CustomTaskEvent event) { return FTBQuestsKubeJSEvents.CUSTOM_TASK.post(ScriptType.SERVER, event.getTask(), new CustomTaskEventJS(event)).arch(); } diff --git a/gradle.properties b/gradle.properties index c9993c1..c7dd600 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.1 enabled_platforms=fabric,forge archives_base_name=ftb-xmod-compat -mod_version=2.0.4 +mod_version=2.1.0 maven_group=dev.ftb.mods curseforge_id=889915 @@ -16,11 +16,13 @@ fabric_api_version=0.83.1+1.20.1 forge_version=1.20.1-47.1.3 ftb_library_version=2001.1.3 -ftb_quests_version=2001.1.3 +ftb_quests_version=2001.3.0-SNAPSHOT ftb_chunks_version=2001.2.0 ftb_ranks_version=2001.1.3 ftb_essentials_version=2001.2.0 ftb_teams_version=2001.1.4 +ftb_filter_system_version=1.0.1-SNAPSHOT +itemfilters_version=2001.1.0-build.55 kubejs_version=2001.6.3-build.18 gamestages_version=15.0.1 From 1c1fefb4c0fb97276140acce1f471975b49f4db7 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Wed, 29 Nov 2023 08:27:09 +0000 Subject: [PATCH 06/10] chore: update mods.toml & fabric.mod.json --- fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index ac70b31..5246078 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ "ftblibrary": ">=2001.1.3" }, "breaks": { - "ftbquests": "<2001.1.3", + "ftbquests": "<2001.3.0", "ftbchunks": "<2001.2.0", "jei": "<15.2", "kubejs": "<2001.6.3-build.18" diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 7f898d1..cc1403b 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -44,7 +44,7 @@ side = "BOTH" [[dependencies.ftbxmodcompat]] modId = "ftbquests" mandatory = false -versionRange = "[2001.1.3,)" +versionRange = "[2001.3.0,)" ordering = "AFTER" side = "BOTH" @@ -55,13 +55,6 @@ versionRange = "[2001.2.0,)" ordering = "AFTER" side = "BOTH" -[[dependencies.ftbxmodcompat]] -modId = "kubejs" -mandatory = false -versionRange = "[1902.6.1,)" -ordering = "AFTER" -side = "BOTH" - [[dependencies.ftbxmodcompat]] modId = "jei" mandatory = false From f3ed785c05396ea2d43d5d1ff610e5b9accdd93e Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Fri, 1 Dec 2023 09:47:53 +0000 Subject: [PATCH 07/10] feat: FFS/KubeJS integration Fire a KJS event for the FFS CustomFilterEvent.MATCH_ITEM event --- .../kubejs/CustomFilterEventJS.java | 22 ++++++++++++++++++ .../ftbfiltersystem/kubejs/FFSEvents.java | 11 +++++++++ .../kubejs/FFSKubeJSPlugin.java | 23 +++++++++++++++++++ .../ftbquests/kubejs/KubeJSIntegration.java | 1 + .../rei/FTBQuestsREIIntegration.java | 6 +++++ common/src/main/resources/kubejs.plugins.txt | 3 ++- gradle.properties | 2 +- 7 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java create mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java new file mode 100644 index 0000000..9207253 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java @@ -0,0 +1,22 @@ +package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; + +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.world.item.ItemStack; + +public class CustomFilterEventJS extends EventJS { + private final ItemStack stack; + private final String data; + + public CustomFilterEventJS(ItemStack stack, String data) { + this.stack = stack; + this.data = data; + } + + public ItemStack getStack() { + return stack; + } + + public String getData() { + return data; + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java new file mode 100644 index 0000000..89fcf65 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java @@ -0,0 +1,11 @@ +package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; + +import dev.latvian.mods.kubejs.event.EventGroup; +import dev.latvian.mods.kubejs.event.EventHandler; +import dev.latvian.mods.kubejs.event.Extra; + +public interface FFSEvents { + EventGroup EVENT_GROUP = EventGroup.of("FTBFilterSystemEvents"); + + EventHandler CUSTOM_FILTER = EVENT_GROUP.server("customFilter", () -> CustomFilterEventJS.class).extra(Extra.STRING).hasResult(); +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java new file mode 100644 index 0000000..d7a11f7 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java @@ -0,0 +1,23 @@ +package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; + +import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbfiltersystem.api.event.CustomFilterEvent; +import dev.latvian.mods.kubejs.KubeJSPlugin; +import dev.latvian.mods.kubejs.script.ScriptType; +import net.minecraft.world.item.ItemStack; + +public class FFSKubeJSPlugin extends KubeJSPlugin { + @Override + public void init() { + CustomFilterEvent.MATCH_ITEM.register(FFSKubeJSPlugin::onCustomFilter); + } + + @Override + public void registerEvents() { + FFSEvents.EVENT_GROUP.register(); + } + + private static EventResult onCustomFilter(ItemStack stack, String eventId, String extraData) { + return FFSEvents.CUSTOM_FILTER.post(ScriptType.SERVER, eventId, new CustomFilterEventJS(stack, extraData)).arch(); + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java index 218093f..aabdc44 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java @@ -17,6 +17,7 @@ import net.minecraft.world.entity.player.Player; public class KubeJSIntegration extends KubeJSPlugin { + @Override public void init() { CustomTaskEvent.EVENT.register(KubeJSIntegration::onCustomTask); CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward); diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java index 0aceb38..db76d7c 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/rei/FTBQuestsREIIntegration.java @@ -3,17 +3,23 @@ import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; import dev.ftb.mods.ftbxmodcompat.ftbquests.recipemod_common.WrappedLootCrate; import dev.ftb.mods.ftbxmodcompat.ftbquests.recipemod_common.WrappedQuest; +import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.entry.filtering.base.BasicFilteringRule; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.item.ItemStack; +import java.util.Collection; + public class FTBQuestsREIIntegration implements REIClientPlugin { private static BasicFilteringRule.MarkDirty cratesChanged; diff --git a/common/src/main/resources/kubejs.plugins.txt b/common/src/main/resources/kubejs.plugins.txt index 47d94d3..b5f5441 100644 --- a/common/src/main/resources/kubejs.plugins.txt +++ b/common/src/main/resources/kubejs.plugins.txt @@ -1,3 +1,4 @@ dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs.KubeJSIntegration ftbquests dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs.FTBChunksKubeJSPlugin ftbchunks -dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams \ No newline at end of file +dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams +dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs.FFSKubeJSPlugin ftbfiltersystem \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c7dd600..9088737 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ ftb_chunks_version=2001.2.0 ftb_ranks_version=2001.1.3 ftb_essentials_version=2001.2.0 ftb_teams_version=2001.1.4 -ftb_filter_system_version=1.0.1-SNAPSHOT +ftb_filter_system_version=1.0.2-SNAPSHOT itemfilters_version=2001.1.0-build.55 kubejs_version=2001.6.3-build.18 From e0d29b12fe890810fe55b1b81865a07e54de103c Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 4 Dec 2023 16:04:56 +0000 Subject: [PATCH 08/10] chore: just made a few log message more consistent in formatting --- .../ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java | 2 +- .../ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java | 2 +- .../mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java index 326a98e..437b83c 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/FFSSetup.java @@ -14,7 +14,7 @@ class FFSSetup { public static void init() { FTBQuestsAPI.api().registerFilterAdapter(new FFSAdapter()); - FTBXModCompat.LOGGER.info("FTB Quests: Enabled FTB Filter System integration"); + FTBXModCompat.LOGGER.info("[FTB Quests] Enabled FTB Filter System integration"); } private static class FFSAdapter implements ItemFilterAdapter { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java index 61818ff..a4d7c90 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/filtering/ItemFiltersSetup.java @@ -14,7 +14,7 @@ class ItemFiltersSetup { public static void init() { FTBQuestsAPI.api().registerFilterAdapter(new ItemFiltersAdapter()); - FTBXModCompat.LOGGER.info("FTB Quests: Enabled Item Filters integration"); + FTBXModCompat.LOGGER.info("[FTB Quests] Enabled Item Filters integration"); } private static class ItemFiltersAdapter implements ItemFilterAdapter { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java index aabdc44..1d0c267 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java @@ -32,7 +32,7 @@ public void init() { if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); }); - FTBXModCompat.LOGGER.info("FTB Quests: Enabled KubeJS integration"); + FTBXModCompat.LOGGER.info("[FTB Quests] Enabled KubeJS integration"); } @Override From 9ed454f088025f0a80e76925896788a85d10eed2 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 5 Dec 2023 16:07:06 +0000 Subject: [PATCH 09/10] chore: update readme & changelog, stop using snapshot builds of ftbq/ffs --- CHANGELOG.md | 8 ++++++++ README.md | 8 ++++++++ gradle.properties | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19d4712..fdd98d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ 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). +## [2.1.0] + +### Added + +* Added FTB Quests integration for Item Filters and FTB Filter System mods + * FTB Quests 2001.3.0 now required; it now supports external filtering mods via an abstraction layer + * Item Filter is no longer a hard dependency for FTB Quests; it's supported along with FTB Filter System by FTB XMod Compat + ## [2.0.4] ### Fixed diff --git a/README.md b/README.md index 50fd227..8a5e328 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,18 @@ If either REI or JEI is present: * FTB Quests will use that mod for displaying the items obtained from any configured loot crates (rewards from the reward table which have loot crates enabled) * FTB Quests will use that mod to show the recipes for items in item tasks (as viewed in the quest display panel) +### Item Filters and FTB Filter System + +As of version 2.1.0, FTB XMod Compat provides FTB Quests integration for the Item Filters and FTB Filter System mods. Item Filters was previously a hard dependency for FTB Quests, but is now an optional dependency, along with the new FTB Filter System mod. Using FTB Filter System will be the recommended path for future modpacks. + +With KubeJS installed, FTB Filter System's "Custom" filter fires a KubeJS event allowing pack developers to match items using an external KJS script. See https://github.com/FTBTeam/FTB-Filter-System/blob/main/README.md for more information on this, including examples. + ### Fallbacks If neither KubeJS nor Game Stages is loaded, FTB Quests will use an inbuilt stages implementation based on string "tags" which can be added to players. This works but is extremely limited in functionality (either a player has a given tag, or doesn't). +If neither Item Filters nor FTB Filter System is load, only simple item matching will be available for FTB Quests item tasks. + ## FTB Chunks The following cross-mod integrations are added to FTB Chunks 1902.4.0+, if present: diff --git a/gradle.properties b/gradle.properties index 9088737..3c69ae8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,12 +16,12 @@ fabric_api_version=0.83.1+1.20.1 forge_version=1.20.1-47.1.3 ftb_library_version=2001.1.3 -ftb_quests_version=2001.3.0-SNAPSHOT +ftb_quests_version=2001.3.0 ftb_chunks_version=2001.2.0 ftb_ranks_version=2001.1.3 ftb_essentials_version=2001.2.0 ftb_teams_version=2001.1.4 -ftb_filter_system_version=1.0.2-SNAPSHOT +ftb_filter_system_version=1.0.2 itemfilters_version=2001.1.0-build.55 kubejs_version=2001.6.3-build.18 From e0e92d54860672e2b3adbb5a70c3633894bda687 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 5 Dec 2023 16:07:38 +0000 Subject: [PATCH 10/10] ci: use "1.**" instead of "1.*" --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d4d795..ec67c57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Java CI - Build on Push on: push: - branches: [ main, dev, "1.*" ] + branches: [ main, dev, "1.**" ] workflow_dispatch: inputs: skip_maven_publish: