mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
93 lines
2.4 KiB
Java
93 lines
2.4 KiB
Java
package crazypants.enderio.machine;
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
|
|
import crazypants.enderio.EnderIO;
|
|
import crazypants.enderio.conduit.ConnectionMode;
|
|
|
|
public enum IoMode {
|
|
|
|
NONE("gui.machine.ioMode.none"),
|
|
PULL("gui.machine.ioMode.pull"),
|
|
PUSH("gui.machine.ioMode.push"),
|
|
PUSH_PULL("gui.machine.ioMode.pullPush"),
|
|
DISABLED("gui.machine.ioMode.disabled");
|
|
|
|
private final String unlocalisedName;
|
|
|
|
IoMode(String unlocalisedName) {
|
|
this.unlocalisedName = unlocalisedName;
|
|
}
|
|
|
|
public String getUnlocalisedName() {
|
|
return unlocalisedName;
|
|
}
|
|
|
|
public static ConnectionMode getNext(ConnectionMode mode) {
|
|
int ord = mode.ordinal() + 1;
|
|
if (ord >= ConnectionMode.VALUES.length) {
|
|
ord = 0;
|
|
}
|
|
return ConnectionMode.VALUES[ord];
|
|
}
|
|
|
|
public static ConnectionMode getPrevious(ConnectionMode mode) {
|
|
|
|
int ord = mode.ordinal() - 1;
|
|
if (ord < 0) {
|
|
ord = ConnectionMode.VALUES.length - 1;
|
|
}
|
|
return ConnectionMode.VALUES[ord];
|
|
}
|
|
|
|
public boolean pulls() {
|
|
return this == PULL || this == PUSH_PULL;
|
|
}
|
|
|
|
public boolean pushes() {
|
|
return this == PUSH || this == PUSH_PULL;
|
|
}
|
|
|
|
public boolean canOutput() {
|
|
return pushes() || this == NONE;
|
|
}
|
|
|
|
public boolean canRecieveInput() {
|
|
return pulls() || this == NONE;
|
|
}
|
|
|
|
public String getLocalisedName() {
|
|
return EnderIO.lang.localize(unlocalisedName);
|
|
}
|
|
|
|
public String colorLocalisedName() {
|
|
String loc = getLocalisedName();
|
|
switch (this) {
|
|
case DISABLED:
|
|
return EnumChatFormatting.RED + loc;
|
|
case NONE:
|
|
return EnumChatFormatting.GRAY + loc;
|
|
case PULL:
|
|
return EnumChatFormatting.AQUA + loc;
|
|
case PUSH:
|
|
return EnumChatFormatting.GOLD + loc;
|
|
case PUSH_PULL:
|
|
return String.format(
|
|
EnderIO.lang.localize(this.getUnlocalisedName() + ".colored"),
|
|
EnumChatFormatting.GOLD,
|
|
EnumChatFormatting.WHITE,
|
|
EnumChatFormatting.AQUA);
|
|
default:
|
|
return loc;
|
|
}
|
|
}
|
|
|
|
public IoMode next() {
|
|
int index = ordinal() + 1;
|
|
if (index >= values().length) {
|
|
index = 0;
|
|
}
|
|
return values()[index];
|
|
}
|
|
}
|