Skip to content

Commit

Permalink
fix: several fixes, version -> 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
desht committed Nov 27, 2023
1 parent ee01fb7 commit 4344416
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 18 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ allprojects {
apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/git-md-changelog.gradle"

base {
archivesName = rootProject.archives_base_name
archivesName = project.archives_base_name
}

version = rootProject.mod_version
group = rootProject.maven_group
version = project.mod_version
group = project.maven_group
archivesBaseName = project.archives_base_name

// needs to be done AFTER version is set
apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/publishing.gradle"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package dev.ftb.mods.ftbfiltersystem;

import dev.ftb.mods.ftbfiltersystem.api.*;
import dev.ftb.mods.ftbfiltersystem.api.filter.AbstractCompoundFilter;
import dev.ftb.mods.ftbfiltersystem.api.FTBFilterSystemAPI;
import dev.ftb.mods.ftbfiltersystem.api.FTBFilterSystemRegistry;
import dev.ftb.mods.ftbfiltersystem.api.FilterException;
import dev.ftb.mods.ftbfiltersystem.api.filter.DumpedFilter;
import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter;
import dev.ftb.mods.ftbfiltersystem.registry.item.SmartFilterItem;
import dev.ftb.mods.ftbfiltersystem.filter.ItemTagFilter;
import dev.ftb.mods.ftbfiltersystem.registry.FilterRegistry;
import dev.ftb.mods.ftbfiltersystem.registry.ModItems;
import dev.ftb.mods.ftbfiltersystem.registry.item.SmartFilterItem;
import dev.ftb.mods.ftbfiltersystem.util.FilterParser;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

import java.util.ArrayList;
Expand All @@ -29,8 +34,12 @@ public boolean isFilterItem(ItemStack stack) {

@Override
public boolean doesFilterMatch(ItemStack filterStack, ItemStack toMatch) {
return isFilterItem(filterStack)
&& FilterParser.parse(SmartFilterItem.getFilterString(filterStack)).test(toMatch);
try {
return isFilterItem(filterStack)
&& FilterParser.parse(SmartFilterItem.getFilterString(filterStack)).test(toMatch);
} catch (FilterException e) {
return false;
}
}

@Override
Expand All @@ -48,11 +57,23 @@ public SmartFilter parseFilter(String filterStr) throws FilterException {
return FilterParser.parse(filterStr);
}

@Override
public SmartFilter parseFilter(ItemStack filterStack) throws FilterException {
return parseFilter(SmartFilterItem.getFilterString(filterStack));
}

@Override
public List<SmartFilter> parseFilterList(SmartFilter.Compound parent, String filterStr) throws FilterException {
return FilterParser.parseFilterList(parent, filterStr);
}

@Override
public ItemStack makeTagFilter(TagKey<Item> tagKey) {
ItemStack res = new ItemStack(ModItems.SMART_FILTER.get());
SmartFilterItem.setFilter(res, ItemTagFilter.ID + "(" + tagKey.location() + ")");
return res;
}

private List<DumpedFilter> dump(SmartFilter filter, int indent, List<DumpedFilter> res) {
res.add(new DumpedFilter(indent, filter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import dev.ftb.mods.ftbfiltersystem.api.filter.DumpedFilter;
import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -103,17 +105,19 @@ public interface API {
FTBFilterSystemRegistry getRegistry();

/**
* Check if the given itemstack is an FTB Filter System filter
* Check if the given itemstack is an FTB Filter System filter.
*
* @param stack the stack to check
* @return true if it's a filter, false otherwise
*/
boolean isFilterItem(ItemStack stack);

/**
* Check if the given filter stack matches the given item stack
* .
* @param filterStack the filter stack, which should be a FTB Filter System filter
* @param toMatch the item stack to test
* @return true if the filter stack matches, false otherwise (including if the filter stack isn't a filter)
* @return true if the filter stack matches, false otherwise (the filter stack isn't a filter, or the filter NBT is bad)
*/
boolean doesFilterMatch(ItemStack filterStack, ItemStack toMatch);

Expand Down Expand Up @@ -145,6 +149,16 @@ public interface API {
*/
SmartFilter parseFilter(String filterStr) throws FilterException;

/**
* Create a new filter, parsed from the given serialized string. Such strings are produced by calling
* the overridden {@code toString()} on any {@link SmartFilter} implementation.
*
* @param filterStack the itemstack, which should be a valid filter item
* @return a new filter
* @throws FilterException if the item stack doesn't have valid filter NBT, or there's a problem parsing the data
*/
SmartFilter parseFilter(ItemStack filterStack) throws FilterException;

/**
* Create a list of new filters, parsed from the given serialized string. Such strings are produced by calling
* the overridden {@code toString()} method on any {@link SmartFilter} implementation; multiples of such strings
Expand All @@ -156,5 +170,13 @@ public interface API {
* @throws FilterException if there's a problem parsing the data
*/
List<SmartFilter> parseFilterList(@NotNull SmartFilter.Compound parent, String filterStr) throws FilterException;

/**
* Create a simple filter which just filters on a specific item tag.
*
* @param tagKey the item tag to filter on
* @return the new filter itemstack
*/
ItemStack makeTagFilter(TagKey<Item> tagKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.ftb.mods.ftbfiltersystem.api.client.Textures;
import dev.ftb.mods.ftbfiltersystem.api.client.gui.AbstractFilterScreen;
import dev.ftb.mods.ftbfiltersystem.api.filter.AbstractCompoundFilter;
import dev.ftb.mods.ftbfiltersystem.api.filter.AbstractSmartFilter;
import dev.ftb.mods.ftbfiltersystem.api.filter.DumpedFilter;
import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter;
import dev.ftb.mods.ftbfiltersystem.client.FTBFilterSystemClient;
Expand Down Expand Up @@ -261,10 +260,14 @@ public boolean keyPressed(int keyCode, int scanCode, int modifier) {
if (getSelectionPanel().isVisible()) {
getSelectionPanel().setVisible(false);
return true;
} else if (titleEditBox.canConsumeInput() && keyCode == InputConstants.KEY_ESCAPE) {
titleEditBox.setValue(newTitle == null ? title.getString() : newTitle.getString());
showingTitleEdit = false;
return true;
} else if (titleEditBox.canConsumeInput()) {
if (keyCode == InputConstants.KEY_ESCAPE) {
titleEditBox.setValue(newTitle == null ? title.getString() : newTitle.getString());
showingTitleEdit = false;
return true;
} else {
return titleEditBox.keyPressed(keyCode, scanCode, modifier);
}
} else {
closeWithConfirmation();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
"ftbfiltersystem.gui.compound": "Compound Filters",
"ftbfiltersystem.gui.basic": "Basic Filters",
"filter.ftbfiltersystem.and.name": "All Of",
"filter.ftbfiltersystem.and.tooltip": "Compound filter: this filter matches if ALL of its child filters match.",
"filter.ftbfiltersystem.or.name": "Any Of",
"filter.ftbfiltersystem.or.tooltip": "Compound filter: this filter matches if ANY of its child filters match.",
"filter.ftbfiltersystem.not.name": "Not",
"filter.ftbfiltersystem.not.tooltip": "Compound filter: this filter matches if its child filter does NOT match. At most child can be added.",
"filter.ftbfiltersystem.only_one.name": "Only One Of",
"filter.ftbfiltersystem.only_one.tooltip": "Compound filter: this filter matches if exactly ONE of its child filters matches.",
"filter.ftbfiltersystem.block.name": "Is Block",
"filter.ftbfiltersystem.block.tooltip": "Simple filter which matches if the item is a placeable block.",
"filter.ftbfiltersystem.durability.name": "Durability",
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.20.1
enabled_platforms=fabric,forge

archives_base_name=ftbfiltersystem
mod_version=1.0.0
maven_group=dev.ftb.mods.ftbfiltersystem
archives_base_name=ftb-filter-system
mod_version=1.0.1
maven_group=dev.ftb.mods

architectury_version=9.1.12

Expand Down

0 comments on commit 4344416

Please sign in to comment.