aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java
blob: 841fd07bbadfd008957b7bccf70f7282f8033374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package gregtech.api.interfaces.tileentity;

import java.util.List;
import java.util.Set;

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();

    default Set<VoidingMode> getAllowedVoidingModes() {
        return VoidingMode.ALL_OPTIONS;
    }

    /**
     * @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);

    default VoidingMode getDefaultVoidingMode() {
        return supportsVoidProtection() ? VoidingMode.VOID_NONE : VoidingMode.VOID_ALL;
    }

    /**
     * @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<ItemStack> getItemOutputSlots(ItemStack[] toOutput);

    /**
     * @param toOutput List of fluids this machine is going to output.
     * @return List of slots available for fluid outputs.
     */
    List<? extends IFluidStore> getFluidOutputSlots(FluidStack[] toOutput);

    /**
     * @return How many slots of items this machine can output per recipe. Item outputs whose slot number
     *         exceeding this limit will be voided.
     */
    default int getItemOutputLimit() {
        return Integer.MAX_VALUE;
    }

    /**
     * @return How many slots of fluids this machine can output per recipe. Fluid outputs whose slot number
     *         exceeding this limit will be voided.
     */
    default int getFluidOutputLimit() {
        return Integer.MAX_VALUE;
    }

    /**
     * @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();
}