From f046db94220c1b582175f858f07fd64e81e6e864 Mon Sep 17 00:00:00 2001 From: miozune Date: Sun, 4 Jun 2023 19:54:11 +0900 Subject: Fix void protection not working with MB with custom output hatch field (#2051) * Fix void protection not working with MB with custom output hatch field * forgot to filter * Add util method for DT-like structure --- .../api/interfaces/tileentity/IVoidable.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java (limited to 'src/main/java/gregtech/api/interfaces/tileentity') diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java b/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java new file mode 100644 index 0000000000..d6325e8597 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java @@ -0,0 +1,64 @@ +package gregtech.api.interfaces.tileentity; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.VoidingMode; +import gregtech.api.interfaces.fluid.IFluidStore; + +/** + * Machines implementing this interface can have logic to configure whether to void excess output or not. + */ +public interface IVoidable { + + /** + * @return if this machine can prevent excess item and fluid from voiding. + */ + boolean supportsVoidProtection(); + + /** + * @return if this machine is configured to not void excess item. + */ + default boolean protectsExcessItem() { + return supportsVoidProtection() && getVoidingMode().protectItem; + } + + /** + * @return if this machine is configured to not void excess fluid. + */ + default boolean protectsExcessFluid() { + return supportsVoidProtection() && getVoidingMode().protectFluid; + } + + VoidingMode getVoidingMode(); + + void setVoidingMode(VoidingMode mode); + + /** + * @param toOutput List of items this machine is going to output. + * @return List of slots available for item outputs. Null element represents empty slot. + */ + List getItemOutputSlots(ItemStack[] toOutput); + + /** + * @param toOutput List of fluids this machine is going to output. + * @return List of slots available for fluid outputs. + */ + List getFluidOutputSlots(FluidStack[] toOutput); + + /** + * @return If this machine has ability to dump item outputs to ME network. + * This doesn't need to check if it can actually dump to ME, + * as this might be called every tick and cause lag. + */ + boolean canDumpItemToME(); + + /** + * @return If this machine has ability to dump fluid outputs to ME network. + * This doesn't need to check if it can actually dump to ME, + * as this might be called every tick and cause lag. + */ + boolean canDumpFluidToME(); +} -- cgit