desht / ModularRouters

A Forge Mod for item routers with pluggable modules
16 stars 20 forks source link

[Suggestion] Lore Filter #122

Closed jackwright-ual closed 3 years ago

jackwright-ual commented 3 years ago

Just an idea, could be interesting to sort through mob drops with lores

desht commented 3 years ago

Problem with that is lore is a client side thing, and the search logic runs on the server (which can't know what language the client player is using). I agree it would be useful, but not sure it's practical...

jackwright-ual commented 3 years ago

Problem with that is lore is a client side thing, and the search logic runs on the server (which can't know what language the client player is using). I agree it would be useful, but not sure it's practical...

Quick reply - thanks, you could possibly use the lore translate key

desht commented 3 years ago

There's no such thing as a "lore translate key". Any lore (i.e. tooltips) that are added to an item are done client-side by mods. The only translation key is for the item's display name.

jackwright-ual commented 3 years ago

Created my own filter named "NBT Regex Filter"

   @Override
    public boolean matchItem(ItemStack stack, Filter.Flags flags) {
        if (stack.isEmpty()) return false;

        //check tag exists
        if(stack.getTag() == null) {
            return false;
        }

        for (Pattern pat : patterns) {
            String nbtData = stack.getTag().getString();
            if (pat.matcher(nbtData).find()) {
                return true;
            }
        }
        return false;
    }