Re-add grid filtering with "$"
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
- Port to Minecraft 1.14 (raoulvdberge)
|
- Port to Minecraft 1.14 (raoulvdberge)
|
||||||
- Removed the Reader and Writer (raoulvdberge)
|
- Removed the Reader and Writer (raoulvdberge)
|
||||||
- Removed covers (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)
|
- When binding a network item to a network you can now bind to any network block, not only the Controller (raoulvdberge)
|
||||||
|
|
||||||
### 1.6.16
|
### 1.6.16
|
||||||
|
@@ -52,7 +52,7 @@ public final class GridFilterParser {
|
|||||||
} else if (part.startsWith("#")) {
|
} else if (part.startsWith("#")) {
|
||||||
gridFilters.add(new TooltipGridFilter(part.substring(1)));
|
gridFilters.add(new TooltipGridFilter(part.substring(1)));
|
||||||
} else if (part.startsWith("$")) {
|
} else if (part.startsWith("$")) {
|
||||||
gridFilters.add(new OredictGridFilter(part.substring(1)));
|
gridFilters.add(new TagGridFilter(part.substring(1)));
|
||||||
} else {
|
} else {
|
||||||
gridFilters.add(new NameGridFilter(part));
|
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.render.FluidRenderer;
|
||||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.tags.FluidTags;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FluidGridStack implements IGridStack {
|
public class FluidGridStack implements IGridStack {
|
||||||
@@ -22,6 +25,7 @@ public class FluidGridStack implements IGridStack {
|
|||||||
private StorageTrackerEntry entry;
|
private StorageTrackerEntry entry;
|
||||||
private boolean craftable;
|
private boolean craftable;
|
||||||
|
|
||||||
|
private Set<String> cachedTags;
|
||||||
private String cachedName;
|
private String cachedName;
|
||||||
private String cachedTooltip;
|
private String cachedTooltip;
|
||||||
private String cachedModId;
|
private String cachedModId;
|
||||||
@@ -92,9 +96,16 @@ public class FluidGridStack implements IGridStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getOreIds() {
|
public Set<String> getTags() {
|
||||||
return new String[]{};
|
if (cachedTags == null) {
|
||||||
//return new String[]{stack.getFluid().getName()};
|
cachedTags = new HashSet<>();
|
||||||
|
|
||||||
|
for (ResourceLocation owningTag : FluidTags.getCollection().getOwningTags(stack.getFluid())) {
|
||||||
|
cachedTags.add(owningTag.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cachedTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.api.storage.tracker.StorageTrackerEntry;
|
|||||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface IGridStack {
|
public interface IGridStack {
|
||||||
@@ -15,7 +16,7 @@ public interface IGridStack {
|
|||||||
|
|
||||||
String getModName();
|
String getModName();
|
||||||
|
|
||||||
String[] getOreIds();
|
Set<String> getTags();
|
||||||
|
|
||||||
String getTooltip();
|
String getTooltip();
|
||||||
|
|
||||||
|
@@ -6,13 +6,17 @@ import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
|||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fml.ModContainer;
|
import net.minecraftforge.fml.ModContainer;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -27,6 +31,7 @@ public class ItemGridStack implements IGridStack {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private StorageTrackerEntry entry;
|
private StorageTrackerEntry entry;
|
||||||
|
|
||||||
|
private Set<String> cachedTags;
|
||||||
private String cachedModId;
|
private String cachedModId;
|
||||||
private String cachedModName;
|
private String cachedModName;
|
||||||
private String cachedTooltip;
|
private String cachedTooltip;
|
||||||
@@ -105,17 +110,16 @@ public class ItemGridStack implements IGridStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getOreIds() {
|
public Set<String> getTags() {
|
||||||
if (oreIds == null) {
|
if (cachedTags == null) {
|
||||||
if (stack.isEmpty()) {
|
cachedTags = new HashSet<>();
|
||||||
oreIds = new String[]{};
|
|
||||||
} else {
|
for (ResourceLocation owningTag : ItemTags.getCollection().getOwningTags(stack.getItem())) {
|
||||||
oreIds = new String[]{};//TODO OreDict
|
cachedTags.add(owningTag.getPath());
|
||||||
//oreIds = Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName).toArray(String[]::new);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oreIds;
|
return cachedTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user