diff --git a/src/main/java/techreborn/client/gui/slot/elements/CheckBoxElement.java b/src/main/java/techreborn/client/gui/slot/elements/CheckBoxElement.java index fa14fe805..f96f52101 100644 --- a/src/main/java/techreborn/client/gui/slot/elements/CheckBoxElement.java +++ b/src/main/java/techreborn/client/gui/slot/elements/CheckBoxElement.java @@ -48,6 +48,9 @@ public class CheckBoxElement extends ElementBase { if(type.equalsIgnoreCase("output")){ return machineBase.slotConfiguration.getSlotDetails(slotID).autoOutput(); } + if(type.equalsIgnoreCase("filter")){ + return machineBase.slotConfiguration.getSlotDetails(slotID).filter(); + } return machineBase.slotConfiguration.getSlotDetails(slotID).autoInput(); } diff --git a/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java b/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java index 9decb3307..dec58f512 100644 --- a/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java +++ b/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java @@ -6,11 +6,14 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderItem; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import reborncore.api.recipe.IRecipeCrafterProvider; +import reborncore.common.recipes.RecipeCrafter; import reborncore.common.tile.SlotConfiguration; import techreborn.client.gui.GuiBase; import techreborn.client.gui.slot.GuiSlotConfiguration; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class ConfigSlotElement extends ElementBase { @@ -18,6 +21,7 @@ public class ConfigSlotElement extends ElementBase { IInventory inventory; int id; public List elements = new ArrayList<>(); + boolean filter = false; public ConfigSlotElement(IInventory slotInventory, int slotId, SlotType type, int x, int y, GuiBase gui) { @@ -44,6 +48,18 @@ public class ConfigSlotElement extends ElementBase { popupElement.updateCheckBox((CheckBoxElement) element, "output", gui13); return true; })); + + if(gui.getMachine() instanceof IRecipeCrafterProvider){ + RecipeCrafter recipeCrafter = ((IRecipeCrafterProvider) gui.getMachine()).getRecipeCrafter(); + if(Arrays.stream(recipeCrafter.inputSlots).anyMatch(value -> value == slotId)){ + elements.add(new CheckBoxElement("Filter Inputs", 0xFFFFFFFF, x - 26, y + 72,"filter", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine()).addPressAction((element, gui13, provider, mouseX, mouseY) -> { + popupElement.updateCheckBox((CheckBoxElement) element, "filter", gui13); + return true; + })); + filter = true; + popupElement.filter = true; + } + } } @Override diff --git a/src/main/java/techreborn/client/gui/slot/elements/SlotConfigPopupElement.java b/src/main/java/techreborn/client/gui/slot/elements/SlotConfigPopupElement.java index d62b9eb65..f26d31d74 100644 --- a/src/main/java/techreborn/client/gui/slot/elements/SlotConfigPopupElement.java +++ b/src/main/java/techreborn/client/gui/slot/elements/SlotConfigPopupElement.java @@ -23,6 +23,7 @@ import java.awt.*; public class SlotConfigPopupElement extends ElementBase { int id; + public boolean filter = false; ConfigSlotElement slotElement; @@ -35,7 +36,7 @@ public class SlotConfigPopupElement extends ElementBase { @Override public void draw(GuiBase gui) { - drawDefaultBackground(gui, adjustX(gui, getX() -8), adjustY(gui, getY() - 7), 84, 105); + drawDefaultBackground(gui, adjustX(gui, getX() -8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0)); super.draw(gui); TileLegacyMachineBase machine = ((TileLegacyMachineBase) gui.tile); @@ -95,14 +96,18 @@ public class SlotConfigPopupElement extends ElementBase { SlotConfiguration.SlotConfigHolder configHolder = guiBase.getMachine().slotConfiguration.getSlotDetails(id); boolean input = configHolder.autoInput(); boolean output = configHolder.autoOutput(); + boolean filter = configHolder.filter(); if(type.equalsIgnoreCase("input")){ input = !configHolder.autoInput(); } if(type.equalsIgnoreCase("output")){ output = !configHolder.autoOutput(); } + if(type.equalsIgnoreCase("filter")){ + filter = !configHolder.filter(); + } - PacketIOSave packetSlotSave = new PacketIOSave(guiBase.tile.getPos(), id, input, output); + PacketIOSave packetSlotSave = new PacketIOSave(guiBase.tile.getPos(), id, input, output, filter); NetworkManager.sendToServer(packetSlotSave); }