aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java
blob: 83570fedccf03cbc5fc3475a304ed05381e7c1ce (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
90
91
92
93
94
95
96
package gregtech.api.interfaces.tileentity;

import javax.annotation.Nonnull;

import gregtech.api.util.shutdown.ShutDownReason;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;

/**
 * For Machines which have Progress
 */
public interface IMachineProgress extends IHasWorldObjectAndCoords {

    /**
     * returns the Progress this Machine has made. Warning, this can also be negative!
     */
    int getProgress();

    /**
     * returns the Progress the Machine needs to complete its task.
     */
    int getMaxProgress();

    /**
     * Manually increases the Progress of the Machine by vent cover.
     */
    boolean increaseProgress(int aProgressAmountInTicks);

    /**
     * returns if the Machine currently does something.
     */
    boolean hasThingsToDo();

    /**
     * returns if the Machine just got enableWorking called after being disabled. Used for Translocators, which need to
     * check if they need to transfer immediately.
     */
    boolean hasWorkJustBeenEnabled();

    /**
     * allows Machine to work
     */
    void enableWorking();

    /**
     * disallows Machine to work
     */
    void disableWorking();

    /**
     * if the Machine is allowed to Work
     */
    boolean isAllowedToWork();

    default void setAllowedToWork(Boolean allowedToWork) {
        if (allowedToWork) {
            enableWorking();
        } else {
            disableWorking();
        }
    }

    /**
     * used to control Machines via Redstone Signal Strength by special Covers In case of 0 the Machine is very likely
     * doing nothing, or is just not being controlled at all.
     */
    default byte getWorkDataValue() {
        return 0;
    }

    /**
     * used to control Machines via Redstone Signal Strength by special Covers only Values between 0 and 15!
     */
    default void setWorkDataValue(byte aValue) {}

    /**
     * gives you the Active Status of the Machine
     */
    boolean isActive();

    /**
     * sets the visible Active Status of the Machine
     */
    void setActive(boolean aActive);

    /**
     * Indicates if the object in question was forced to shut down (i.e. loss of power)
     */
    default boolean wasShutdown() {
        return false;
    }

    @Nonnull
    default ShutDownReason getLastShutDownReason() {
        return ShutDownReasonRegistry.NONE;
    }
}