diff --git a/src/main/java/refinedstorage/container/ContainerGrid.java b/src/main/java/refinedstorage/container/ContainerGrid.java index 775e32ddb..308649927 100755 --- a/src/main/java/refinedstorage/container/ContainerGrid.java +++ b/src/main/java/refinedstorage/container/ContainerGrid.java @@ -59,6 +59,10 @@ public class ContainerGrid extends ContainerBase { addSlotToContainer(new SlotItemHandler(((TileGrid) grid).getPatterns(), 0, 152, 96)); addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, 132)); } + + if (!(grid instanceof WirelessGrid)) { + addSlotToContainer(new SlotItemHandler(((TileGrid) grid).getFilter(), 0, 204, 6)); + } } public IGrid getGrid() { diff --git a/src/main/java/refinedstorage/gui/grid/GuiGrid.java b/src/main/java/refinedstorage/gui/grid/GuiGrid.java index b316fa7d5..4a268be27 100755 --- a/src/main/java/refinedstorage/gui/grid/GuiGrid.java +++ b/src/main/java/refinedstorage/gui/grid/GuiGrid.java @@ -13,6 +13,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import org.apache.commons.lang3.StringUtils; import refinedstorage.RefinedStorage; import refinedstorage.api.network.GridExtractFlags; +import refinedstorage.api.storage.CompareUtils; import refinedstorage.block.EnumGridType; import refinedstorage.container.ContainerGrid; import refinedstorage.gui.GuiBase; @@ -45,7 +46,7 @@ public class GuiGrid extends GuiBase { private int slotNumber; public GuiGrid(ContainerGrid container, IGrid grid) { - super(container, 193, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208); + super(container, !(grid instanceof WirelessGrid) ? 227 : 193, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208); setScrollbar(new Scrollbar(174, 20, 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 70 : 88)); getScrollbar().setCanScroll(false); @@ -99,6 +100,26 @@ public class GuiGrid extends GuiBase { while (t.hasNext()) { ClientStack stack = t.next(); + if (!(grid instanceof WirelessGrid)) { + List filteredItems = ((TileGrid) grid).getFilteredItems(); + + boolean found = filteredItems.isEmpty(); + + for (ItemStack item : filteredItems) { + if (CompareUtils.compareStackNoQuantity(stack.getStack(), item)) { + found = true; + + break; + } + } + + if (!found) { + t.remove(); + + continue; + } + } + if (grid.getViewType() == TileGrid.VIEW_TYPE_NON_CRAFTABLES && stack.isCraftable()) { t.remove(); @@ -222,7 +243,7 @@ public class GuiGrid extends GuiBase { ty = 2; } - drawTexture(x + 152, y + 114, 195, ty * 16, 16, 16); + drawTexture(x + 152, y + 114, 240, ty * 16, 16, 16); } searchField.drawTextBox(); diff --git a/src/main/java/refinedstorage/tile/grid/TileGrid.java b/src/main/java/refinedstorage/tile/grid/TileGrid.java index af8c33670..e15f19591 100755 --- a/src/main/java/refinedstorage/tile/grid/TileGrid.java +++ b/src/main/java/refinedstorage/tile/grid/TileGrid.java @@ -23,6 +23,7 @@ import refinedstorage.inventory.BasicItemHandler; import refinedstorage.inventory.BasicItemValidator; import refinedstorage.item.ItemPattern; import refinedstorage.network.MessageGridSettingsUpdate; +import refinedstorage.tile.TileBase; import refinedstorage.tile.TileNode; import refinedstorage.tile.config.IRedstoneModeConfig; @@ -65,6 +66,31 @@ public class TileGrid extends TileNode implements IGrid { private InventoryCraftResult result = new InventoryCraftResult(); private BasicItemHandler patterns = new BasicItemHandler(2, this, new BasicItemValidator(RefinedStorageItems.PATTERN)); + private BasicItemHandler filter = new BasicItemHandler(1, this, new BasicItemValidator(RefinedStorageItems.GRID_FILTER)) { + @Override + protected void onContentsChanged(int slot) { + super.onContentsChanged(slot); + + filteredItems.clear(); + + ItemStack stack = getStackInSlot(slot); + + if (stack != null && stack.hasTagCompound()) { + BasicItemHandler items = new BasicItemHandler(9 * 3); + + TileBase.readItems(items, 0, stack.getTagCompound()); + + for (int i = 0; i < items.getSlots(); ++i) { + ItemStack item = items.getStackInSlot(i); + + if (item != null) { + filteredItems.add(item); + } + } + } + } + }; + private List filteredItems = new ArrayList(); private EnumGridType type; @@ -127,6 +153,14 @@ public class TileGrid extends TileNode implements IGrid { return patterns; } + public BasicItemHandler getFilter() { + return filter; + } + + public List getFilteredItems() { + return filteredItems; + } + public void onCraftingMatrixChanged() { markDirty(); @@ -334,6 +368,7 @@ public class TileGrid extends TileNode implements IGrid { readItemsLegacy(matrix, 0, tag); readItems(patterns, 1, tag); + readItems(filter, 2, tag); if (tag.hasKey(NBT_VIEW_TYPE)) { viewType = tag.getInteger(NBT_VIEW_TYPE); @@ -358,6 +393,7 @@ public class TileGrid extends TileNode implements IGrid { writeItemsLegacy(matrix, 0, tag); writeItems(patterns, 1, tag); + writeItems(filter, 2, tag); tag.setInteger(NBT_VIEW_TYPE, viewType); tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection); diff --git a/src/main/resources/assets/refinedstorage/textures/gui/crafting_grid.png b/src/main/resources/assets/refinedstorage/textures/gui/crafting_grid.png index 8a4578e0a..3541a86c6 100755 Binary files a/src/main/resources/assets/refinedstorage/textures/gui/crafting_grid.png and b/src/main/resources/assets/refinedstorage/textures/gui/crafting_grid.png differ diff --git a/src/main/resources/assets/refinedstorage/textures/gui/grid.png b/src/main/resources/assets/refinedstorage/textures/gui/grid.png index 2d2cb3a5f..fb1d4edf2 100644 Binary files a/src/main/resources/assets/refinedstorage/textures/gui/grid.png and b/src/main/resources/assets/refinedstorage/textures/gui/grid.png differ diff --git a/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png b/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png index 0c495db60..12de1c6bc 100755 Binary files a/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png and b/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png differ