-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebugScreenInformation.java
105 lines (84 loc) · 3.89 KB
/
DebugScreenInformation.java
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
package org.auioc.mcmod.arnicalib.mod.client.widget;
import java.util.ArrayList;
import org.auioc.mcmod.arnicalib.base.collection.ListUtils;
import org.auioc.mcmod.arnicalib.game.world.position.SpeedUnit;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.EnumValue;
public class DebugScreenInformation {
private static final Minecraft MC = Minecraft.getInstance();
public static void handle(ArrayList<String> gameInfo, ArrayList<String> systemInfo) {
if (!MC.options.reducedDebugInfo) handleGameInformation(gameInfo);
handleSystemInformation(systemInfo);
}
private static void handleGameInformation(ArrayList<String> info) {
if (Config.enabledTweaks.get()) {
if (Config.hideLeftSide.get() && _clear(info)) return;
}
if (Config.enabledAddons.get()) {
if (Config.speedmeterEnabled.get()) _addSpeedmeter(info);
}
}
private static void handleSystemInformation(ArrayList<String> info) {
if (Config.enabledTweaks.get()) {
if (Config.hideRightSide.get() && _clear(info)) return;
if (Config.hideSystemInformation.get()) _removeSystemInfo(info);
}
}
private static boolean _clear(ArrayList<String> info) {
info.clear();
return true;
}
private static void _addSpeedmeter(ArrayList<String> info) {
var unit = Config.speedmeterUnit.get();
var symbol = Config.speedmeterShowUnitSymbol.get() ? String.format(" (%s)", unit.getSymbol()) : "";
var entity = MC.cameraEntity;
double vX = unit.convertFrom(entity.getX() - entity.xOld);
double vY = unit.convertFrom(entity.getY() - entity.yOld);
double vZ = unit.convertFrom(entity.getZ() - entity.zOld);
double vA = Math.sqrt(vX * vX + vY * vY + vZ * vZ);
var velocity = String.format("Velocity: %.3f / %.3f / %.3f%s", vX, vY, vZ, symbol);
var speed = String.format("Speed: %.3f%s", vA, symbol);
int at = ListUtils.indexOf(info, (l) -> l.startsWith("XYZ")) + 1;
ListUtils.add(info, at, speed);
ListUtils.add(info, at, velocity);
}
private static void _removeSystemInfo(ArrayList<String> info) {
int targetedIndex = ListUtils.indexOf(info, (l) -> l.startsWith("§nTargeted"));
int toIndex = targetedIndex != -1 ? targetedIndex : info.size();
info.subList(0, toIndex).clear();
}
public static class Config {
public static BooleanValue enabledAddons;
public static BooleanValue speedmeterEnabled;
public static EnumValue<SpeedUnit> speedmeterUnit;
public static BooleanValue speedmeterShowUnitSymbol;
public static BooleanValue enabledTweaks;
public static BooleanValue hideLeftSide;
public static BooleanValue hideRightSide;
public static BooleanValue hideSystemInformation;
public static void build(final ForgeConfigSpec.Builder b) {
{
b.push("addons");
enabledAddons = b.define("enabled", true);
{
b.push("speedmeter");
speedmeterEnabled = b.define("enabled", true);
speedmeterUnit = b.defineEnum("unit", SpeedUnit.METRES_PER_SECOND);
speedmeterShowUnitSymbol = b.define("show_unit_symbol", true);
b.pop();
}
b.pop();
}
{
b.push("tweaks");
enabledTweaks = b.define("enabled", false);
hideLeftSide = b.define("hide_left_side", false);
hideRightSide = b.define("hide_right_side", false);
hideSystemInformation = b.define("hide_system_information", false);
b.pop();
}
}
}
}