config (not interactable)
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
package org.saturnclient.saturnclient;
|
package org.saturnclient.saturnclient;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.util.math.ColorHelper;
|
import net.minecraft.util.math.ColorHelper;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.cloaks.Cloaks;
|
import org.saturnclient.saturnclient.cloaks.Cloaks;
|
||||||
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
import org.saturnclient.saturnclient.event.KeyInputHandler;
|
import org.saturnclient.saturnclient.event.KeyInputHandler;
|
||||||
import org.saturnclient.saturnmods.ModManager;
|
import org.saturnclient.saturnmods.ModManager;
|
||||||
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
import org.saturnclient.saturnclient.auth.SaturnSocket;
|
||||||
@@ -26,6 +28,9 @@ public class SaturnClient implements ModInitializer {
|
|||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
LOGGER.info("Initializing " + MOD_ID);
|
LOGGER.info("Initializing " + MOD_ID);
|
||||||
ModManager.init();
|
ModManager.init();
|
||||||
|
ConfigManager.load();
|
||||||
|
|
||||||
|
ClientLifecycleEvents.CLIENT_STOPPING.register(c -> ConfigManager.save());
|
||||||
|
|
||||||
KeyInputHandler.register();
|
KeyInputHandler.register();
|
||||||
if (SaturnSocket.authenticate()) {
|
if (SaturnSocket.authenticate()) {
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package org.saturnclient.saturnclient.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
public class ConfigManager {
|
||||||
|
private static File configFile = new File(MinecraftClient.getInstance().runDirectory, "saturn.json");
|
||||||
|
private static Map<String, Map<String, Property<?>>> properties = new HashMap<>();
|
||||||
|
|
||||||
|
private String namespace;
|
||||||
|
|
||||||
|
public ConfigManager(String namespace) {
|
||||||
|
this.namespace = namespace;
|
||||||
|
properties.put(namespace, new HashMap<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generic method to store any type of property
|
||||||
|
public <T> Property<T> property(String name, Property<T> value) {
|
||||||
|
properties.get(namespace).put(name, value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static void load() {
|
||||||
|
try {
|
||||||
|
SaturnClient.LOGGER.info("Starting to load config...");
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
configFile.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject jsonObject = JsonParser.parseString(new String(Files.readAllBytes(configFile.toPath())))
|
||||||
|
.getAsJsonObject();
|
||||||
|
|
||||||
|
for (String namespace : properties.keySet()) {
|
||||||
|
JsonElement configElement = jsonObject.get(namespace);
|
||||||
|
|
||||||
|
if (configElement == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
JsonObject config = jsonObject.get(namespace).getAsJsonObject();
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
SaturnClient.LOGGER.warn("No config found for namespace: " + namespace);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Property<?>> propertyMap = properties.get(namespace);
|
||||||
|
|
||||||
|
for (String propertyName : propertyMap.keySet()) {
|
||||||
|
JsonElement c = config.get(propertyName);
|
||||||
|
|
||||||
|
if (c == null) {
|
||||||
|
SaturnClient.LOGGER.warn("No property found in config for " + propertyName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaturnClient.LOGGER.info("got prop " + c);
|
||||||
|
Property<?> p = propertyMap.get(propertyName);
|
||||||
|
SaturnClient.LOGGER.info("setting prop " + propertyName + " to " + p.value);
|
||||||
|
|
||||||
|
SaturnClient.LOGGER.info("Property type: " + p.getType());
|
||||||
|
if (p.matchesJson(c)) {
|
||||||
|
switch (p.getType()) {
|
||||||
|
case BOOLEAN:
|
||||||
|
((Property<Boolean>) p).value = c.getAsBoolean();
|
||||||
|
break;
|
||||||
|
case INTEGER:
|
||||||
|
((Property<Integer>) p).value = c.getAsInt();
|
||||||
|
break;
|
||||||
|
case FLOAT:
|
||||||
|
((Property<Float>) p).value = c.getAsFloat();
|
||||||
|
break;
|
||||||
|
case STRING:
|
||||||
|
((Property<String>) p).value = c.getAsString();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SaturnClient.LOGGER.warn("Property does not match JSON: " + propertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
SaturnClient.LOGGER.error("Error reading the config file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save() {
|
||||||
|
try {
|
||||||
|
SaturnClient.LOGGER.info("Starting to save config...");
|
||||||
|
|
||||||
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
|
||||||
|
// Iterate through all namespaces and their properties
|
||||||
|
for (String namespace : properties.keySet()) {
|
||||||
|
JsonObject namespaceConfig = new JsonObject();
|
||||||
|
Map<String, Property<?>> propertyMap = properties.get(namespace);
|
||||||
|
|
||||||
|
// Iterate through each property in the namespace
|
||||||
|
for (String propertyName : propertyMap.keySet()) {
|
||||||
|
Property<?> property = propertyMap.get(propertyName);
|
||||||
|
JsonElement propertyValue = null;
|
||||||
|
|
||||||
|
// Convert the property value based on its type
|
||||||
|
switch (property.getType()) {
|
||||||
|
case BOOLEAN:
|
||||||
|
propertyValue = new JsonPrimitive((Boolean) property.value);
|
||||||
|
break;
|
||||||
|
case INTEGER:
|
||||||
|
propertyValue = new JsonPrimitive((Integer) property.value);
|
||||||
|
break;
|
||||||
|
case FLOAT:
|
||||||
|
propertyValue = new JsonPrimitive((Float) property.value);
|
||||||
|
break;
|
||||||
|
case STRING:
|
||||||
|
propertyValue = new JsonPrimitive((String) property.value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SaturnClient.LOGGER.warn("Unknown property type for: " + propertyName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (propertyValue != null) {
|
||||||
|
namespaceConfig.add(propertyName, propertyValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the namespace config to the main JSON object
|
||||||
|
jsonObject.add(namespace, namespaceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the JSON object to the config file
|
||||||
|
Files.write(configFile.toPath(), jsonObject.toString().getBytes());
|
||||||
|
SaturnClient.LOGGER.info("Config saved successfully.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
SaturnClient.LOGGER.error("Error saving the config file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package org.saturnclient.saturnclient.config;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
|
||||||
|
public class Property<T> {
|
||||||
|
public enum PropertyType {
|
||||||
|
BOOLEAN, INTEGER, FLOAT, STRING, UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
public T value;
|
||||||
|
|
||||||
|
public Property(T value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBool() {
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return (boolean) value;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Property does not contain a boolean");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt() {
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
return (int) value;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Property does not contain an int");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFloat() {
|
||||||
|
if (value instanceof Float) {
|
||||||
|
return (float) value;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Property does not contain a float");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString() {
|
||||||
|
if (value instanceof String) {
|
||||||
|
return (String) value;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Property does not contain a string");
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyType getType() {
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return PropertyType.BOOLEAN;
|
||||||
|
}
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
return PropertyType.INTEGER;
|
||||||
|
}
|
||||||
|
if (value instanceof Float) {
|
||||||
|
return PropertyType.FLOAT;
|
||||||
|
}
|
||||||
|
if (value instanceof String) {
|
||||||
|
return PropertyType.STRING;
|
||||||
|
}
|
||||||
|
return PropertyType.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean matchesJson(JsonElement element) {
|
||||||
|
if (element.isJsonPrimitive()) {
|
||||||
|
JsonPrimitive primitive = element.getAsJsonPrimitive();
|
||||||
|
if (value instanceof Boolean && primitive.isBoolean())
|
||||||
|
return true;
|
||||||
|
if (value instanceof Integer && primitive.isNumber())
|
||||||
|
return true;
|
||||||
|
if (value instanceof Float && primitive.isNumber())
|
||||||
|
return true;
|
||||||
|
if (value instanceof String && primitive.isString())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import net.minecraft.client.gui.DrawContext;
|
|||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
import org.saturnclient.saturnmods.HudMod;
|
import org.saturnclient.saturnmods.HudMod;
|
||||||
import org.saturnclient.saturnmods.ModDimensions;
|
import org.saturnclient.saturnmods.ModDimensions;
|
||||||
import org.saturnclient.saturnmods.ModManager;
|
import org.saturnclient.saturnmods.ModManager;
|
||||||
@@ -38,8 +40,8 @@ public class HudEditor extends Screen {
|
|||||||
if (isCorner(mouseX, mouseY, dim)) {
|
if (isCorner(mouseX, mouseY, dim)) {
|
||||||
draggingMod = mod;
|
draggingMod = mod;
|
||||||
resizing = true;
|
resizing = true;
|
||||||
offsetX = (int) (mouseX - (dim.x + dim.width * dim.scale));
|
offsetX = (int) (mouseX - (dim.x.value + dim.width * dim.scale.value));
|
||||||
offsetY = (int) (mouseY - (dim.y + dim.height * dim.scale));
|
offsetY = (int) (mouseY - (dim.y.value + dim.height * dim.scale.value));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,8 +49,8 @@ public class HudEditor extends Screen {
|
|||||||
if (isInside(mouseX, mouseY, dim)) {
|
if (isInside(mouseX, mouseY, dim)) {
|
||||||
draggingMod = mod;
|
draggingMod = mod;
|
||||||
resizing = false;
|
resizing = false;
|
||||||
offsetX = (int) (mouseX - dim.x);
|
offsetX = (int) (mouseX - dim.x.value);
|
||||||
offsetY = (int) (mouseY - dim.y);
|
offsetY = (int) (mouseY - dim.y.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,12 +74,12 @@ public class HudEditor extends Screen {
|
|||||||
|
|
||||||
if (resizing) {
|
if (resizing) {
|
||||||
// Scale based on cursor movement
|
// Scale based on cursor movement
|
||||||
float newScale = Math.max(0.5f, ((float) (mouseX - dim.x) / dim.width));
|
float newScale = Math.max(0.5f, ((float) (mouseX - dim.x.value) / dim.width));
|
||||||
dim.scale = newScale;
|
dim.scale.value = newScale;
|
||||||
} else {
|
} else {
|
||||||
// Move the mod
|
// Move the mod
|
||||||
dim.x = (int) mouseX - offsetX;
|
dim.x.value = (int) mouseX - offsetX;
|
||||||
dim.y = (int) mouseY - offsetY;
|
dim.y.value = (int) mouseY - offsetY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||||
@@ -90,8 +92,8 @@ public class HudEditor extends Screen {
|
|||||||
MatrixStack matrices = context.getMatrices();
|
MatrixStack matrices = context.getMatrices();
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
matrices.translate(dim.x, dim.y, 0);
|
matrices.translate(dim.x.value, dim.y.value, 0);
|
||||||
matrices.scale(dim.scale, dim.scale, 1.0f);
|
matrices.scale(dim.scale.value, dim.scale.value, 1.0f);
|
||||||
|
|
||||||
// Render the mod
|
// Render the mod
|
||||||
mod.renderDummy(context);
|
mod.renderDummy(context);
|
||||||
@@ -99,24 +101,30 @@ public class HudEditor extends Screen {
|
|||||||
matrices.pop();
|
matrices.pop();
|
||||||
|
|
||||||
// Draw border around mod
|
// Draw border around mod
|
||||||
int borderX = dim.x;
|
int borderX = dim.x.value;
|
||||||
int borderY = dim.y;
|
int borderY = dim.y.value;
|
||||||
int borderW = (int) (dim.width * dim.scale);
|
int borderW = (int) (dim.width * dim.scale.value);
|
||||||
int borderH = (int) (dim.height * dim.scale);
|
int borderH = (int) (dim.height * dim.scale.value);
|
||||||
|
|
||||||
context.drawBorder(borderX, borderY, borderW, borderH, 0xFFFFFFFF); // White border
|
context.drawBorder(borderX, borderY, borderW, borderH, 0xFFFFFFFF); // White border
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInside(double mouseX, double mouseY, ModDimensions dim) {
|
private boolean isInside(double mouseX, double mouseY, ModDimensions dim) {
|
||||||
return mouseX >= dim.x && mouseX <= dim.x + (dim.width * dim.scale) &&
|
return mouseX >= dim.x.value && mouseX <= dim.x.value + (dim.width * dim.scale.value) &&
|
||||||
mouseY >= dim.y && mouseY <= dim.y + (dim.height * dim.scale);
|
mouseY >= dim.y.value && mouseY <= dim.y.value + (dim.height * dim.scale.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCorner(double mouseX, double mouseY, ModDimensions dim) {
|
private boolean isCorner(double mouseX, double mouseY, ModDimensions dim) {
|
||||||
float rightX = dim.x + dim.width * dim.scale;
|
float rightX = dim.x.value + dim.width * dim.scale.value;
|
||||||
float bottomY = dim.y + dim.height * dim.scale;
|
float bottomY = dim.y.value + dim.height * dim.scale.value;
|
||||||
|
|
||||||
return Math.abs(mouseX - rightX) < RESIZE_MARGIN && Math.abs(mouseY - bottomY) < RESIZE_MARGIN;
|
return Math.abs(mouseX - rightX) < RESIZE_MARGIN && Math.abs(mouseY - bottomY) < RESIZE_MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
ConfigManager.save();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package org.saturnclient.saturnclient.menus;
|
||||||
|
|
||||||
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
|
import org.saturnclient.saturnmods.ModManager;
|
||||||
|
import org.saturnclient.saturnmods.SaturnMod;
|
||||||
|
import org.saturnclient.ui.SaturnUi;
|
||||||
|
import org.saturnclient.ui.Textures;
|
||||||
|
import org.saturnclient.ui.animations.FadeIn;
|
||||||
|
import org.saturnclient.ui.animations.Slide;
|
||||||
|
import org.saturnclient.ui.components.SaturnModComp;
|
||||||
|
import org.saturnclient.ui.widgets.SaturnClickableImage;
|
||||||
|
import org.saturnclient.ui.widgets.SaturnScroll;
|
||||||
|
import org.saturnclient.ui.widgets.SaturnSprite;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public class ModMenu extends SaturnUi {
|
||||||
|
public ModMenu() {
|
||||||
|
super(Text.literal("Mods"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
int rectWidth = 330;
|
||||||
|
int rectHeight = 228;
|
||||||
|
int modsX = (width - rectWidth) / 2;
|
||||||
|
int modsY = (height - rectHeight + 15) / 2;
|
||||||
|
|
||||||
|
draw(new SaturnSprite(Textures.SETTINGS_BG)
|
||||||
|
.setX(modsX)
|
||||||
|
.setY(modsY)
|
||||||
|
.setWidth(rectWidth)
|
||||||
|
.setHeight(rectHeight)
|
||||||
|
.setAnimations(new Slide(1, 10)));
|
||||||
|
|
||||||
|
int tabsX = (width - 43) / 2;
|
||||||
|
int tabsY = modsY - 17;
|
||||||
|
|
||||||
|
draw(new SaturnSprite(Textures.TABS)
|
||||||
|
.setX(tabsX)
|
||||||
|
.setY(tabsY)
|
||||||
|
.setWidth(43)
|
||||||
|
.setHeight(15)
|
||||||
|
.setAnimations(new Slide(1, 10)));
|
||||||
|
|
||||||
|
int tabSize = 9;
|
||||||
|
tabsX = (width - tabSize) / 2;
|
||||||
|
draw(new SaturnClickableImage(Textures.SETTINGS, () -> {
|
||||||
|
System.out.println("Pressed");
|
||||||
|
})
|
||||||
|
.setX(tabsX)
|
||||||
|
.setY(tabsY + 3)
|
||||||
|
.setWidth(tabSize)
|
||||||
|
.setHeight(tabSize)
|
||||||
|
.setAnimations(new FadeIn(2))
|
||||||
|
.setAnimations(new Slide(1, 10)));
|
||||||
|
|
||||||
|
draw(new SaturnClickableImage(Textures.MODS_TAB, () -> {
|
||||||
|
System.out.println("Pressed");
|
||||||
|
})
|
||||||
|
.setX(tabsX - 12)
|
||||||
|
.setY(tabsY + 3)
|
||||||
|
.setWidth(tabSize)
|
||||||
|
.setHeight(tabSize)
|
||||||
|
.setAnimations(new FadeIn(2))
|
||||||
|
.setAnimations(new Slide(1, 10)));
|
||||||
|
|
||||||
|
draw(new SaturnClickableImage(Textures.SEARCH, () -> {
|
||||||
|
System.out.println("Pressed");
|
||||||
|
})
|
||||||
|
.setX(tabsX + 12)
|
||||||
|
.setY(tabsY + 3)
|
||||||
|
.setWidth(tabSize)
|
||||||
|
.setHeight(tabSize)
|
||||||
|
.setAnimations(new FadeIn(2))
|
||||||
|
.setAnimations(new Slide(1, 10)));
|
||||||
|
|
||||||
|
int modX = 0;
|
||||||
|
int modY = 0;
|
||||||
|
int col = 0;
|
||||||
|
|
||||||
|
SaturnScroll modsScroll = new SaturnScroll();
|
||||||
|
|
||||||
|
for (SaturnMod mod : ModManager.MODS) {
|
||||||
|
modsScroll.draw(new SaturnModComp(mod)
|
||||||
|
.setX(modX)
|
||||||
|
.setY(modY)
|
||||||
|
.setWidth(86)
|
||||||
|
.setHeight(20));
|
||||||
|
|
||||||
|
col++;
|
||||||
|
|
||||||
|
if (col < 3) {
|
||||||
|
modX += 86 + 18;
|
||||||
|
} else {
|
||||||
|
modX = 0;
|
||||||
|
modY += 20 + 20;
|
||||||
|
col = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
draw(modsScroll.setX(modsX + 17).setY(modsY + 10).setWidth(rectWidth - 17).setHeight(rectHeight - 10)
|
||||||
|
.setAnimations(new Slide(1, 10)));
|
||||||
|
|
||||||
|
super.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
ConfigManager.save();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +1,57 @@
|
|||||||
package org.saturnclient.saturnmods;
|
package org.saturnclient.saturnmods;
|
||||||
|
|
||||||
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
|
|
||||||
public class ModDimensions {
|
public class ModDimensions {
|
||||||
public int x = 0;
|
public Property<Integer> x = new Property<>(0);
|
||||||
public int y = 0;
|
public Property<Integer> y = new Property<>(0);
|
||||||
public float scale = 1.0f;
|
public Property<Float> scale = new Property<>(1.0f);
|
||||||
|
|
||||||
public int width = 0;
|
public int width = 0;
|
||||||
public int height = 0;
|
public int height = 0;
|
||||||
|
|
||||||
public ModDimensions() {
|
public ModDimensions(ConfigManager configManager) {
|
||||||
|
configManager.property("x", this.x);
|
||||||
|
configManager.property("y", this.y);
|
||||||
|
configManager.property("scale", this.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModDimensions(int x, int y) {
|
public ModDimensions(ConfigManager configManager, int x, int y) {
|
||||||
this.x = x;
|
this.x.value = x;
|
||||||
this.y = y;
|
this.y.value = y;
|
||||||
|
configManager.property("x", this.x);
|
||||||
|
configManager.property("y", this.y);
|
||||||
|
configManager.property("scale", this.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModDimensions(int x, int y, int width, int height) {
|
public ModDimensions(ConfigManager configManager, int x, int y, int width, int height) {
|
||||||
this.x = x;
|
this.x.value = x;
|
||||||
this.y = y;
|
this.y.value = y;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
configManager.property("x", this.x);
|
||||||
|
configManager.property("y", this.y);
|
||||||
|
configManager.property("scale", this.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModDimensions(int x, int y, float scale) {
|
public ModDimensions(ConfigManager configManager, int x, int y, float scale) {
|
||||||
this.x = x;
|
this.x.value = x;
|
||||||
this.y = y;
|
this.y.value = y;
|
||||||
this.scale = scale;
|
this.scale.value = scale;
|
||||||
|
configManager.property("x", this.x);
|
||||||
|
configManager.property("y", this.y);
|
||||||
|
configManager.property("scale", this.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModDimensions(int x, int y, int width, int height, float scale) {
|
public ModDimensions(ConfigManager configManager, int x, int y, int width, int height, float scale) {
|
||||||
this.x = x;
|
this.x.value = x;
|
||||||
this.y = y;
|
this.y.value = y;
|
||||||
|
this.scale.value = scale;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.scale = scale;
|
configManager.property("x", this.x);
|
||||||
|
configManager.property("y", this.y);
|
||||||
|
configManager.property("scale", this.scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ public class ModManager {
|
|||||||
MatrixStack matrices = context.getMatrices();
|
MatrixStack matrices = context.getMatrices();
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
matrices.translate(dim.x, dim.y, 0);
|
matrices.translate(dim.x.value, (float) dim.y.value, 0);
|
||||||
|
|
||||||
matrices.scale(dim.scale, dim.scale, 1.0f);
|
matrices.scale(dim.scale.value, dim.scale.value, 1.0f);
|
||||||
|
|
||||||
((HudMod) m).render(context);
|
((HudMod) m).render(context);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.saturnclient.saturnmods.mods;
|
package org.saturnclient.saturnmods.mods;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
import org.saturnclient.saturnmods.HudMod;
|
import org.saturnclient.saturnmods.HudMod;
|
||||||
import org.saturnclient.saturnmods.ModDimensions;
|
import org.saturnclient.saturnmods.ModDimensions;
|
||||||
import org.saturnclient.saturnmods.SaturnMod;
|
import org.saturnclient.saturnmods.SaturnMod;
|
||||||
@@ -16,8 +18,9 @@ import net.minecraft.item.Items;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class ArmorDisplay implements SaturnMod, HudMod {
|
public class ArmorDisplay implements SaturnMod, HudMod {
|
||||||
private static ModDimensions dimensions = new ModDimensions(0, 0, 34, 75);
|
private static ConfigManager config = new ConfigManager("armor");
|
||||||
public static boolean enabled = false;
|
private static ModDimensions dimensions = new ModDimensions(config, 0, 0, 34, 75);
|
||||||
|
public static Property<Boolean> enabled = config.property("enabled", new Property<>(false));
|
||||||
|
|
||||||
private boolean renderItem(DrawContext context, ItemStack item, int y) {
|
private boolean renderItem(DrawContext context, ItemStack item, int y) {
|
||||||
if (item.isEmpty()) {
|
if (item.isEmpty()) {
|
||||||
@@ -101,10 +104,10 @@ public class ArmorDisplay implements SaturnMod, HudMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean e) {
|
public void setEnabled(boolean e) {
|
||||||
enabled = e;
|
enabled.value = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.saturnclient.saturnmods.mods;
|
package org.saturnclient.saturnmods.mods;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
import org.saturnclient.saturnmods.HudMod;
|
import org.saturnclient.saturnmods.HudMod;
|
||||||
import org.saturnclient.saturnmods.ModDimensions;
|
import org.saturnclient.saturnmods.ModDimensions;
|
||||||
import org.saturnclient.saturnmods.SaturnMod;
|
import org.saturnclient.saturnmods.SaturnMod;
|
||||||
@@ -12,8 +14,9 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class Coordinates implements SaturnMod, HudMod {
|
public class Coordinates implements SaturnMod, HudMod {
|
||||||
private static ModDimensions dimensions = new ModDimensions();
|
private static ConfigManager config = new ConfigManager("coords");
|
||||||
public static boolean enabled = false;
|
private static ModDimensions dimensions = new ModDimensions(config);
|
||||||
|
public static Property<Boolean> enabled = config.property("enabled", new Property<>(false));
|
||||||
|
|
||||||
public Coordinates() {
|
public Coordinates() {
|
||||||
}
|
}
|
||||||
@@ -58,10 +61,10 @@ public class Coordinates implements SaturnMod, HudMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean e) {
|
public void setEnabled(boolean e) {
|
||||||
enabled = e;
|
enabled.value = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"providers": [
|
||||||
|
{
|
||||||
|
"type": "reference",
|
||||||
|
"id": "saturnclient:panton"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Reference in New Issue
Block a user