Skip to content

Commit

Permalink
1.3.2-7.2_01
Browse files Browse the repository at this point in the history
Garkatron committed Aug 25, 2024
1 parent 11c18d7 commit 8397e58
Showing 7 changed files with 78 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -15,6 +15,6 @@ halplibe_version=4.1.3
godot_signal_system_lib=1.0.0-7.2

# Mod
mod_version=1.3.1-7.2_01
mod_version=1.3.2-7.2_01
mod_group=deus
mod_name=stanleylib
4 changes: 4 additions & 0 deletions src/main/java/deus/stanleylib/config/ConfigHandler.java
Original file line number Diff line number Diff line change
@@ -12,6 +12,10 @@ public class ConfigHandler {
static {
Toml toml = new Toml("StanleyLibConfig");

toml.addCategory("Gui")
.addEntry("temperatureBar","vertical or horizontal","vertical")
.addEntry("temperatureBarCompact","small version",true);

toml.addCategory("temperatureManagement")
.addEntry("activateTemperatureManagement", true);

9 changes: 8 additions & 1 deletion src/main/java/deus/stanleylib/overlay/HudManager.java
Original file line number Diff line number Diff line change
@@ -3,15 +3,22 @@
import deus.stanleylib.StanleyLib;
import net.minecraft.client.gui.hud.*; // Asegúrate de que las importaciones sean correctas

import static deus.stanleylib.StanleyLib.MOD_CONFIG;

public class HudManager {
private static final HudComponent thermometer = HudComponents.register(new ThermometerComponent(
"thermometer",
182, 7,
ThermometerComponent.getTemperatureBarW(),
ThermometerComponent.getTemperatureBarH()
,
new SnapLayout(HudComponents.HOTBAR, ComponentAnchor.TOP_LEFT, ComponentAnchor.BOTTOM_LEFT)));

public static void init() {

StanleyLib.LOGGER.debug("Registering HUD components");
}



}

71 changes: 65 additions & 6 deletions src/main/java/deus/stanleylib/overlay/ThermometerComponent.java
Original file line number Diff line number Diff line change
@@ -13,12 +13,20 @@

import java.awt.*;

import static deus.stanleylib.StanleyLib.MOD_CONFIG;

public class ThermometerComponent extends MovableHudComponent {

private int width = 182;
private int height = 5;
private int width = getTemperatureBarW();
private int height = getTemperatureBarH();
private float currentTemperature = 0.0f;

private static final int COMPACT_HEIGHT = 48;
private static final int REGULAR_HEIGHT = 182;
private static final int COMPACT_WIDTH = 48;
private static final int REGULAR_WIDTH = 182;
private static final int SPECIAL_VALUE = 5; // Valor especial requerido

public Color freezing = new Color(0, 0, 255, 255); // Azul
public Color cold = new Color(152, 152, 232, 255); // Gris claro
public Color normal = new Color(122, 122, 122, 255); // Gris neutro
@@ -29,7 +37,7 @@ public class ThermometerComponent extends MovableHudComponent {
private float flashTime = 0.0f;
private long previousTime = 0;

private final String texture = "assets/stanleylib/textures/gui/thermometer.png"; // Ruta de la textura con el prefijo /
private final String texture = getTexture();
// assets/stanleylib/textures/gui/thermometer.png
// /assets/minecraft/textures/gui/icons.png

@@ -88,9 +96,24 @@ private void renderSprite(Minecraft mc, Gui gui, int x, int y, double targetTemp

GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(texture));

// Usa currentTemperature para dibujar la barra de temperatura suavizada
gui.drawTexturedModalRect(x, y, 0, 0, width, height);
gui.drawTexturedModalRect(x, y, 0, height, (int) (currentTemperature * width), height);
int textureWidth = width;
int textureHeight = height;

// Draw the thermometer texture background
gui.drawTexturedModalRect(x, y, 0, 0, textureWidth, textureHeight);

// Calculate the height or width to draw based on orientation
if (MOD_CONFIG.getConfig().getString("Gui.temperatureBar").equals("vertical")) {
int filledHeight = (int) (currentTemperature * height);
// Ensure filled height doesn't exceed the component height
filledHeight = Math.min(filledHeight, height);
gui.drawTexturedModalRect(x, y + height - filledHeight, width, height - filledHeight, width, filledHeight);
} else {
int filledWidth = (int) (currentTemperature * width);
// Ensure filled width doesn't exceed the component width
filledWidth = Math.min(filledWidth, width);
gui.drawTexturedModalRect(x, y, 0, height, filledWidth, height);
}

previousTime = System.currentTimeMillis(); // Actualizar el tiempo anterior
}
@@ -141,4 +164,40 @@ public double lerp(double a, double b, double t){
return a + (b - a) * t;
}

public static int getTemperatureBarH() {
String orientation = MOD_CONFIG.getConfig().getString("Gui.temperatureBar");
boolean isCompact = MOD_CONFIG.getConfig().getBoolean("Gui.temperatureBarCompact");

if ("vertical".equals(orientation)) {
return isCompact ? COMPACT_HEIGHT : REGULAR_HEIGHT;
} else {
return SPECIAL_VALUE;
}
}

public static int getTemperatureBarW() {
String orientation = MOD_CONFIG.getConfig().getString("Gui.temperatureBar");
boolean isCompact = MOD_CONFIG.getConfig().getBoolean("Gui.temperatureBarCompact");

if ("horizontal".equals(orientation)) {
return isCompact ? COMPACT_WIDTH : REGULAR_WIDTH;
} else {
return SPECIAL_VALUE;
}
}

public static String getTexture() {
String orientation = MOD_CONFIG.getConfig().getString("Gui.temperatureBar");
boolean isCompact = MOD_CONFIG.getConfig().getBoolean("Gui.temperatureBarCompact");
if ("horizontal".equals(orientation)) {
return isCompact ? "assets/stanleylib/textures/gui/c_thermometer.png" : "assets/stanleylib/textures/gui/thermometer.png";
} else {

if ("vertical".equals(orientation)) {
return isCompact ? "assets/stanleylib/textures/gui/vc_thermometer.png" : "assets/stanleylib/textures/gui/v_thermometer.png";
} else {
return "";
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8397e58

Please sign in to comment.