diff options
| author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-03-21 14:48:22 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-21 08:48:22 +0100 |
| commit | 2696141f9790fd6c8d3df1148f46d298512c4902 (patch) | |
| tree | b05082fdb69de516ec34f07012055ac82dd0bb09 | |
| parent | 72118423d214b964ea9bd3d2a1411c72941c5f90 (diff) | |
| download | OneConfig-2696141f9790fd6c8d3df1148f46d298512c4902.tar.gz OneConfig-2696141f9790fd6c8d3df1148f46d298512c4902.tar.bz2 OneConfig-2696141f9790fd6c8d3df1148f46d298512c4902.zip | |
stuff (#1)
* new: use archloom instead of forgegradle
* misc: reformat code
* update archloom
22 files changed, 292 insertions, 356 deletions
diff --git a/build.gradle b/build.gradle index e320d14..7efe09c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,79 +1,98 @@ +//file:noinspection UnnecessaryQualifiedReference +//file:noinspection GroovyAssignabilityCheck + plugins { + id "dev.architectury.architectury-pack200" version "0.1.3" + id "com.github.johnrengelman.shadow" version "7.1.0" + id "cc.woverflow.loom" version "0.10.6" + id "net.kyori.blossom" version "1.3.0" id "java" - id "com.github.johnrengelman.shadow" version "6.1.0" - id "net.minecraftforge.gradle.forge" version "6f53277" } -group "io.polyfrost" -version "1.0-SNAPSHOT" -archivesBaseName = "OneConfig" +version = mod_version +group = "io.polyfrost" +archivesBaseName = mod_name + +blossom { + String className = "src/main/java/io/polyfrost/oneconfig/OneConfig.java" + replaceToken("@VER@", project.version, className) + replaceToken("@NAME@", mod_name, className) + replaceToken("@ID@", mod_id, className) +} -sourceCompatibility = targetCompatibility = 1.8 +sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 compileJava.options.encoding = 'UTF-8' -minecraft { - version = "1.8.9-11.15.1.2318-1.8.9" - runDir = "run" - mappings = "stable_22" - makeObfSourceJar = false +loom { + launchConfigs { + client { + + } + } + runConfigs { + client { + ideConfigGenerated = true + } + } + forge { + pack200Provider = new dev.architectury.pack200.java.Pack200Adapter() + } } configurations { - shade - implementation.extendsFrom(shade) + include + implementation.extendsFrom(include) } repositories { -mavenCentral() + maven { url 'https://repo.woverflow.cc/' } } dependencies { -implementation 'org.jetbrains:annotations:22.0.0' + minecraft("com.mojang:minecraft:1.8.9") + mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") + forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") } -/** - * This task simply replaces the `${version}` and `${mcversion}` properties in the mcmod.info with the data from Gradle - */ processResources { // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version + inputs.property "version", version + inputs.property "name", mod_name + inputs.property "id", mod_id - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'version': project.version, 'mcversion': project.minecraft.version + filesMatching("mcmod.info") { + expand( + "id": mod_id, + "name": mod_name, + "version": version + ) } - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } + rename '(.+_at.cfg)', 'META-INF/$1' } -/** - * This task simply moves resources so they can be accessed at runtime, Forge is quite weird isn't it - */ -task moveResources { - doLast { - ant.move file: "${buildDir}/resources/main", - todir: "${buildDir}/classes/java" +sourceSets { + main { + output.resourcesDir = java.classesDirectory } } -moveResources.dependsOn processResources -classes.dependsOn moveResources +remapJar { + archiveClassifier = "nodeps" +} + +jar { + manifest.attributes( + 'ModSide': 'CLIENT', + 'ForceLoadAsMod': true, + "TweakOrder": "0" + ) +} shadowJar { - archiveClassifier.set('dep') - configurations = [project.configurations.shade] + archiveClassifier.set('') + from(remapJar.archiveFile) + configurations = [project.configurations.include] duplicatesStrategy DuplicatesStrategy.EXCLUDE } - -reobf { shadowJar { mappingType = "SEARGE" } } -tasks.reobfShadowJar.mustRunAfter shadowJar -afterEvaluate { - build.dependsOn reobfShadowJar -}
\ No newline at end of file +assemble.dependsOn shadowJar
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..527e3ee --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +org.gradle.jvmargs=-Xmx2G +mod_name = OneConfig +mod_id = oneconfig +mod_version = 1.0.0 + +loom.platform = forge
\ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d913..b1159fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 9c76f81..4f8d00d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,30 +1,8 @@ pluginManagement { repositories { - mavenCentral() gradlePluginPortal() - - // Add the Forge Repository (ForgeGradle fetches most of its stuff from here) - maven { - name = "Forge" - url = "https://maven.minecraftforge.net" - } - - // Add the Jitpack Repository (We fetch ForgeGradle from this) - maven { - name = "Jitpack" - url = "https://jitpack.io/" - } - } - resolutionStrategy { - eachPlugin { - // If the "net.minecraftforge.gradle.forge" plugin is requested we redirect it to asbyth's ForgeGradle fork - if (requested.id.id == "net.minecraftforge.gradle.forge") { - useModule("com.github.asbyth:ForgeGradle:${requested.version}") - } - } + maven { url = "https://repo.woverflow.cc" } } } - -rootProject.name = 'oneConfig' - +rootProject.name = mod_name
\ No newline at end of file diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java index da4a604..7f29c39 100644 --- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/OneConfig.java @@ -14,7 +14,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import java.io.File; -@Mod(modid = "oneconfig", name = "OneConfig", version = "${version}") +@Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") public class OneConfig { private static final Minecraft mc = Minecraft.getMinecraft(); public static File jarFile; diff --git a/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java index 575fc3f..df727a0 100644 --- a/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java +++ b/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java @@ -39,8 +39,7 @@ public class OneConfigCommand implements ICommand { @Override public void processCommand(ICommandSender sender, String[] args) { - if (args.length == 0) - new TickDelay(() -> mc.displayGuiScreen(new Window()), 1); + if (args.length == 0) new TickDelay(() -> mc.displayGuiScreen(new Window()), 1); else { switch (args[0]) { case "hud": diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java index a518633..b46c65d 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java @@ -8,16 +8,16 @@ import java.io.*; import java.nio.charset.StandardCharsets; public class OneConfigConfig extends Config { + public static String currentProfile = "Default Profile"; + public OneConfigConfig() { super(null, "OneConfig.json"); } @Override public void init(ModData modData) { - if (new File("OneConfig/" + configFile).exists()) - load(); - else - save(); + if (new File("OneConfig/" + configFile).exists()) load(); + else save(); } @Override @@ -37,6 +37,4 @@ public class OneConfigConfig extends Config { e.printStackTrace(); } } - - public static String currentProfile = "Default Profile"; } diff --git a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java index a66a8a0..9bb2e85 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java +++ b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java @@ -10,13 +10,13 @@ import java.util.HashMap; public class ConfigCore { public static HashMap<ModData, ArrayList<Option>> settings = new HashMap<>(); - public static void saveAll () { + public static void saveAll() { for (ModData modData : settings.keySet()) { modData.config.save(); } } - public static void reInitAll () { + public static void reInitAll() { ArrayList<ModData> data = new ArrayList<>(settings.keySet()); settings.clear(); HudCore.huds.clear(); diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java index 2e3e92d..73dbbe7 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -20,8 +20,7 @@ import java.util.Optional; public class Config { protected final String configFile; - protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting() - .registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create(); + protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create(); /** * @param modData information about the mod @@ -33,10 +32,8 @@ public class Config { } public void init(ModData modData) { - if (Profiles.getProfileFile(configFile).exists()) - load(); - else - save(); + if (Profiles.getProfileFile(configFile).exists()) load(); + else save(); modData.config = this; ConfigCore.settings.put(modData, generateOptionList(this.getClass())); } @@ -109,8 +106,7 @@ public class Config { } } else { Option customOption = processCustomOption(field); - if (customOption != null) - options.add(customOption); + if (customOption != null) options.add(customOption); } } return options; diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java index 5980a63..99cf656 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java @@ -19,8 +19,7 @@ public abstract class Option { this.field = field; this.name = name; this.description = description; - if (field != null) - field.setAccessible(true); + if (field != null) field.setAccessible(true); } /** diff --git a/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java index db9fce2..45d448d 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java +++ b/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java @@ -11,8 +11,8 @@ import java.util.ArrayList; import java.util.Arrays; public class Profiles { - public static ArrayList<String> profiles; private static final File profileDir = new File("OneConfig/profiles"); + public static ArrayList<String> profiles; public static String getCurrentProfile() { if (!profileDir.exists() && !profileDir.mkdir()) { @@ -21,8 +21,7 @@ public class Profiles { } if (profiles == null) { String[] profilesArray = new File("OneConfig/profiles").list((file, s) -> file.isDirectory()); - if (profilesArray != null) - profiles = new ArrayList<>(Arrays.asList(profilesArray)); + if (profilesArray != null) profiles = new ArrayList<>(Arrays.asList(profilesArray)); } if (!getProfileDir(OneConfigConfig.currentProfile).exists()) { createProfile(OneConfigConfig.currentProfile); @@ -62,8 +61,7 @@ public class Profiles { try { File newFile = new File(new File("OneConfig/profiles"), newName); FileUtils.moveDirectory(getProfileDir(name), newFile); - if (OneConfigConfig.currentProfile.equals(name)) - OneConfigConfig.currentProfile = newName; + if (OneConfigConfig.currentProfile.equals(name)) OneConfigConfig.currentProfile = newName; profiles.remove(name); profiles.add(newName); } catch (IOException e) { diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java index 7b4fd99..abcd5ca 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCBlock.java @@ -21,9 +21,10 @@ import static io.polyfrost.oneconfig.gui.Window.resolution; public class OCBlock { public static final Theme theme = Themes.getActiveTheme(); private static final Minecraft mc = Minecraft.getMinecraft(); - private Color color; - private String text; private final boolean bold; + private final Color elementColor = theme.getElementColor(); + private final Color hoverColor = theme.getHoverColor(); + private final Runnable draw; /** * Width of the element in pixels. */ @@ -32,6 +33,8 @@ public class OCBlock { * Height of the element in pixels. */ public int height; + private Color color; + private String text; private ThemeElement element; private boolean clicked = false; private boolean rightClicked = false; @@ -41,9 +44,6 @@ public class OCBlock { private float percentHoveredGreen = 0f; private float percentHoveredBlue = 0f; private float percentHoveredAlpha = 0f; - private final Color elementColor = theme.getElementColor(); - private final Color hoverColor = theme.getHoverColor(); - private final Runnable draw; /** * Create a basic element. @@ -54,11 +54,11 @@ public class OCBlock { /** * Create a new basic element. - * @param color color of the element - * @param width width of the element + * + * @param color color of the element + * @param width width of the element * @param height height of the element - * @deprecated - * This method DOES NOT respect the theme colors for the element. Use of {@link #OCBlock(int, int)} is recommended instead. + * @deprecated This method DOES NOT respect the theme colors for the element. Use of {@link #OCBlock(int, int)} is recommended instead. */ @Deprecated() public OCBlock(int color, int width, int height) { @@ -67,8 +67,9 @@ public class OCBlock { /** * Create a new element with the specified text, and automatic width/height + padding. - * @param text text to use - * @param bold weather or not to use bold text + * + * @param text text to use + * @param bold weather or not to use bold text * @param color color for the text */ public OCBlock(@NotNull String text, boolean bold, int color) { @@ -77,8 +78,9 @@ public class OCBlock { /** * Create a new element with the specified text, and custom width/height. - * @param text text to use - * @param bold weather or not to use bold text + * + * @param text text to use + * @param bold weather or not to use bold text * @param color color for the text (use {@link Theme#getTextColor()} or {@link Theme#getAccentTextColor()} for default colors) */ public OCBlock(String text, boolean bold, int color, int width, int height) { @@ -92,7 +94,8 @@ public class OCBlock { /** * Create a new Element with the specified image. - * @param element element to use + * + * @param element element to use * @param colorMask color mast to use (-1 for default) */ public OCBlock(ThemeElement element, int colorMask, int width, int height) { @@ -106,6 +109,7 @@ public class OCBlock { /** * Create a new Element with a custom render script. The {@link Runnable} should ONLY contain #draw() calls or equivalent. + * * @param whatToDraw a {@link Runnable}, containing draw scripts for elements. You will need to instantiate the objects first, if they are sub-elements. */ public OCBlock(Runnable whatToDraw, int width, int height) { @@ -126,20 +130,19 @@ public class OCBlock { percentHoveredAlpha = smooth(percentHoveredAlpha, elementColor.getAlpha() / 255f, hoverColor.getAlpha() / 255f); GlStateManager.color(percentHoveredRed, percentHoveredGreen, percentHoveredBlue, percentHoveredAlpha); update(x, y); - if(draw != null) { + if (draw != null) { draw.run(); } - if(element != null) { + if (element != null) { theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); theme.getTextureManager().draw(element, x, y, width, height); } - if(text == null) { + if (text == null) { theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - } - else { + } else { theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - if(bold) { + if (bold) { theme.getBoldFont().drawString(text, x + 3, y + 2, 1f, 1f, color.getRGB()); } else { theme.getFont().drawString(text, x + 3, y + 2, 1.1f, 1f, color.getRGB()); @@ -157,7 +160,7 @@ public class OCBlock { int mouseX = Mouse.getX() / resolution.getScaleFactor(); int mouseY = Math.abs((Mouse.getY() / resolution.getScaleFactor()) - resolution.getScaledHeight()); hovered = mouseX > x && mouseY > y && mouseX < x + width && mouseY < y + height; - if(hovered) { + if (hovered) { onHover(); if (Mouse.isButtonDown(0) && !clicked) { onClick(0); @@ -170,10 +173,10 @@ public class OCBlock { rightClicked = Mouse.isButtonDown(1); onKeyPress(Keyboard.getEventKey()); } - if(clicked) { + if (clicked) { Renderer.color(theme.getClickColor()); } - if(!hovered && clicked) clicked = false; + if (!hovered && clicked) clicked = false; } /** @@ -188,6 +191,7 @@ public class OCBlock { /** * Override this method to set a function when a key is pressed while this element is hovered. + * * @param keyCode key code that was pressed (check org.lwjgl.Keyboard for keymap) */ public void onKeyPress(int keyCode) { @@ -196,6 +200,7 @@ public class OCBlock { /** * Override this method to set a function when the element is hovered. + * * @param button the button that was pressed (0 is left, 1 is right) */ public void onClick(int button) { @@ -213,46 +218,46 @@ public class OCBlock { private float smooth(float current, float min, float max) { current = Renderer.easeOut(current, isHovered() ? 1f : 0f); - if(current <= min) { + if (current <= min) { current = min; } - if(current >= max) { + if (current >= max) { current = max; } return current; } - public void setText(String text) { - this.text = text; - } - - public void setWidth(int width) { - this.width = width; + public int getHeight() { + return height; } public void setHeight(int height) { this.height = height; } - public int getHeight() { - return height; - } - public Color getColor() { return color; } + public void setColor(Color color) { + this.color = color; + } + public int getWidth() { return width; } + public void setWidth(int width) { + this.width = width; + } + public String getText() { return text; } - public void setColor(Color color) { - this.color = color; + public void setText(String text) { + this.text = text; } public boolean isHovered() { diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java index 298690f..5f78baa 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCButton.java @@ -8,13 +8,13 @@ import org.jetbrains.annotations.NotNull; import java.awt.*; public class OCButton extends OCBlock { + private final Color elementColor = theme.getElementColor(); + private final Color hoverColor = theme.getHoverColor(); private float percentHoveredRed = 0f; private float percentHoveredGreen = 0f; private float percentHoveredBlue = 0f; private float percentHoveredAlpha = 0f; private float percentDescription = 0f; - private final Color elementColor = theme.getElementColor(); - private final Color hoverColor = theme.getHoverColor(); private ThemeElement element; private boolean alwaysShowDesc = true; private String title, description; @@ -58,27 +58,27 @@ public class OCButton extends OCBlock { percentHoveredGreen = smooth(percentHoveredGreen, elementColor.getGreen() / 255f, hoverColor.getGreen() / 255f); percentHoveredBlue = smooth(percentHoveredBlue, elementColor.getBlue() / 255f, hoverColor.getBlue() / 255f); percentHoveredAlpha = smooth(percentHoveredAlpha, elementColor.getAlpha() / 255f, hoverColor.getAlpha() / 255f); - if(!alwaysShowDesc) { + if (!alwaysShowDesc) { percentDescription = Renderer.clamp(Renderer.easeOut(percentDescription, isHovered() ? 1f : 0f)); } GlStateManager.color(percentHoveredRed, percentHoveredGreen, percentHoveredBlue, percentHoveredAlpha); - if(isClicked()) { + if (isClicked()) { //Renderer.setGlColor(theme.getClickColor()); } theme.getTextureManager().draw(ThemeElement.BUTTON, x, y, width, height); - if(element != null) { - GlStateManager.color(1f,1f,1f, isClicked() ? 0.6f : 1f); + if (element != null) { + GlStateManager.color(1f, 1f, 1f, isClicked() ? 0.6f : 1f); theme.getTextureManager().draw(element, x + 19, y + 8, element.size, element.size); - if(title != null) { - if(alwaysShowDesc) { + if (title != null) { + if (alwaysShowDesc) { theme.getBoldFont().drawString(title, x + element.size + 25, y + 30, 1.2f, 1.2f, isClicked() ? theme.getTextColor().darker().getRGB() : theme.getTextColor().getRGB()); theme.getFont().drawString(description, x + element.size + 25, y + theme.getBoldFont().getHeight() + 37, 1.2f, 1.2f, isClicked() ? theme.getAccentTextColor().darker().getRGB() : theme.getAccentTextColor().getRGB()); } else { int titleY = y + 48; titleY -= (int) (percentDescription * 18); Color targetColor = theme.getAccentTextColor(); - Color currentColor = isClicked() ? targetColor.darker() : new Color(targetColor.getRed(), targetColor.getGreen(), targetColor.getBlue(), (int) (targetColor.getAlpha() * percentDescription)); + Color currentColor = isClicked() ? targetColor.darker() : new Color(targetColor.getRed(), targetColor.getGreen(), targetColor.getBlue(), (int) (targetColor.getAlpha() * percentDescription)); theme.getFont().drawString(description, x + element.size + 25, y + theme.getBoldFont().getHeight() + 37, 1.2f, 1.2f, currentColor.getRGB()); theme.getBoldFont().drawString(title, x + element.size + 25, titleY, 1.2f, 1.2f, isClicked() ? theme.getTextColor().darker().getRGB() : theme.getTextColor().getRGB()); } @@ -89,11 +89,11 @@ public class OCButton extends OCBlock { private float smooth(float current, float min, float max) { current = Renderer.easeOut(current, isHovered() ? 1f : 0f); - if(current <= min) { + if (current <= min) { current = min; } - if(current >= max) { + if (current >= max) { current = max; } return current; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java index 3d23b2f..d7fa7e9 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/OCStoreBlock.java @@ -1,16 +1,15 @@ package io.polyfrost.oneconfig.gui.elements; import io.polyfrost.oneconfig.renderer.Renderer; -import io.polyfrost.oneconfig.themes.textures.ThemeElement; -import net.minecraft.client.gui.Gui; import net.minecraft.util.ResourceLocation; import java.awt.*; public class OCStoreBlock extends OCBlock { - private ResourceLocation image; - private String description, title; - private Color color; + private final ResourceLocation image; + private final String description; + private final String title; + private final Color color; public OCStoreBlock(String title, String description, ResourceLocation image, int color) { super(color, 300, 400); @@ -31,6 +30,6 @@ public class OCStoreBlock extends OCBlock { } public void draw(int x, int y, int width, int height) { - draw(x,y); + draw(x, y); } } diff --git a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java index 262e36d..cc55e59 100644 --- a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java +++ b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java @@ -44,10 +44,8 @@ public class HudGui extends GuiScreen { float pos = getXSnapping(mouseX, true); float newWidth = pos - xFloat; float newScale = newWidth / ((hud.getWidth(hud.scale) + hud.paddingX * hud.scale) / hud.scale); - if (newScale > 20) - newScale = 20; - else if (newScale < 0.3) - newScale = 0.3f; + if (newScale > 20) newScale = 20; + else if (newScale < 0.3) newScale = 0.3f; hud.scale = newScale; if (xFloat / this.width > 0.5) @@ -65,8 +63,7 @@ public class HudGui extends GuiScreen { int color = new Color(215, 224, 235).getRGB(); if (editingHud == hud) { color = new Color(43, 159, 235).getRGB(); - if (isDragging) - Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB()); + if (isDragging) Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB()); } Renderer.drawLine(x - 2 / 4f, y, x + width + 2 / 4f, y, 2, color); Renderer.drawLine(x, y, x, y + height, 2, color); @@ -84,28 +81,20 @@ public class HudGui extends GuiScreen { float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - if (newX < 0) - newX = 0; - else if (newX + width > this.width) - newX = this.width - width; - if (newY < 0) - newY = 0; - else if (newY + height > this.height) - newY = this.height - height; + if (newX < 0) newX = 0; + else if (newX + width > this.width) newX = this.width - width; + if (newY < 0) newY = 0; + else if (newY + height > this.height) newY = this.height - height; |
