Hotfix Nr. 2
This commit is contained in:
@@ -32,6 +32,10 @@ public class Config {
|
||||
|
||||
public boolean fullbrightEnabled = false;
|
||||
|
||||
public boolean hitboxEnabled = false;
|
||||
public int hitboxHue = 0;
|
||||
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("citrus-dev.json");
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.fullrisk.citrusDev.UI;
|
||||
|
||||
import de.fullrisk.citrusDev.Config;
|
||||
|
||||
public class Module_Hitbox {
|
||||
private static boolean enabled = Config.get().hitboxEnabled;
|
||||
private static int hue = Config.get().hitboxHue; // 0-360
|
||||
public static volatile int color = hueToArgb(hue);
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public static void setEnabled(boolean value) {
|
||||
enabled = value;
|
||||
Config.get().hitboxEnabled = value;
|
||||
Config.get().save();
|
||||
}
|
||||
|
||||
public static int getHue() {
|
||||
return hue;
|
||||
}
|
||||
|
||||
public static void setHue(int value) {
|
||||
hue = value;
|
||||
color = hueToArgb(hue);
|
||||
Config.get().hitboxHue = value;
|
||||
Config.get().save();
|
||||
}
|
||||
|
||||
private static int hueToArgb(int hueDegrees) {
|
||||
float h = (hueDegrees % 360) / 360.0F;
|
||||
int rgb = java.awt.Color.HSBtoRGB(h, 1.0F, 1.0F);
|
||||
return 0xFF000000 | (rgb & 0x00FFFFFF); // force opaque
|
||||
}
|
||||
}
|
||||
@@ -366,11 +366,33 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
|
||||
"Module Disabled", "Fullbright is now inactive"
|
||||
);
|
||||
|
||||
FlowLayout hitboxRow = ModuleRow.build(
|
||||
GLASS_PANEL, DISABLED, FLAT,
|
||||
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/block_culling_file.png"),
|
||||
18, 12,
|
||||
MC_FIVE,
|
||||
"hitbox",
|
||||
"Customize hitboxes",
|
||||
new ModuleRow.ToggleState() {
|
||||
public boolean get() { return Module_Hitbox.isEnabled(); }
|
||||
public void set(boolean value) { Module_Hitbox.setEnabled(value); }
|
||||
},
|
||||
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/settings.png"),
|
||||
() -> {
|
||||
Config.get().lastModule = "Hitbox";
|
||||
Config.get().save();
|
||||
openModuleSettings("Hitbox", hitboxSettings());
|
||||
},
|
||||
"Module Enabled", "Hitbox color is now active",
|
||||
"Module Disabled", "Hitbox color is now inactive"
|
||||
);
|
||||
|
||||
FlowLayout rowsContainer = UIContainers.verticalFlow(Sizing.fixed(CONTENT_WIDTH - 8), Sizing.content());
|
||||
rowsContainer.gap(4);
|
||||
rowsContainer.verticalAlignment(VerticalAlignment.TOP);
|
||||
rowsContainer.horizontalAlignment(HorizontalAlignment.CENTER);
|
||||
|
||||
rowsContainer.child(hitboxRow);
|
||||
rowsContainer.child(coordinatesRow);
|
||||
rowsContainer.child(keyStrokesRow);
|
||||
rowsContainer.child(fpsRow);
|
||||
@@ -459,6 +481,7 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
|
||||
case "FPS" -> openModuleSettings("FPS", fpsModuleSettings());
|
||||
case "Key" -> openModuleSettings("Keystrokes", keyStrokesSettings());
|
||||
case "Coords" -> openModuleSettings("Coordinates", CoordsSettings());
|
||||
case "Hitbox" -> openModuleSettings("Hitbox", hitboxSettings());
|
||||
default -> buildGeneralPanel(content);
|
||||
}
|
||||
}
|
||||
@@ -555,6 +578,36 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
|
||||
|
||||
}
|
||||
|
||||
private List<SettingRow> hitboxSettings() {
|
||||
|
||||
FlowLayout enabledCheckbox = SettingsControls.makeCheckbox(
|
||||
FLAT,
|
||||
GLASS_PANEL,
|
||||
Module_Hitbox.isEnabled(),
|
||||
value -> {
|
||||
Module_Hitbox.setEnabled(value);
|
||||
openModuleSettings("Hitbox", hitboxSettings()); // rebuild panel so slider appears/disappears
|
||||
}
|
||||
);
|
||||
|
||||
List<SettingRow> rows = new java.util.ArrayList<>();
|
||||
rows.add(new SettingRow("Custom Color", enabledCheckbox));
|
||||
|
||||
if (Module_Hitbox.isEnabled()) {
|
||||
FlowLayout hueSlider = SettingsControls.makeSlider(
|
||||
FLAT,
|
||||
80,
|
||||
0.0, 360.0,
|
||||
Module_Hitbox.getHue(),
|
||||
value -> (int) (double) value + "°",
|
||||
value -> Module_Hitbox.setHue((int) (double) value)
|
||||
);
|
||||
rows.add(new SettingRow("Color", hueSlider));
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
private int positionIndex(int x, int y) {
|
||||
boolean right = x > 50;
|
||||
boolean bottom = y > 50;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.fullrisk.citrusDev.mixin;
|
||||
|
||||
import de.fullrisk.citrusDev.Config;
|
||||
import de.fullrisk.citrusDev.UI.Module_Hitbox;
|
||||
import net.minecraft.client.renderer.debug.EntityHitboxDebugRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(EntityHitboxDebugRenderer.class)
|
||||
public class HitboxColorMixin {
|
||||
|
||||
@ModifyVariable(method = "showHitboxes", at = @At("STORE"), name = "mainColor")
|
||||
private int citrusDev$changeHitboxColor(int mainColor) {
|
||||
return Module_Hitbox.isEnabled() ? Module_Hitbox.color : mainColor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user