-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathXRay.java
More file actions
67 lines (51 loc) · 2.04 KB
/
Copy pathXRay.java
File metadata and controls
67 lines (51 loc) · 2.04 KB
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
package pro.mikey.xray;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.resources.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;
import pro.mikey.xray.screens.ScanManageScreen;
import pro.mikey.xray.utils.XPlatShim;
import pro.mikey.xray.core.ScanController;
import java.util.ServiceLoader;
public enum XRay {
INSTANCE;
public static final String MOD_ID = "xray";
public static final Identifier SERVER_DISABLE_CHANNEL = id("disable");
private static final Logger LOGGER = LogManager.getLogger();
public static final XPlatShim XPLAT = ServiceLoader.load(XPlatShim.class).findFirst().orElseThrow();
private static final KeyMapping.Category CATEGORY = KeyMapping.Category.register(XRay.id("category"));
public static final KeyMapping TOGGLE_KEY = new KeyMapping(I18n.get("xray.config.toggle"), GLFW.GLFW_KEY_BACKSLASH, CATEGORY);
public static final KeyMapping OPEN_GUI_KEY = new KeyMapping(I18n.get("xray.config.open"), GLFW.GLFW_KEY_G, CATEGORY);
public void init() {
}
public void onToggleKeyPressed() {
if (minecraftNotReady()) {
LOGGER.warn("Cannot toggle X-Ray, Minecraft is not ready.");
return;
}
ScanController.INSTANCE.toggleXRay();
}
public void onOpenGuiKeyPressed() {
if (minecraftNotReady()) {
LOGGER.warn("Cannot open GUI, Minecraft is not ready.");
return;
}
Minecraft.getInstance().gui.setScreen(new ScanManageScreen());
}
private boolean minecraftNotReady() {
Minecraft mc = Minecraft.getInstance();
return mc.player == null || Minecraft.getInstance().gui.screen() != null || Minecraft.getInstance().level == null;
}
public static Identifier id(String path) {
return Identifier.fromNamespaceAndPath(MOD_ID, path);
}
public static Identifier assetLocation(String path) {
return Identifier.fromNamespaceAndPath(MOD_ID, "textures/" + path);
}
public static Configuration config() {
return Configuration.INSTANCE;
}
}