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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package gregtech.api.enums;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Set;
import javax.annotation.Nonnull;
import com.gtnewhorizons.modularui.api.drawable.UITexture;
import gregtech.api.gui.modularui.GTUITextures;
public enum VoidingMode {
/**
* Voids nothing, protects both item and fluid
*/
VOID_NONE(true, true, GTUITextures.BUTTON_STANDARD, GTUITextures.OVERLAY_BUTTON_VOID_EXCESS_NONE, "none"),
/**
* Voids item, protects fluid
*/
VOID_ITEM(false, true, GTUITextures.BUTTON_STANDARD_PRESSED, GTUITextures.OVERLAY_BUTTON_VOID_EXCESS_ITEM, "item"),
/**
* Voids fluid, protects item
*/
VOID_FLUID(true, false, GTUITextures.BUTTON_STANDARD_PRESSED, GTUITextures.OVERLAY_BUTTON_VOID_EXCESS_FLUID,
"fluid"),
/**
* Voids all, protects nothing
*/
VOID_ALL(false, false, GTUITextures.BUTTON_STANDARD_PRESSED, GTUITextures.OVERLAY_BUTTON_VOID_EXCESS_ALL, "all");
/**
* Default set of voiding mode you will probably support.
*/
public static final Set<VoidingMode> ALL_OPTIONS = EnumSet.allOf(VoidingMode.class);
/**
* Set of voiding mode you will probably support if your machine has no item output
*/
public static final Set<VoidingMode> FLUID_ONLY_MODES = EnumSet.of(VOID_FLUID, VOID_NONE);
/**
* Set of voiding mode you will probably support if your machine has no fluid output
*/
public static final Set<VoidingMode> ITEM_ONLY_MODES = EnumSet.of(VOID_ITEM, VOID_NONE);
public final boolean protectItem;
public final boolean protectFluid;
public final UITexture buttonTexture;
public final UITexture buttonOverlay;
public final String name;
VoidingMode(boolean protectItem, boolean protectFluid, UITexture buttonTexture, UITexture buttonOverlay,
String name) {
this.protectItem = protectItem;
this.protectFluid = protectFluid;
this.buttonTexture = buttonTexture;
this.buttonOverlay = buttonOverlay;
this.name = name;
}
public String getTransKey() {
return "GT5U.gui.button.voiding_mode_" + name;
}
public VoidingMode next() {
return values()[(ordinal() + 1) % values().length];
}
public VoidingMode previous() {
return values()[(ordinal() + values().length - 1) % values().length];
}
public VoidingMode nextInCollection(Collection<VoidingMode> allowed) {
if (allowed.isEmpty()) throw new IllegalArgumentException("nothing allowed");
VoidingMode ret = this;
do {
ret = ret.next();
} while (!allowed.contains(ret));
return ret;
}
public VoidingMode previousInCollection(Collection<VoidingMode> allowed) {
if (allowed.isEmpty()) throw new IllegalArgumentException("nothing allowed");
VoidingMode ret = this;
do {
ret = ret.previous();
} while (!allowed.contains(ret));
return ret;
}
/**
* Do not use this for loading mode from TEs, to prevent mode being shifted when new mode is added.
*/
@Nonnull
public static VoidingMode fromOrdinal(int ordinal) {
if (ordinal >= 0 && ordinal < values().length) {
return values()[ordinal];
}
return VOID_NONE;
}
@Nonnull
public static VoidingMode fromName(String name) {
for (VoidingMode mode : values()) {
if (mode.name.equals(name)) {
return mode;
}
}
return VOID_NONE;
}
}
|