Re-add grid filtering with "$"
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
- Port to Minecraft 1.14 (raoulvdberge)
|
||||
- Removed the Reader and Writer (raoulvdberge)
|
||||
- Removed covers (raoulvdberge)
|
||||
- Oredict mode for Patterns has been replaced with "Exact mode" (by default on). When exact mode is off, Refined Storage will use equivalent items or fluids from the Minecraft item/fluid tag system (raoulvdberge)
|
||||
- Grid filtering with "$" now does filtering based on item/fluid tag name instead of oredict name (raoulvdberge)
|
||||
- When binding a network item to a network you can now bind to any network block, not only the Controller (raoulvdberge)
|
||||
|
||||
### 1.6.16
|
||||
|
@@ -52,7 +52,7 @@ public final class GridFilterParser {
|
||||
} else if (part.startsWith("#")) {
|
||||
gridFilters.add(new TooltipGridFilter(part.substring(1)));
|
||||
} else if (part.startsWith("$")) {
|
||||
gridFilters.add(new OredictGridFilter(part.substring(1)));
|
||||
gridFilters.add(new TagGridFilter(part.substring(1)));
|
||||
} else {
|
||||
gridFilters.add(new NameGridFilter(part));
|
||||
}
|
||||
|
@@ -1,19 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.screen.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.stack.IGridStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class OredictGridFilter implements Predicate<IGridStack> {
|
||||
private String oreName;
|
||||
|
||||
public OredictGridFilter(String oreName) {
|
||||
this.oreName = oreName.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(IGridStack stack) {
|
||||
return Arrays.stream(stack.getOreIds()).anyMatch(oreName -> oreName.toLowerCase().contains(this.oreName));
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.raoulvdberge.refinedstorage.screen.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.stack.IGridStack;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class TagGridFilter implements Predicate<IGridStack> {
|
||||
private String tagName;
|
||||
|
||||
public TagGridFilter(String tagName) {
|
||||
this.tagName = tagName.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(IGridStack stack) {
|
||||
return stack.getTags().stream().anyMatch(name -> name.toLowerCase().contains(this.tagName));
|
||||
}
|
||||
}
|
@@ -5,12 +5,15 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FluidGridStack implements IGridStack {
|
||||
@@ -22,6 +25,7 @@ public class FluidGridStack implements IGridStack {
|
||||
private StorageTrackerEntry entry;
|
||||
private boolean craftable;
|
||||
|
||||
private Set<String> cachedTags;
|
||||
private String cachedName;
|
||||
private String cachedTooltip;
|
||||
private String cachedModId;
|
||||
@@ -92,9 +96,16 @@ public class FluidGridStack implements IGridStack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOreIds() {
|
||||
return new String[]{};
|
||||
//return new String[]{stack.getFluid().getName()};
|
||||
public Set<String> getTags() {
|
||||
if (cachedTags == null) {
|
||||
cachedTags = new HashSet<>();
|
||||
|
||||
for (ResourceLocation owningTag : FluidTags.getCollection().getOwningTags(stack.getFluid())) {
|
||||
cachedTags.add(owningTag.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
return cachedTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IGridStack {
|
||||
@@ -15,7 +16,7 @@ public interface IGridStack {
|
||||
|
||||
String getModName();
|
||||
|
||||
String[] getOreIds();
|
||||
Set<String> getTags();
|
||||
|
||||
String getTooltip();
|
||||
|
||||
|
@@ -6,13 +6,17 @@ import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -27,6 +31,7 @@ public class ItemGridStack implements IGridStack {
|
||||
@Nullable
|
||||
private StorageTrackerEntry entry;
|
||||
|
||||
private Set<String> cachedTags;
|
||||
private String cachedModId;
|
||||
private String cachedModName;
|
||||
private String cachedTooltip;
|
||||
@@ -105,17 +110,16 @@ public class ItemGridStack implements IGridStack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOreIds() {
|
||||
if (oreIds == null) {
|
||||
if (stack.isEmpty()) {
|
||||
oreIds = new String[]{};
|
||||
} else {
|
||||
oreIds = new String[]{};//TODO OreDict
|
||||
//oreIds = Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName).toArray(String[]::new);
|
||||
public Set<String> getTags() {
|
||||
if (cachedTags == null) {
|
||||
cachedTags = new HashSet<>();
|
||||
|
||||
for (ResourceLocation owningTag : ItemTags.getCollection().getOwningTags(stack.getItem())) {
|
||||
cachedTags.add(owningTag.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
return oreIds;
|
||||
return cachedTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user